Skip to content

Commit e370a3b

Browse files
authored
Remove pre commit hook and disabled mandating copyright headers (#3243)
For #2963
1 parent 760fbdb commit e370a3b

File tree

7 files changed

+30
-49
lines changed

7 files changed

+30
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
.huskyrc.json
23
out
34
node_modules
45
*.pyc

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"eg2.tslint"
6+
]
7+
}

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.gitattributes
66
.gitignore
77
.gitmodules
8+
.huskyrc.json
89
.npmrc
910
.travis.yml
1011
CODE_OF_CONDUCT.md

build/tslint-rules/copyrightAndStrictHeaderRule.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ const copyrightHeaderNoSpace = [
1616
'// Licensed under the MIT License.',
1717
'\'use strict\';'
1818
];
19-
20-
const allowedCopyrightHeaders = [copyrightHeader.join('\n'), copyrightHeader.join('\r\n'), copyrightHeaderNoSpace.join('\n'), copyrightHeaderNoSpace.join('\r\n')];
21-
const failureMessage = 'Header must contain copyright and \'use strict\' in the Python Extension';
19+
const allowedCopyrightHeaders = [
20+
copyrightHeader.join('\n'), copyrightHeader.join('\r\n'),
21+
copyrightHeaderNoSpace.join('\n'), copyrightHeaderNoSpace.join('\r\n'),
22+
'\'use strict\';'
23+
];
24+
const failureMessage = 'Header must contain either \'use strict\' or [copyright] & \'use strict\' in the Python Extension files';
2225
class NoFileWithoutCopyrightHeader extends baseRuleWalker_1.BaseRuleWalker {
2326
visitSourceFile(sourceFile) {
2427
if (!this.sholdIgnoreCcurrentFile(sourceFile)) {

build/tslint-rules/copyrightAndStrictHeaderRule.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ const copyrightHeader = [
1414
'',
1515
'\'use strict\';'
1616
];
17-
const allowedCopyrightHeaders = [copyrightHeader.join('\n'), copyrightHeader.join('\r\n')];
18-
const failureMessage = 'Header must contain copyright and \'use strict\' in the Python Extension';
17+
const copyrightHeaderNoSpace = [
18+
'// Copyright (c) Microsoft Corporation. All rights reserved.',
19+
'// Licensed under the MIT License.',
20+
'\'use strict\';'
21+
];
22+
const allowedCopyrightHeaders = [
23+
copyrightHeader.join('\n'), copyrightHeader.join('\r\n'),
24+
copyrightHeaderNoSpace.join('\n'), copyrightHeaderNoSpace.join('\r\n'),
25+
'\'use strict\';'
26+
];
27+
const failureMessage = 'Header must contain either \'use strict\' or [copyright] & \'use strict\' in the Python Extension files';
1928

2029
class NoFileWithoutCopyrightHeader extends BaseRuleWalker {
2130
public visitSourceFile(sourceFile: ts.SourceFile) {

gulpfile.js

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,6 @@ const tslintFilter = [
7474
'!**/*.d.ts'
7575
];
7676

77-
const copyrightHeader = [
78-
'// Copyright (c) Microsoft Corporation. All rights reserved.',
79-
'// Licensed under the MIT License.',
80-
'',
81-
'\'use strict\';'
82-
];
83-
const copyrightHeaderNoSpace = [
84-
'// Copyright (c) Microsoft Corporation. All rights reserved.',
85-
'// Licensed under the MIT License.',
86-
'\'use strict\';'
87-
];
88-
const copyrightHeaders = [copyrightHeader.join('\n'), copyrightHeader.join('\r\n'), copyrightHeaderNoSpace.join('\n'), copyrightHeaderNoSpace.join('\r\n')];
89-
9077
gulp.task('precommit', (done) => run({ exitOnError: true, mode: 'staged' }, done));
9178

9279
gulp.task('hygiene-watch', () => gulp.watch(tsFilter, gulp.series('hygiene-modified')));
@@ -274,7 +261,6 @@ function buildDebugAdapterCoverage(done) {
274261
* @property {'changes'|'staged'|'all'|'compile'|'diffMaster'} [mode=] - Mode.
275262
* @property {boolean=} skipIndentationCheck - Skip indentation checks.
276263
* @property {boolean=} skipFormatCheck - Skip format checks.
277-
* @property {boolean=} skipCopyrightCheck - Skip copyright checks.
278264
* @property {boolean=} skipLinter - Skip linter.
279265
*/
280266

@@ -322,19 +308,6 @@ const hygiene = (options, done) => {
322308
compilationInProgress = true;
323309
options = options || {};
324310
let errorCount = 0;
325-
const addedFiles = options.skipCopyrightCheck ? [] : getAddedFilesSync();
326-
const copyrights = es.through(function (file) {
327-
if (addedFiles.indexOf(file.path) !== -1) {
328-
const contents = file.contents.toString('utf8');
329-
if (!copyrightHeaders.some(header => contents.indexOf(header) === 0)) {
330-
// Use tslint format.
331-
console.error(`ERROR: (copyright) ${file.relative}[1,1]: Missing or bad copyright statement`);
332-
errorCount++;
333-
}
334-
}
335-
336-
this.emit('data', file);
337-
});
338311

339312
const indentation = es.through(function (file) {
340313
file.contents
@@ -479,10 +452,6 @@ const hygiene = (options, done) => {
479452
result = result
480453
.pipe(filter(tslintFilter));
481454

482-
if (!options.skipCopyrightCheck) {
483-
result = result.pipe(copyrights);
484-
}
485-
486455
if (!options.skipFormatCheck) {
487456
// result = result
488457
// .pipe(formatting);
@@ -548,7 +517,6 @@ const hygiene = (options, done) => {
548517
* @property {string[]=} files - Optional list of files to be modified.
549518
* @property {boolean=} skipIndentationCheck - Skip indentation checks.
550519
* @property {boolean=} skipFormatCheck - Skip format checks.
551-
* @property {boolean=} skipCopyrightCheck - Skip copyright checks.
552520
* @property {boolean=} skipLinter - Skip linter.
553521
* @property {boolean=} watch - Watch mode.
554522
*/
@@ -693,14 +661,7 @@ function getFileListToProcess(options) {
693661

694662
exports.hygiene = hygiene;
695663

696-
// // this allows us to run hygiene via CLI (e.g. `node gulfile.js`).
697-
// if (require.main === module) {
698-
// const args = process.argv0.length > 2 ? process.argv.slice(2) : [];
699-
// const isPreCommit = args.findIndex(arg => arg.startsWith('precommit='));
700-
// const performPreCommitCheck = isPreCommit >= 0 ? args[isPreCommit].split('=')[1].trim().toUpperCase().startsWith('T') : false;
701-
// // Allow precommit hooks for those with a file `./out/precommit.hook`.
702-
// if (args.length > 0 && (!performPreCommitCheck || !fs.existsSync(path.join(__dirname, 'precommit.hook')))) {
703-
// return;
704-
// }
705-
// run({ exitOnError: true, mode: 'staged' }, () => { });
706-
// }
664+
// this allows us to run hygiene via CLI (e.g. `node gulfile.js`).
665+
if (require.main === module) {
666+
run({ exitOnError: true, mode: 'staged' }, () => { });
667+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,6 @@
16871687
"testMultiWorkspace": "node ./out/test/multiRootTest.js",
16881688
"testAnalysisEngine": "node ./out/test/analysisEngineTest.js",
16891689
"testPerformance": "node ./out/test/performanceTest.js",
1690-
"precommit": "node gulpfile.js precommit=true",
16911690
"lint-staged": "node gulpfile.js",
16921691
"lint": "tslint src/**/*.ts -t verbose",
16931692
"clean": "gulp clean",

0 commit comments

Comments
 (0)