Change double-quote hygiene rule to tslint rule (#6514)

This commit is contained in:
Charles Gagnon
2019-08-05 09:46:22 -07:00
committed by GitHub
parent a5a37c97a9
commit 8a6dc02e5b
23 changed files with 228 additions and 53 deletions

View File

@@ -289,19 +289,6 @@ function hygiene(some) {
this.emit('data', file);
});
const localizeDoubleQuotes = es.through(function (file) {
const lines = file.__lines;
lines.forEach((line, i) => {
if (/localize\(['"].*['"],\s'.*'\)/.test(line)) {
console.error(file.relative + '(' + (i + 1) + ',1): Message parameter to localize calls should be double-quotes');
errorCount++;
}
});
this.emit('data', file);
});
// {{SQL CARBON EDIT}} END
const formatting = es.map(function (file, cb) {
@@ -352,6 +339,17 @@ function hygiene(some) {
input = some;
}
const tslintSqlConfiguration = tslint.Configuration.findConfiguration('tslint-sql.json', '.');
const tslintSqlOptions = { fix: false, formatter: 'json' };
const sqlTsLinter = new tslint.Linter(tslintSqlOptions);
const sqlTsl = es.through(function (file) {
const contents = file.contents.toString('utf8');
sqlTsLinter.lint(file.relative, contents, tslintSqlConfiguration.results);
this.emit('data', file);
});
const productJsonFilter = filter('product.json', { restore: true });
const result = input
@@ -371,9 +369,8 @@ function hygiene(some) {
// {{SQL CARBON EDIT}}
.pipe(filter(useStrictFilter))
.pipe(useStrict)
// Only look at files under the sql folder since we don't want to cause conflicts with VS code
.pipe(filter(sqlFilter))
.pipe(localizeDoubleQuotes);
.pipe(sqlTsl);
const javascript = result
.pipe(filter(eslintFilter))
@@ -405,6 +402,19 @@ function hygiene(some) {
errorCount += tslintResult.failures.length;
}
const sqlTslintResult = sqlTsLinter.getResult();
if (sqlTslintResult.failures.length > 0) {
for (const failure of sqlTslintResult.failures) {
const name = failure.getFileName();
const position = failure.getStartPosition();
const line = position.getLineAndCharacter().line;
const character = position.getLineAndCharacter().character;
console.error(`${name}:${line + 1}:${character + 1}:${failure.getFailure()}`);
}
errorCount += sqlTslintResult.failures.length;
}
if (errorCount > 0) {
this.emit('error', 'Hygiene failed with ' + errorCount + ' errors. Check \'build/gulpfile.hygiene.js\'.');
} else {