Skip to content

Commit 9f7c0cb

Browse files
authored
Run ESLint over our JS files, fix all lints (microsoft#50172)
1 parent 03b12a6 commit 9f7c0cb

File tree

12 files changed

+44
-19
lines changed

12 files changed

+44
-19
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/tests/**
33
/lib/**
44
/src/lib/*.generated.d.ts
5+
/scripts/*.js
6+
/scripts/eslint/built/**

.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
"plugins": [
1414
"@typescript-eslint", "jsdoc", "no-null", "import"
1515
],
16+
"overrides": [
17+
// By default, the ESLint CLI only looks at .js files. But, it will also look at
18+
// any files which are referenced in an override config. Most users of typescript-eslint
19+
// get this behavior by default by extending a recommended typescript-eslint config, which
20+
// just so happens to override some core ESLint rules. We don't extend from any config, so
21+
// explicitly reference TS files here so the CLI picks them up.
22+
//
23+
// ESLint in VS Code will lint any opened file (so long as it's not eslintignore'd), so
24+
// that will work regardless of the below.
25+
{ "files": ["*.ts"] }
26+
],
1627
"rules": {
1728
"@typescript-eslint/adjacent-overload-signatures": "error",
1829
"@typescript-eslint/array-type": "error",

.vscode/settings.template.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
],
77
"eslint.options": {
88
"rulePaths": ["./scripts/eslint/built/rules/"],
9-
"extensions": [".ts"]
109
},
1110
// To use the last-known-good (LKG) compiler version:
1211
// "typescript.tsdk": "lib"

Gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ const eslint = (folder) => async () => {
358358
"--cache-location", `${folder}/.eslintcache`,
359359
"--format", formatter,
360360
"--rulesdir", "scripts/eslint/built/rules",
361-
"--ext", ".ts",
362361
];
363362

364363
if (cmdLineOptions.fix) {

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"typescript": "^4.5.5",
8989
"vinyl": "latest",
9090
"vinyl-sourcemaps-apply": "latest",
91+
"which": "^2.0.2",
9192
"xml2js": "^0.4.23"
9293
},
9394
"overrides": {

scripts/build/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = minimist(process.argv.slice(2), {
77
boolean: ["dirty", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built"],
88
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
99
alias: {
10+
/* eslint-disable quote-props */
1011
"b": "browser",
1112
"i": ["inspect", "inspect-brk", "break", "debug", "debug-brk"],
1213
"t": ["tests", "test"],
@@ -16,6 +17,7 @@ module.exports = minimist(process.argv.slice(2), {
1617
"skippercent": "skipPercent",
1718
"w": "workers",
1819
"f": "fix"
20+
/* eslint-enable quote-props */
1921
},
2022
default: {
2123
soft: false,

scripts/build/prepend.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @ts-check
22
const stream = require("stream");
3-
const Vinyl = require("vinyl");
43
const ts = require("../../lib/typescript");
54
const fs = require("fs");
65
const { base64VLQFormatEncode } = require("./sourcemaps");
@@ -43,13 +42,14 @@ function prepend(data) {
4342
sourcesContent: input.sourcesContent
4443
};
4544
}
45+
// eslint-disable-next-line boolean-trivia, no-null/no-null
4646
return cb(null, output);
4747
}
4848
catch (e) {
4949
return cb(e);
5050
}
5151
}
52-
})
52+
});
5353
}
5454
exports.prepend = prepend;
5555

@@ -59,6 +59,6 @@ exports.prepend = prepend;
5959
function prependFile(file) {
6060
const data = typeof file === "string" ? fs.readFileSync(file, "utf8") :
6161
vinyl => fs.readFileSync(file(vinyl), "utf8");
62-
return prepend(data)
62+
return prepend(data);
6363
}
64-
exports.prependFile = prependFile;
64+
exports.prependFile = prependFile;

scripts/build/projects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ProjectQueue {
3535
}
3636
}
3737

38-
const execTsc = (lkg, ...args) =>
38+
const execTsc = (/** @type {boolean} */ lkg, /** @type {string[]} */ ...args) =>
3939
exec(process.execPath,
4040
[resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"),
4141
"-b", ...args],
@@ -45,7 +45,7 @@ const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, .
4545

4646
/**
4747
* @param {string} project
48-
* @param {object} [options]
48+
* @param {object} options
4949
* @param {boolean} [options.lkg=true]
5050
* @param {boolean} [options.force=false]
5151
*/
@@ -58,11 +58,11 @@ const projectCleaner = new ProjectQueue((projects, lkg) => execTsc(lkg, "--clean
5858
*/
5959
exports.cleanProject = (project) => projectCleaner.enqueue(project);
6060

61-
const projectWatcher = new ProjectQueue((projects) => execTsc(true, "--watch", ...projects));
61+
const projectWatcher = new ProjectQueue((projects) => execTsc(/*lkg*/ true, "--watch", ...projects));
6262

6363
/**
6464
* @param {string} project
65-
* @param {object} [options]
65+
* @param {object} options
6666
* @param {boolean} [options.lkg=true]
6767
*/
6868
exports.watchProject = (project, { lkg } = {}) => projectWatcher.enqueue(project, { lkg });

scripts/build/sourcemaps.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ function base64VLQFormatEncode(value) {
4545

4646
return result;
4747
}
48-
exports.base64VLQFormatEncode = base64VLQFormatEncode;
48+
exports.base64VLQFormatEncode = base64VLQFormatEncode;
49+
50+
/** @typedef {object} RawSourceMap */

0 commit comments

Comments
 (0)