Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 491ebca

Browse filesBrowse files
armano2mysticatea
authored andcommitted
Fix: crash in no-unused-vars when using enum (eslint#556)
1 parent ae7c4e6 commit 491ebca
Copy full SHA for 491ebca

File tree

Expand file treeCollapse file tree

3 files changed

+174
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+174
-1
lines changed
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enum Foo {
2+
BAR = 'bar'
3+
}

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

Copy file name to clipboardExpand all lines: tests/lib/__snapshots__/scope-analysis.js.snap
+170Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,176 @@ Object {
27032703
}
27042704
`;
27052705

2706+
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/enum-string.ts 1`] = `
2707+
Object {
2708+
"$id": 4,
2709+
"block": Object {
2710+
"range": Array [
2711+
0,
2712+
29,
2713+
],
2714+
"type": "Program",
2715+
},
2716+
"childScopes": Array [
2717+
Object {
2718+
"$id": 3,
2719+
"block": Object {
2720+
"range": Array [
2721+
0,
2722+
28,
2723+
],
2724+
"type": "TSEnumDeclaration",
2725+
},
2726+
"childScopes": Array [],
2727+
"functionExpressionScope": false,
2728+
"isStrict": false,
2729+
"references": Array [
2730+
Object {
2731+
"$id": 2,
2732+
"from": Object {
2733+
"$ref": 3,
2734+
},
2735+
"identifier": Object {
2736+
"name": "BAR",
2737+
"range": Array [
2738+
15,
2739+
18,
2740+
],
2741+
"type": "Identifier",
2742+
},
2743+
"kind": "w",
2744+
"resolved": Object {
2745+
"$ref": 1,
2746+
},
2747+
"writeExpr": Object {
2748+
"range": Array [
2749+
21,
2750+
26,
2751+
],
2752+
"type": "Literal",
2753+
},
2754+
},
2755+
],
2756+
"throughReferences": Array [],
2757+
"type": "enum",
2758+
"upperScope": Object {
2759+
"$ref": 4,
2760+
},
2761+
"variableMap": Object {
2762+
"BAR": Object {
2763+
"$ref": 1,
2764+
},
2765+
},
2766+
"variableScope": Object {
2767+
"$ref": 4,
2768+
},
2769+
"variables": Array [
2770+
Object {
2771+
"$id": 1,
2772+
"defs": Array [
2773+
Object {
2774+
"name": Object {
2775+
"name": "BAR",
2776+
"range": Array [
2777+
15,
2778+
18,
2779+
],
2780+
"type": "Identifier",
2781+
},
2782+
"node": Object {
2783+
"range": Array [
2784+
15,
2785+
26,
2786+
],
2787+
"type": "TSEnumMember",
2788+
},
2789+
"parent": undefined,
2790+
"type": "EnumMemberName",
2791+
},
2792+
],
2793+
"eslintUsed": undefined,
2794+
"identifiers": Array [
2795+
Object {
2796+
"name": "BAR",
2797+
"range": Array [
2798+
15,
2799+
18,
2800+
],
2801+
"type": "Identifier",
2802+
},
2803+
],
2804+
"name": "BAR",
2805+
"references": Array [
2806+
Object {
2807+
"$ref": 2,
2808+
},
2809+
],
2810+
"scope": Object {
2811+
"$ref": 3,
2812+
},
2813+
},
2814+
],
2815+
},
2816+
],
2817+
"functionExpressionScope": false,
2818+
"isStrict": false,
2819+
"references": Array [],
2820+
"throughReferences": Array [],
2821+
"type": "global",
2822+
"upperScope": null,
2823+
"variableMap": Object {
2824+
"Foo": Object {
2825+
"$ref": 0,
2826+
},
2827+
},
2828+
"variableScope": Object {
2829+
"$ref": 4,
2830+
},
2831+
"variables": Array [
2832+
Object {
2833+
"$id": 0,
2834+
"defs": Array [
2835+
Object {
2836+
"name": Object {
2837+
"name": "Foo",
2838+
"range": Array [
2839+
5,
2840+
8,
2841+
],
2842+
"type": "Identifier",
2843+
},
2844+
"node": Object {
2845+
"range": Array [
2846+
0,
2847+
28,
2848+
],
2849+
"type": "TSEnumDeclaration",
2850+
},
2851+
"parent": undefined,
2852+
"type": "EnumName",
2853+
},
2854+
],
2855+
"eslintUsed": undefined,
2856+
"identifiers": Array [
2857+
Object {
2858+
"name": "Foo",
2859+
"range": Array [
2860+
5,
2861+
8,
2862+
],
2863+
"type": "Identifier",
2864+
},
2865+
],
2866+
"name": "Foo",
2867+
"references": Array [],
2868+
"scope": Object {
2869+
"$ref": 4,
2870+
},
2871+
},
2872+
],
2873+
}
2874+
`;
2875+
27062876
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/function-overload.ts 1`] = `
27072877
Object {
27082878
"$id": 4,

‎visitor-keys.js

Copy file name to clipboardExpand all lines: visitor-keys.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = Evk.unionWith({
3939
TSEmptyBodyFunctionDeclaration: ["id", "typeParameters", "params", "returnType"],
4040
TSEmptyBodyFunctionExpression: ["id", "typeParameters", "params", "returnType"],
4141
TSEnumDeclaration: ["members"],
42-
TSEnumMember: ["initializer"],
42+
TSEnumMember: ["id", "initializer"],
4343
TSExportAssignment: ["expression"],
4444
TSExportKeyword: [],
4545
TSImportType: ["parameter", "qualifier", "typeParameters"],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.