mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
* [ADF-3093] Started li18nt VS Code extension * [ADF-3093] Started work on UI style lint tool for VSCode * [ADF-3093] Added UI style rules up to sg0006 * [ADF-3093] Added remaining style rules * [ADF-3093] Added docs and command line tool * [ADF-3093] Removed Microsoft notices and updated licences to Apache-2.0
33 lines
830 B
TypeScript
33 lines
830 B
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as program from 'commander';
|
|
|
|
import {
|
|
SGStringProblem, sgErrorMessages, rules
|
|
} from './li18nt/server/src/SGStyleRules';
|
|
|
|
|
|
program
|
|
.usage(" <source>")
|
|
.parse(process.argv);
|
|
|
|
if (program.args.length === 0) {
|
|
console.log('Error: source file "en.json" must be provided');
|
|
process.exit();
|
|
}
|
|
|
|
let text = fs.readFileSync(path.resolve(program.args[0]), 'utf8');
|
|
|
|
let lines = text.split(/\r?\n/g);
|
|
let messages: SGStringProblem[] = [];
|
|
|
|
lines.forEach((line, index) => {
|
|
rules.forEach(rule => {
|
|
let newProblems = rule(line, index);
|
|
messages.push(...newProblems);
|
|
});
|
|
});
|
|
|
|
messages.forEach(message => {
|
|
console.log(`Line ${message.lineNum} (${message.startCharPos}-${message.endCharPos}): ${sgErrorMessages[message.messageCode]}`)
|
|
}); |