Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 6aad31d

Browse files
committed
Upgrade: typescript-estree to 7.0.0
1 parent d772b0a commit 6aad31d

File tree

10 files changed

+1498
-1760
lines changed

10 files changed

+1498
-1760
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ _test.js
77
.vscode
88
yarn.lock
99
.eslint-release-info.json
10+
.idea

analyze-scope.js

+7-19
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,6 @@ class Referencer extends OriginalReferencer {
239239
super.MethodDefinition(node);
240240
}
241241

242-
/**
243-
* Override.
244-
* Don't make variable if `kind === "type"`.
245-
* It doesn't declare variables but declare types.
246-
* @param {VariableDeclaration} node The VariableDeclaration node to visit.
247-
* @returns {void}
248-
*/
249-
VariableDeclaration(node) {
250-
if (node.kind !== "type") {
251-
super.VariableDeclaration(node);
252-
return;
253-
}
254-
255-
// To detect typeof.
256-
this.typeMode = true;
257-
this.visitChildren(node);
258-
this.typeMode = false;
259-
}
260-
261242
/**
262243
* Don't create the reference object for the key if not computed.
263244
* @param {TSEmptyBodyFunctionDeclaration} node The TSEmptyBodyFunctionDeclaration node to visit.
@@ -337,6 +318,7 @@ class Referencer extends OriginalReferencer {
337318
this.visit(returnType);
338319
this.typeMode = upperTypeMode;
339320
}
321+
340322
TSEmptyBodyDeclareFunction(node) {
341323
this.TSEmptyBodyFunctionDeclaration(node);
342324
}
@@ -556,6 +538,12 @@ class Referencer extends OriginalReferencer {
556538
this.visit(body);
557539
}
558540

541+
TSTypeAliasDeclaration(node) {
542+
this.typeMode = true;
543+
this.visitChildren(node);
544+
this.typeMode = false;
545+
}
546+
559547
/**
560548
* Process the module block.
561549
* @param {TSModuleBlock} node The TSModuleBlock node to visit.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dependencies": {
4747
"eslint-scope": "^4.0.0",
4848
"eslint-visitor-keys": "^1.0.0",
49-
"typescript-estree": "^6.0.0"
49+
"typescript-estree": "^7.0.0"
5050
},
5151
"devDependencies": {
5252
"eslint": "^4.19.1",

parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ exports.parseForESLint = function parseForESLint(code, options) {
4242
enter: node => {
4343
switch (node.type) {
4444
// Just for backward compatibility.
45-
case "DeclareFunction":
45+
case "TSDeclareFunction":
4646
if (!node.body) {
47-
node.type = `TSEmptyBody${node.type}`;
47+
node.type = "TSEmptyBodyDeclareFunction";
4848
}
4949
break;
5050

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type foo = string

tests/lib/__snapshots__/ecma-features.js.snap

-2
Original file line numberDiff line numberDiff line change
@@ -102029,7 +102029,6 @@ Object {
102029102029
"body": Array [
102030102030
Object {
102031102031
"async": false,
102032-
"body": null,
102033102032
"expression": false,
102034102033
"generator": false,
102035102034
"id": Object {
@@ -102347,7 +102346,6 @@ Object {
102347102346
"body": Array [
102348102347
Object {
102349102348
"async": false,
102350-
"body": null,
102351102349
"expression": false,
102352102350
"generator": false,
102353102351
"id": Object {

tests/lib/__snapshots__/scope-analysis.js.snap

+25
Original file line numberDiff line numberDiff line change
@@ -5298,6 +5298,31 @@ Object {
52985298
}
52995299
`;
53005300

5301+
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-alias.ts 1`] = `
5302+
Object {
5303+
"$id": 0,
5304+
"block": Object {
5305+
"range": Array [
5306+
0,
5307+
19,
5308+
],
5309+
"type": "Program",
5310+
},
5311+
"childScopes": Array [],
5312+
"functionExpressionScope": false,
5313+
"isStrict": false,
5314+
"references": Array [],
5315+
"throughReferences": Array [],
5316+
"type": "global",
5317+
"upperScope": null,
5318+
"variableMap": Object {},
5319+
"variableScope": Object {
5320+
"$ref": 0,
5321+
},
5322+
"variables": Array [],
5323+
}
5324+
`;
5325+
53015326
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-annotations.ts 1`] = `
53025327
Object {
53035328
"$id": 7,

tests/lib/__snapshots__/tsx.js.snap

+97-117
Original file line numberDiff line numberDiff line change
@@ -500,148 +500,128 @@ Object {
500500
"type": "ImportDeclaration",
501501
},
502502
Object {
503-
"declarations": Array [
504-
Object {
505-
"id": Object {
506-
"loc": Object {
507-
"end": Object {
508-
"column": 10,
509-
"line": 2,
510-
},
511-
"start": Object {
512-
"column": 5,
513-
"line": 2,
503+
"id": Object {
504+
"loc": Object {
505+
"end": Object {
506+
"column": 10,
507+
"line": 2,
508+
},
509+
"start": Object {
510+
"column": 5,
511+
"line": 2,
512+
},
513+
},
514+
"name": "Props",
515+
"range": Array [
516+
36,
517+
41,
518+
],
519+
"type": "Identifier",
520+
},
521+
"loc": Object {
522+
"end": Object {
523+
"column": 1,
524+
"line": 4,
525+
},
526+
"start": Object {
527+
"column": 0,
528+
"line": 2,
529+
},
530+
},
531+
"range": Array [
532+
31,
533+
63,
534+
],
535+
"type": "TSTypeAliasDeclaration",
536+
"typeAnnotation": Object {
537+
"loc": Object {
538+
"end": Object {
539+
"column": 1,
540+
"line": 4,
541+
},
542+
"start": Object {
543+
"column": 13,
544+
"line": 2,
545+
},
546+
},
547+
"members": Array [
548+
Object {
549+
"computed": false,
550+
"key": Object {
551+
"loc": Object {
552+
"end": Object {
553+
"column": 7,
554+
"line": 3,
555+
},
556+
"start": Object {
557+
"column": 2,
558+
"line": 3,
559+
},
514560
},
561+
"name": "title",
562+
"range": Array [
563+
48,
564+
53,
565+
],
566+
"type": "Identifier",
515567
},
516-
"name": "Props",
517-
"range": Array [
518-
36,
519-
41,
520-
],
521-
"type": "Identifier",
522-
},
523-
"init": Object {
524568
"loc": Object {
525569
"end": Object {
526-
"column": 1,
527-
"line": 4,
570+
"column": 15,
571+
"line": 3,
528572
},
529573
"start": Object {
530-
"column": 13,
531-
"line": 2,
574+
"column": 2,
575+
"line": 3,
532576
},
533577
},
534-
"members": Array [
535-
Object {
536-
"computed": false,
537-
"key": Object {
538-
"loc": Object {
539-
"end": Object {
540-
"column": 7,
541-
"line": 3,
542-
},
543-
"start": Object {
544-
"column": 2,
545-
"line": 3,
546-
},
547-
},
548-
"name": "title",
549-
"range": Array [
550-
48,
551-
53,
552-
],
553-
"type": "Identifier",
578+
"range": Array [
579+
48,
580+
61,
581+
],
582+
"type": "TSPropertySignature",
583+
"typeAnnotation": Object {
584+
"loc": Object {
585+
"end": Object {
586+
"column": 15,
587+
"line": 3,
554588
},
589+
"start": Object {
590+
"column": 7,
591+
"line": 3,
592+
},
593+
},
594+
"range": Array [
595+
53,
596+
61,
597+
],
598+
"type": "TSTypeAnnotation",
599+
"typeAnnotation": Object {
555600
"loc": Object {
556601
"end": Object {
557602
"column": 15,
558603
"line": 3,
559604
},
560605
"start": Object {
561-
"column": 2,
606+
"column": 9,
562607
"line": 3,
563608
},
564609
},
565610
"range": Array [
566-
48,
611+
55,
567612
61,
568613
],
569-
"type": "TSPropertySignature",
570-
"typeAnnotation": Object {
571-
"loc": Object {
572-
"end": Object {
573-
"column": 15,
574-
"line": 3,
575-
},
576-
"start": Object {
577-
"column": 7,
578-
"line": 3,
579-
},
580-
},
581-
"range": Array [
582-
53,
583-
61,
584-
],
585-
"type": "TSTypeAnnotation",
586-
"typeAnnotation": Object {
587-
"loc": Object {
588-
"end": Object {
589-
"column": 15,
590-
"line": 3,
591-
},
592-
"start": Object {
593-
"column": 9,
594-
"line": 3,
595-
},
596-
},
597-
"range": Array [
598-
55,
599-
61,
600-
],
601-
"type": "TSStringKeyword",
602-
},
603-
},
614+
"type": "TSStringKeyword",
604615
},
605-
],
606-
"range": Array [
607-
44,
608-
63,
609-
],
610-
"type": "TSTypeLiteral",
611-
},
612-
"loc": Object {
613-
"end": Object {
614-
"column": 1,
615-
"line": 4,
616-
},
617-
"start": Object {
618-
"column": 5,
619-
"line": 2,
620616
},
621617
},
622-
"range": Array [
623-
36,
624-
63,
625-
],
626-
"type": "VariableDeclarator",
627-
},
628-
],
629-
"kind": "type",
630-
"loc": Object {
631-
"end": Object {
632-
"column": 1,
633-
"line": 4,
634-
},
635-
"start": Object {
636-
"column": 0,
637-
"line": 2,
638-
},
618+
],
619+
"range": Array [
620+
44,
621+
63,
622+
],
623+
"type": "TSTypeLiteral",
639624
},
640-
"range": Array [
641-
31,
642-
63,
643-
],
644-
"type": "VariableDeclaration",
645625
},
646626
Object {
647627
"declaration": Object {

0 commit comments

Comments
 (0)