Skip to content

Commit

Permalink
Update typescript-eslint to v5.52 (#14358)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Feb 19, 2023
1 parent 4fb03a7 commit 0d6c8f6
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 61 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@iarna/toml": "2.2.5",
"@prettier/is-es5-identifier-name": "0.1.0",
"@prettier/parse-srcset": "2.0.2",
"@typescript-eslint/typescript-estree": "5.51.0",
"@typescript-eslint/visitor-keys": "5.51.0",
"@typescript-eslint/typescript-estree": "5.52.0",
"@typescript-eslint/visitor-keys": "5.52.0",
"acorn": "8.8.2",
"acorn-jsx": "5.3.2",
"angular-estree-parser": "6.0.0",
Expand Down Expand Up @@ -111,7 +111,7 @@
"@types/file-entry-cache": "5.0.2",
"@types/find-cache-dir": "3.2.1",
"@types/jest": "29.4.0",
"@typescript-eslint/eslint-plugin": "5.51.0",
"@typescript-eslint/eslint-plugin": "5.52.0",
"benchmark": "2.1.4",
"browserslist-to-esbuild": "1.2.0",
"c8": "7.12.0",
Expand Down
12 changes: 12 additions & 0 deletions scripts/build/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ const pluginFiles = [
),
text: "exports.inferSingleRun = () => false;",
},
{
module: require.resolve(
"@typescript-eslint/typescript-estree/dist/parseSettings/ExpiringCache.js"
),
text: "exports.ExpiringCache = class {};",
},
{
module: require.resolve(
"@typescript-eslint/typescript-estree/dist/parseSettings/getProjectConfigFiles.js"
),
text: "exports.resolveProjectList = () => [];",
},
{
module: require.resolve(
"@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js"
Expand Down
27 changes: 17 additions & 10 deletions src/language-js/print/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ function printTypescript(path, options, print) {
return ["require(", print("expression"), ")"];
case "TSModuleDeclaration": {
const { parent } = path;
const isExternalModule = isStringLiteral(node.id);
const parentIsDeclaration = parent.type === "TSModuleDeclaration";
const bodyIsDeclaration = node.body?.type === "TSModuleDeclaration";

Expand All @@ -352,15 +351,23 @@ function printTypescript(path, options, print) {

// Global declaration looks like this:
// (declare)? global { ... }
if (!node.global) {
parts.push(
isExternalModule ||
/(?:^|\s)module(?:\s|$)/.test(
options.originalText.slice(locStart(node), locStart(node.id))
)
? "module "
: "namespace "
);
const isGlobal =
node.kind === "global" ||
// TODO: Use `node.kind` when babel update AST
// https://github.com/typescript-eslint/typescript-eslint/pull/6443
node.global;

if (!isGlobal) {
const kind =
node.kind ??
// TODO: Use `node.kind` when babel update AST
(isStringLiteral(node.id) ||
/(?:^|\s)module(?:\s|$)/.test(
options.originalText.slice(locStart(node), locStart(node.id))
)
? "module"
: "namespace");
parts.push(kind, " ");
}
}

Expand Down
10 changes: 6 additions & 4 deletions tests/config/format-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ const meriyahDisabledTests = new Set([
].map((file) => path.join(__dirname, "../format", file)),
]);
const babelTsDisabledTest = new Set(
[].map((directory) => path.join(__dirname, "../format/typescript", directory))
["conformance/types/moduleDeclaration/kind-detection.ts"].map((file) =>
path.join(__dirname, "../format/typescript", file)
)
);

const isUnstable = (filename, options) => {
Expand Down Expand Up @@ -236,8 +238,7 @@ function runSpec(fixtures, parsers, options) {
if (
parsers.includes("typescript") &&
!parsers.includes("babel-ts") &&
!IS_TYPESCRIPT_ONLY_TEST &&
!babelTsDisabledTest.has(dirname)
!IS_TYPESCRIPT_ONLY_TEST
) {
allParsers.push("babel-ts");
}
Expand Down Expand Up @@ -285,7 +286,8 @@ function runSpec(fixtures, parsers, options) {
if (
(currentParser === "espree" && espreeDisabledTests.has(filename)) ||
(currentParser === "meriyah" && meriyahDisabledTests.has(filename)) ||
(currentParser === "acorn" && acornDisabledTests.has(filename))
(currentParser === "acorn" && acornDisabledTests.has(filename)) ||
(currentParser === "babel-ts" && babelTsDisabledTest.has(filename))
) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet: #0 [babel-ts] format 1`] = `
"Missing semicolon. (1:10)
> 1 | namespace "a" {}
| ^"
`;

exports[`snippet: #0 [typescript] format 1`] = `
"Identifier expected. (1:11)
> 1 | namespace "a" {}
| ^"
`;

exports[`snippet: #1 [babel-ts] format 1`] = `
"Missing semicolon. (1:10)
> 1 | namespace "a";
| ^"
`;

exports[`snippet: #1 [typescript] format 1`] = `
"Identifier expected. (1:11)
> 1 | namespace "a";
| ^"
`;

exports[`snippet: #2 [babel-ts] format 1`] = `
"Unexpected token, expected "{" (1:12)
> 1 | namespace a;
| ^"
`;
exports[`snippet: #2 [typescript] format 1`] = `
"'{' expected. (1:12)
> 1 | namespace a;
| ^"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
run_spec(
{
importMeta: import.meta,
snippets: ['namespace "a" {}', 'namespace "a";', "namespace a;"],
},
["babel-ts", "typescript"]
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`kind-detection.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
declare /* module */ namespace A {}
=====================================output=====================================
declare namespace /* module */ A {}
================================================================================
`;

exports[`moduleDeclaration.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare /* module */ namespace A {}
88 changes: 44 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1750,13 +1750,13 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.51.0"
"@typescript-eslint/eslint-plugin@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.52.0"
dependencies:
"@typescript-eslint/scope-manager": 5.51.0
"@typescript-eslint/type-utils": 5.51.0
"@typescript-eslint/utils": 5.51.0
"@typescript-eslint/scope-manager": 5.52.0
"@typescript-eslint/type-utils": 5.52.0
"@typescript-eslint/utils": 5.52.0
debug: ^4.3.4
grapheme-splitter: ^1.0.4
ignore: ^5.2.0
Expand All @@ -1770,50 +1770,50 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 5351d8cec13bd9867ce4aaf7052aa31c9ca867fc89c620fc0fe5718ac2cbc165903275db59974324d98e45df0d33a73a4367d236668772912731031a672cfdcd
checksum: cff07ee94d8ab2a1b6c33b5c5bf641eff2bf2bebc0f35a9d8b3f128fd610e27a4aaf620bc2ad23608ad161b1810b7e32e5a2e0f746cc5094c3f506f7a14daa34
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/scope-manager@npm:5.51.0"
"@typescript-eslint/scope-manager@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/scope-manager@npm:5.52.0"
dependencies:
"@typescript-eslint/types": 5.51.0
"@typescript-eslint/visitor-keys": 5.51.0
checksum: b3c9f48b6b7a7ae2ebcad4745ef91e4727776b2cf56d31be6456b1aa063aa649539e20f9fffa83cad9ccaaa9c492f2354a1c15526a2b789e235ec58b3a82d22c
"@typescript-eslint/types": 5.52.0
"@typescript-eslint/visitor-keys": 5.52.0
checksum: 9a03fe30f8e90a5106c482478f213eefdd09f2f74e24d9dc59b453885466a758fe6d1cd24d706aed6188fb03c84b16ca6491cf20da6b16b8fc53cad8b8c327f2
languageName: node
linkType: hard

"@typescript-eslint/type-utils@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/type-utils@npm:5.51.0"
"@typescript-eslint/type-utils@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/type-utils@npm:5.52.0"
dependencies:
"@typescript-eslint/typescript-estree": 5.51.0
"@typescript-eslint/utils": 5.51.0
"@typescript-eslint/typescript-estree": 5.52.0
"@typescript-eslint/utils": 5.52.0
debug: ^4.3.4
tsutils: ^3.21.0
peerDependencies:
eslint: "*"
peerDependenciesMeta:
typescript:
optional: true
checksum: ab9747b0c629cfaaab903eed8ce1e39d34d69a402ce5faf2f1fff2bbb461bdbe034044b1368ba67ba8e5c1c512172e07d83c8a563635d8de811bf148d95c7dec
checksum: ac5422040461febab8a2eeec76d969024ccff76203dec357f7220c9b5e0dde96e3e3a76fd4118d42b50bd5bfb3a194aaceeb63417a2ac4e1ebf5e687558a9a10
languageName: node
linkType: hard

"@typescript-eslint/types@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/types@npm:5.51.0"
checksum: b31021a0866f41ba5d71b6c4c7e20cc9b99d49c93bb7db63b55b2e51542fb75b4e27662ee86350da3c1318029e278a5a807facaf4cb5aeea724be8b0e021e836
"@typescript-eslint/types@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/types@npm:5.52.0"
checksum: 018940d61aebf7cf3f7de1b9957446e2ea01f08fe950bef4788c716a3a88f7c42765fe7d80152b0d0428fcd4bd3ace2dfa8c459ba1c59d9a84e951642180f869
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/typescript-estree@npm:5.51.0"
"@typescript-eslint/typescript-estree@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/typescript-estree@npm:5.52.0"
dependencies:
"@typescript-eslint/types": 5.51.0
"@typescript-eslint/visitor-keys": 5.51.0
"@typescript-eslint/types": 5.52.0
"@typescript-eslint/visitor-keys": 5.52.0
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
Expand All @@ -1822,35 +1822,35 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: aec23e5cab48ee72fefa6d1ac266639ebabf6cebec1e0207ad47011d3a48186ac9a632c8e34c3bac896155f54895a497230c11d789fd81263b08eb267d7113ce
checksum: 67d396907fee3d6894e26411a5098a37f07e5d50343189e6361ff7db91c74a7ffe2abd630d11f14c2bda1f4af13edf52b80b11cbccb55b44079c7cec14c9e108
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:5.51.0, @typescript-eslint/utils@npm:^5.10.0":
version: 5.51.0
resolution: "@typescript-eslint/utils@npm:5.51.0"
"@typescript-eslint/utils@npm:5.52.0, @typescript-eslint/utils@npm:^5.10.0":
version: 5.52.0
resolution: "@typescript-eslint/utils@npm:5.52.0"
dependencies:
"@types/json-schema": ^7.0.9
"@types/semver": ^7.3.12
"@typescript-eslint/scope-manager": 5.51.0
"@typescript-eslint/types": 5.51.0
"@typescript-eslint/typescript-estree": 5.51.0
"@typescript-eslint/scope-manager": 5.52.0
"@typescript-eslint/types": 5.52.0
"@typescript-eslint/typescript-estree": 5.52.0
eslint-scope: ^5.1.1
eslint-utils: ^3.0.0
semver: ^7.3.7
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
checksum: c6e28c942fbac5500f0e8ed67ef304b484ba296486e55306f78fb090dc9d5bb1f25a0bedc065e14680041eadce5e95fa10aab618cb0c316599ec987e6ea72442
checksum: 01906be5262ece36537e9d586e4d2d4791e05752a9354bcb42b1f5bf965f53daa13309c61c3dff5e201ea28c298e4e01cf0c93738afa0099fea0da3b1d8cb3a5
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:5.51.0":
version: 5.51.0
resolution: "@typescript-eslint/visitor-keys@npm:5.51.0"
"@typescript-eslint/visitor-keys@npm:5.52.0":
version: 5.52.0
resolution: "@typescript-eslint/visitor-keys@npm:5.52.0"
dependencies:
"@typescript-eslint/types": 5.51.0
"@typescript-eslint/types": 5.52.0
eslint-visitor-keys: ^3.3.0
checksum: b49710f3c6b3b62a846a163afffd81be5eb2b1f44e25bec51ff3c9f4c3b579d74aa4cbd3753b4fc09ea3dbc64a7062f9c658c08d22bb2740a599cb703d876220
checksum: 33b44f0cd35b7b47f34e89d52e47b8d8200f55af306b22db4de104d79f65907458ea022e548f50d966e32fea150432ac9c1ae65b3001b0ad2ac8a17c0211f370
languageName: node
linkType: hard

Expand Down Expand Up @@ -6716,9 +6716,9 @@ __metadata:
"@types/file-entry-cache": 5.0.2
"@types/find-cache-dir": 3.2.1
"@types/jest": 29.4.0
"@typescript-eslint/eslint-plugin": 5.51.0
"@typescript-eslint/typescript-estree": 5.51.0
"@typescript-eslint/visitor-keys": 5.51.0
"@typescript-eslint/eslint-plugin": 5.52.0
"@typescript-eslint/typescript-estree": 5.52.0
"@typescript-eslint/visitor-keys": 5.52.0
acorn: 8.8.2
acorn-jsx: 5.3.2
angular-estree-parser: 6.0.0
Expand Down

0 comments on commit 0d6c8f6

Please sign in to comment.