Update to eslint v9, typescript-eslint v8 (#59518)

This commit is contained in:
Jake Bailey 2024-08-12 17:13:24 -07:00 коммит произвёл GitHub
Родитель 7049af5f4f
Коммит 01a874a8ba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
18 изменённых файлов: 684 добавлений и 802 удалений

Просмотреть файл

@ -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",
@ -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

1368
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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",
@ -52,8 +52,9 @@
"@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",
@ -61,25 +62,25 @@
"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": {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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));
}
}

Просмотреть файл

@ -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");
}

Просмотреть файл

@ -1792,7 +1792,7 @@ export let sys: System = (() => {
try {
buffer = _fs.readFileSync(fileName);
}
catch (e) {
catch {
return undefined;
}
let len = buffer.length;
@ -1863,7 +1863,7 @@ export let sys: System = (() => {
continue;
}
}
catch (e) {
catch {
continue;
}
}
@ -1882,7 +1882,7 @@ export let sys: System = (() => {
directories.sort();
return { files, directories };
}
catch (e) {
catch {
return emptyFileSystemEntries;
}
}
@ -1911,7 +1911,7 @@ export let sys: System = (() => {
return false;
}
}
catch (e) {
catch {
return false;
}
finally {
@ -1952,7 +1952,7 @@ export let sys: System = (() => {
try {
return statSync(path)?.mtime;
}
catch (e) {
catch {
return undefined;
}
finally {
@ -1964,7 +1964,7 @@ export let sys: System = (() => {
try {
_fs.utimesSync(path, time, time);
}
catch (e) {
catch {
return;
}
}
@ -1973,7 +1973,7 @@ export let sys: System = (() => {
try {
return _fs.unlinkSync(path);
}
catch (e) {
catch {
return;
}
}

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -41,7 +41,7 @@ export function readTestFile(path: string) {
try {
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
}
catch (err) {
catch {
return undefined;
}

Просмотреть файл

@ -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
}
}
@ -280,7 +280,7 @@ export function initializeNodeSystem(): StartInput {
const factory = require("./cancellationToken.js");
cancellationToken = factory(sys.args);
}
catch (e) {
catch {
cancellationToken = ts.server.nullCancellationToken;
}

Просмотреть файл

@ -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;
}
};