Skip to content

Commit 0055cf0

Browse files
authored
Migrating to ESLint and adding recommit checks (#17908)
* chore: Update eslint configuration and remove unused files * Adding pre commit hook * Fixing eslint parser * fix lint * chore: Update eslint configuration and remove unused files * Update eslint configuration and add eslint-plugin-jsdoc * chore: Update eslint configuration to use "warn" level for "notice/notice" rule
1 parent 5f560a9 commit 0055cf0

9 files changed

+1089
-298
lines changed

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
"yaml.schemas": {
2222
"https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json": "build/**/*.yml"
2323
},
24+
"eslint.validate": [ "javascript", "javascriptreact", "html", "typescriptreact", "typescript" ],
2425
}

.vscode/tasks.json

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"_id": "build",
2121
"isDefault": false
2222
}
23+
},
24+
{
25+
"type": "npm",
26+
"script": "lint",
27+
"problemMatcher": [],
28+
"label": "npm: lint",
29+
"detail": "eslint ."
2330
}
2431
]
2532
}

eslint.config.mjs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// @ts-check
2+
3+
import tseslint from 'typescript-eslint';
4+
import notice from "eslint-plugin-notice";
5+
import jsdoc from 'eslint-plugin-jsdoc';
6+
7+
export default [
8+
{
9+
files: ['**/*.ts', '**/*.tsx'],
10+
ignores: ['src/prompts/**/*.ts'], // Ignore prompts files as they are copied from other repos
11+
languageOptions: {
12+
parser: tseslint.parser
13+
},
14+
plugins: {
15+
notice,
16+
jsdoc
17+
},
18+
rules: {
19+
"notice/notice": [
20+
"warn",
21+
{
22+
template: `/*---------------------------------------------------------------------------------------------
23+
* Copyright (c) Microsoft Corporation. All rights reserved.
24+
* Licensed under the MIT License. See License.txt in the project root for license information.
25+
*--------------------------------------------------------------------------------------------*/
26+
27+
`,
28+
onNonMatchingHeader: 'prepend',
29+
messages: {
30+
whenFailedToMatch: "Missing or incorrectly formatted copyright statement.",
31+
}
32+
},
33+
34+
],
35+
"no-undef": "off",
36+
"no-unused-vars": "off",
37+
"constructor-super": "warn",
38+
"curly": "off",
39+
"eqeqeq": "warn",
40+
"no-buffer-constructor": "warn",
41+
"no-caller": "warn",
42+
"no-debugger": "warn",
43+
"no-duplicate-case": "warn",
44+
"no-duplicate-imports": "off",
45+
"no-eval": "warn",
46+
"no-async-promise-executor": "off",
47+
"no-extra-semi": "warn",
48+
"no-new-wrappers": "warn",
49+
"no-redeclare": "off",
50+
"no-sparse-arrays": "warn",
51+
"no-throw-literal": "off",
52+
"no-unsafe-finally": "warn",
53+
"no-unused-labels": "warn",
54+
"no-restricted-globals": [
55+
"warn",
56+
"name",
57+
"length",
58+
"event",
59+
"closed",
60+
"external",
61+
"status",
62+
"origin",
63+
"orientation",
64+
"context"
65+
], // non-complete list of globals that are easy to access unintentionally
66+
"no-var": "off",
67+
"semi": "off",
68+
"jsdoc/no-types": "warn",
69+
},
70+
}
71+
];

gulpfile.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
var gulp = require('gulp');
22
var rename = require('gulp-rename');
3-
var gulpTsLint = require('gulp-tslint');
43
var ts = require('gulp-typescript');
5-
var tslint = require('tslint');
64
var tsProject = ts.createProject('tsconfig.json');
75
var del = require('del');
86
var srcmap = require('gulp-sourcemaps');
@@ -14,24 +12,20 @@ var nls = require('vscode-nls-dev');
1412
var argv = require('yargs').argv;
1513
var min = (argv.min === undefined) ? false : true;
1614
var vscodeTest = require('@vscode/test-electron');
15+
const gulpESLintNew = require('gulp-eslint-new');
1716

