mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -17,6 +17,7 @@ const vfs = require('vinyl-fs');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const pall = require('p-all');
|
||||
const task = require('./lib/task');
|
||||
|
||||
/**
|
||||
* Hygiene works by creating cascading subsets of all our files and
|
||||
@@ -57,6 +58,7 @@ const indentationFilter = [
|
||||
'!test/assert.js',
|
||||
|
||||
// except specific folders
|
||||
'!test/automation/out/**',
|
||||
'!test/smoke/out/**',
|
||||
'!extensions/vscode-api-tests/testWorkspace/**',
|
||||
'!extensions/vscode-api-tests/testWorkspace2/**',
|
||||
@@ -192,13 +194,13 @@ const tslintBaseFilter = [
|
||||
];
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
const useStrictFilter = [
|
||||
'src/**'
|
||||
];
|
||||
// const useStrictFilter = [
|
||||
// 'src/**'
|
||||
// ];
|
||||
|
||||
const sqlFilter = [
|
||||
'src/sql/**'
|
||||
];
|
||||
// const sqlFilter = [
|
||||
// 'src/sql/**'
|
||||
// ];
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
|
||||
@@ -206,6 +208,7 @@ const tslintCoreFilter = [
|
||||
'src/**/*.ts',
|
||||
'test/**/*.ts',
|
||||
'!extensions/**/*.ts',
|
||||
'!test/automation/**',
|
||||
'!test/smoke/**',
|
||||
...tslintBaseFilter
|
||||
];
|
||||
@@ -214,6 +217,7 @@ const tslintExtensionsFilter = [
|
||||
'extensions/**/*.ts',
|
||||
'!src/**/*.ts',
|
||||
'!test/**/*.ts',
|
||||
'test/automation/**/*.ts',
|
||||
...tslintBaseFilter
|
||||
];
|
||||
|
||||
@@ -256,6 +260,33 @@ gulp.task('tslint', () => {
|
||||
]).pipe(es.through());
|
||||
});
|
||||
|
||||
function checkPackageJSON(actualPath) {
|
||||
const actual = require(path.join(__dirname, '..', actualPath));
|
||||
const rootPackageJSON = require('../package.json');
|
||||
|
||||
for (let depName in actual.dependencies) {
|
||||
const depVersion = actual.dependencies[depName];
|
||||
const rootDepVersion = rootPackageJSON.dependencies[depName];
|
||||
if (!rootDepVersion) {
|
||||
// missing in root is allowed
|
||||
continue;
|
||||
}
|
||||
if (depVersion !== rootDepVersion) {
|
||||
this.emit('error', `The dependency ${depName} in '${actualPath}' (${depVersion}) is different than in the root package.json (${rootDepVersion})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const checkPackageJSONTask = task.define('check-package-json', () => {
|
||||
return gulp.src('package.json')
|
||||
.pipe(es.through(function() {
|
||||
checkPackageJSON.call(this, 'remote/package.json');
|
||||
checkPackageJSON.call(this, 'remote/web/package.json');
|
||||
}));
|
||||
});
|
||||
gulp.task(checkPackageJSONTask);
|
||||
|
||||
|
||||
function hygiene(some) {
|
||||
let errorCount = 0;
|
||||
|
||||
@@ -307,19 +338,19 @@ function hygiene(some) {
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Check for unnecessary 'use strict' lines. These are automatically added by the alwaysStrict compiler option so don't need to be added manually
|
||||
const useStrict = es.through(function (file) {
|
||||
const lines = file.__lines;
|
||||
// Only take the first 10 lines to reduce false positives- the compiler will throw an error if it's not the first non-comment line in a file
|
||||
// (10 is used to account for copyright and extraneous newlines)
|
||||
lines.slice(0, 10).forEach((line, i) => {
|
||||
if (/\s*'use\s*strict\s*'/.test(line)) {
|
||||
console.error(file.relative + '(' + (i + 1) + ',1): Unnecessary \'use strict\' - this is already added by the compiler');
|
||||
errorCount++;
|
||||
}
|
||||
});
|
||||
// const useStrict = es.through(function (file) {
|
||||
// const lines = file.__lines;
|
||||
// // Only take the first 10 lines to reduce false positives- the compiler will throw an error if it's not the first non-comment line in a file
|
||||
// // (10 is used to account for copyright and extraneous newlines)
|
||||
// lines.slice(0, 10).forEach((line, i) => {
|
||||
// if (/\s*'use\s*strict\s*'/.test(line)) {
|
||||
// console.error(file.relative + '(' + (i + 1) + ',1): Unnecessary \'use strict\' - this is already added by the compiler');
|
||||
// errorCount++;
|
||||
// }
|
||||
// });
|
||||
|
||||
this.emit('data', file);
|
||||
});
|
||||
// this.emit('data', file);
|
||||
// });
|
||||
// {{SQL CARBON EDIT}} END
|
||||
|
||||
const formatting = es.map(function (file, cb) {
|
||||
@@ -370,16 +401,16 @@ function hygiene(some) {
|
||||
input = some;
|
||||
}
|
||||
|
||||
const tslintSqlConfiguration = tslint.Configuration.findConfiguration('tslint-sql.json', '.');
|
||||
// const tslintSqlConfiguration = tslint.Configuration.findConfiguration('tslint-sql.json', '.'); // TODO RESTORE
|
||||
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);
|
||||
// const sqlTsl = es.through(function (file) { //TODO restore
|
||||
// const contents = file.contents.toString('utf8');
|
||||
// sqlTsLinter.lint(file.relative, contents, tslintSqlConfiguration.results);
|
||||
|
||||
this.emit('data', file);
|
||||
});
|
||||
// this.emit('data', file);
|
||||
// });
|
||||
|
||||
const productJsonFilter = filter('product.json', { restore: true });
|
||||
|
||||
@@ -393,15 +424,13 @@ function hygiene(some) {
|
||||
.pipe(filter(copyrightFilter))
|
||||
.pipe(copyrights);
|
||||
|
||||
const typescript = result
|
||||
let typescript = result
|
||||
.pipe(filter(tslintHygieneFilter))
|
||||
.pipe(formatting)
|
||||
.pipe(tsl)
|
||||
// {{SQL CARBON EDIT}}
|
||||
.pipe(filter(useStrictFilter))
|
||||
.pipe(useStrict)
|
||||
.pipe(filter(sqlFilter))
|
||||
.pipe(sqlTsl);
|
||||
.pipe(formatting);
|
||||
|
||||
if (!process.argv.some(arg => arg === '--skip-tslint')) {
|
||||
typescript = typescript.pipe(tsl);
|
||||
}
|
||||
|
||||
const javascript = result
|
||||
.pipe(filter(eslintFilter))
|
||||
@@ -487,7 +516,7 @@ function createGitIndexVinyls(paths) {
|
||||
.then(r => r.filter(p => !!p));
|
||||
}
|
||||
|
||||
gulp.task('hygiene', () => hygiene());
|
||||
gulp.task('hygiene', task.series(checkPackageJSONTask, () => hygiene()));
|
||||
|
||||
// this allows us to run hygiene as a git pre-commit hook
|
||||
if (require.main === module) {
|
||||
|
||||
Reference in New Issue
Block a user