Skip to content

Commit

Permalink
Update to eslint v9, typescript-eslint v8 (#59518)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Aug 13, 2024
1 parent 7049af5 commit 01a874a
Show file tree
Hide file tree
Showing 18 changed files with 687 additions and 805 deletions.
18 changes: 5 additions & 13 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,15 @@ export default tseslint.config(
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": [
"error",
{
extendDefaults: true,
types: {
// This is theoretically good, but ts-eslint appears to mistake our declaration of Symbol for the global Symbol type.
// See: https://github.com/typescript-eslint/typescript-eslint/issues/7306
"Symbol": false,
"{}": false, // {} is a totally useful and valid type.
},
},
],
"@typescript-eslint/no-empty-object-type": "off", // {} is a totally useful and valid type.
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
// Ignore: (solely underscores | starting with exactly one underscore)
argsIgnorePattern: "^(_+$|_[^_])",
varsIgnorePattern: "^(_+$|_[^_])",
// Not setting an ignore pattern for caught errors; those can always be safely removed.
},
],
"@typescript-eslint/no-inferrable-types": "off",
Expand Down Expand Up @@ -239,7 +230,8 @@ export default tseslint.config(
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/unified-signatures": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/no-wrapper-object-types": "off",
"@typescript-eslint/no-unused-vars": "off",

// scripts/eslint/rules
Expand Down
1,374 changes: 627 additions & 747 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@dprint/formatter": "^0.4.1",
"@dprint/typescript": "0.91.6",
"@esfx/canceltoken": "^1.0.0",
"@eslint/js": "^8.57.0",
"@eslint/js": "^9.9.0",
"@octokit/rest": "^21.0.1",
"@types/chai": "^4.3.17",
"@types/diff": "^5.2.1",
Expand All @@ -52,34 +52,35 @@
"@types/node": "latest",
"@types/source-map-support": "^0.5.10",
"@types/which": "^3.0.4",
"@typescript-eslint/utils": "^7.18.0",
"azure-devops-node-api": "^14.0.1",
"@typescript-eslint/rule-tester": "^8.1.0",
"@typescript-eslint/utils": "^8.1.0",
"azure-devops-node-api": "^14.0.2",
"c8": "^10.1.2",
"chai": "^4.5.0",
"chalk": "^4.1.2",
"chokidar": "^3.6.0",
"diff": "^5.2.0",
"dprint": "^0.47.2",
"esbuild": "^0.23.0",
"eslint": "^8.57.0",
"eslint-formatter-autolinkable-stylish": "^1.3.0",
"eslint": "^9.9.0",
"eslint-formatter-autolinkable-stylish": "^1.4.0",
"fast-xml-parser": "^4.4.1",
"glob": "^10.4.5",
"globals": "^15.9.0",
"hereby": "^1.9.0",
"jsonc-parser": "^3.3.1",
"knip": "^5.27.0",
"knip": "^5.27.2",
"minimist": "^1.2.8",
"mocha": "^10.7.0",
"mocha": "^10.7.3",
"mocha-fivemat-progress-reporter": "^0.1.0",
"monocart-coverage-reports": "^2.10.0",
"monocart-coverage-reports": "^2.10.2",
"ms": "^2.1.3",
"node-fetch": "^3.3.2",
"playwright": "^1.45.3",
"playwright": "^1.46.0",
"source-map-support": "^0.5.21",
"tslib": "^2.6.3",
"typescript": "^5.5.4",
"typescript-eslint": "^7.18.0",
"typescript-eslint": "^8.1.0",
"which": "^3.0.1"
},
"overrides": {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/argument-trivia.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/argument-trivia.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("argument-trivia", rule, {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/debug-assert.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/debug-assert.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("debug-assert", rule, {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/js-extensions.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/js-extensions.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("js-extensions", rule, {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/no-in-operator.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/no-in-operator.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("no-in-operator", rule, {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/no-keywords.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/no-keywords.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("no-keywords", rule, {
Expand Down
7 changes: 4 additions & 3 deletions scripts/eslint/tests/only-arrow-functions.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
const rule = require("../rules/only-arrow-functions.cjs");

const ruleTester = new RuleTester({
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
parser: require.resolve("@typescript-eslint/parser"),
});

ruleTester.run("only-arrow-functions", rule, {
Expand Down
7 changes: 5 additions & 2 deletions scripts/eslint/tests/support/RuleTester.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require("path");
const { TSESLint } = require("@typescript-eslint/utils");
const Mocha = require("mocha");
const { RuleTester } = require("@typescript-eslint/rule-tester");

RuleTester.afterAll = Mocha.after;

module.exports.ROOT_DIR = path.join(process.cwd(), "scripts", "eslint", "tests", "fixtures");
module.exports.FILENAME = path.join(module.exports.ROOT_DIR, "file.ts");
module.exports.RuleTester = TSESLint.RuleTester;
module.exports.RuleTester = RuleTester;
2 changes: 1 addition & 1 deletion scripts/failed-tests.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
try {
reporter = require(reporterOptions.reporter);
}
catch (_) {
catch {
reporter = require(path.resolve(process.cwd(), reporterOptions.reporter));
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/find-unused-diganostic-messages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ startOfDiags.split(EOL).forEach(line => {
execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
process.stdout.write(".");
}
catch (error) {
catch {
missingNames.push(diagName);
process.stdout.write("x");
}
Expand Down
14 changes: 7 additions & 7 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ export let sys: System = (() => {
try {
buffer = _fs.readFileSync(fileName);
}
catch (e) {
catch {
return undefined;
}
let len = buffer.length;
Expand Down Expand Up @@ -1863,7 +1863,7 @@ export let sys: System = (() => {
continue;
}
}
catch (e) {
catch {
continue;
}
}
Expand All @@ -1882,7 +1882,7 @@ export let sys: System = (() => {
directories.sort();
return { files, directories };
}
catch (e) {
catch {
return emptyFileSystemEntries;
}
}
Expand Down Expand Up @@ -1911,7 +1911,7 @@ export let sys: System = (() => {
return false;
}
}
catch (e) {
catch {
return false;
}
finally {
Expand Down Expand Up @@ -1952,7 +1952,7 @@ export let sys: System = (() => {
try {
return statSync(path)?.mtime;
}
catch (e) {
catch {
return undefined;
}
finally {
Expand All @@ -1964,7 +1964,7 @@ export let sys: System = (() => {
try {
_fs.utimesSync(path, time, time);
}
catch (e) {
catch {
return;
}
}
Expand All @@ -1973,7 +1973,7 @@ export let sys: System = (() => {
try {
return _fs.unlinkSync(path);
}
catch (e) {
catch {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ export function validateLocaleAndSetLanguage(
try {
fileContents = sys.readFile(filePath);
}
catch (e) {
catch {
if (errors) {
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/watchUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
try {
return createCachedFileSystemEntries(rootDir, rootDirPath);
}
catch (_e) {
catch {
// If there is exception to read directories, dont cache the result and direct the calls to host
Debug.assert(!cachedReadDirectoryResult.has(ensureTrailingDirectorySeparator(rootDirPath)));
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/harness/harnessUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function readTestFile(path: string) {
try {
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
}
catch (err) {
catch {
return undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tsserver/nodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function initializeNodeSystem(): StartInput {
try {
this.fd = fs.openSync(this.logFilename, "w");
}
catch (_) {
catch {
// swallow the error and keep logging disabled if file cannot be opened
}
}
Expand Down Expand Up @@ -280,7 +280,7 @@ export function initializeNodeSystem(): StartInput {
const factory = require("./cancellationToken.js");
cancellationToken = factory(sys.args);
}
catch (e) {
catch {
cancellationToken = ts.server.nullCancellationToken;
}

Expand Down
2 changes: 1 addition & 1 deletion src/typingsInstaller/nodeTypingsInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FileLog implements ts.server.typingsInstaller.Log {
try {
fs.appendFileSync(this.logFile, `[${ts.server.nowString()}] ${text}${sys.newLine}`);
}
catch (e) {
catch {
this.logFile = undefined;
}
};
Expand Down

0 comments on commit 01a874a

Please sign in to comment.