1817
require('./tasks/packagetasks');
1918
require('./tasks/localizationtasks');
2019

2120
gulp.task('ext:lint', () => {
22-
// !! If updating this make sure to check if you need to update the TSA Scan task in ADO !!
23-
var program = tslint.Linter.createProgram('tsconfig.json');
2421
return gulp.src([
2522
config.paths.project.root + '/src/**/*.ts',
2623
'!' + config.paths.project.root + '/src/views/htmlcontent/**/*',
2724
config.paths.project.root + '/test/**/*.ts'
2825
])
29-
.pipe((gulpTsLint({
30-
program,
31-
formatter: "verbose",
32-
rulesDirectory: "node_modules/tslint-microsoft-contrib"
33-
})))
34-
.pipe(gulpTsLint.report());
26+
.pipe(gulpESLintNew())
27+
.pipe(gulpESLintNew.format()) // Output lint results to the console.
28+
.pipe(gulpESLintNew.failAfterError());
3529
});
3630

3731
// Copy icons for OE

package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"scripts": {
5151
"build": "gulp build",
5252
"compile": "gulp ext:compile",
53-
"watch": "gulp watch"
53+
"watch": "gulp watch",
54+
"lint": "gulp lint"
5455
},
5556
"devDependencies": {
5657
"@angular/common": "~2.1.2",
@@ -61,8 +62,10 @@
6162
"@angular/platform-browser-dynamic": "~2.1.2",
6263
"@angular/router": "~3.1.2",
6364
"@angular/upgrade": "~2.1.2",
65+
"@eslint/js": "^9.5.0",
6466
"@types/azdata": "^1.44.0",
6567
"@types/ejs": "^3.1.0",
68+
"@types/eslint__js": "^8.42.3",
6669
"@types/jquery": "^3.3.31",
6770
"@types/jqueryui": "^1.12.7",
6871
"@types/keytar": "^4.4.2",
@@ -83,15 +86,19 @@
8386
"coveralls": "^3.0.2",
8487
"decache": "^4.1.0",
8588
"del": "^2.2.1",
89+
"eslint": "^9.5.0",
90+
"eslint-plugin-jsdoc": "^48.2.12",
91+
"eslint-plugin-notice": "^1.0.0",
8692
"gulp": "^4.0.2",
8793
"gulp-concat": "^2.6.0",
94+
"gulp-eslint-new": "^2.1.0",
8895
"gulp-istanbul-report": "0.0.1",
8996
"gulp-rename": "^1.2.2",
9097
"gulp-shell": "^0.7.0",
9198
"gulp-sourcemaps": "^1.6.0",
92-
"gulp-tslint": "^8.1.4",
9399
"gulp-typescript": "^5.0.1",
94100
"gulp-uglify": "^2.0.0",
101+
"husky": "^9.0.11",
95102
"istanbul": "^0.4.5",
96103
"pm-mocha-jenkins-reporter": "^0.2.6",
97104
"remap-istanbul": "0.9.6",
@@ -101,10 +108,9 @@
101108
"systemjs": "0.19.40",
102109
"systemjs-builder": "^0.15.32",
103110
"systemjs-plugin-json": "^0.2.0",
104-
"tslint": "^6.1.3",
105-
"tslint-microsoft-contrib": "^6.2.0",
106111
"typemoq": "^1.7.0",
107-
"typescript": "^5.0.4",
112+
"typescript": "^5.4.5",
113+
"typescript-eslint": "^7.13.1",
108114
"uglify-js": "mishoo/UglifyJS2#harmony-v2.8.22",
109115
"vscode-nls-dev": "2.0.1",
110116
"yargs": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz"
@@ -1215,4 +1221,4 @@
12151221
}
12161222
}
12171223
}
1218-
}
1224+
}

tslint.json

-130
This file was deleted.

tslint.mssdl.required.json

-25
This file was deleted.

0 commit comments

Comments
 (0)