Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ee41b9

Browse files
armano2bradzacher
authored andcommitted
feat(typescript-estree): remove legacy useJSXTextNode option (typescript-eslint#3109)
1 parent 8b96290 commit 2ee41b9

31 files changed

+51
-112
lines changed

packages/typescript-estree/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ interface ParseOptions {
101101
* Set to true to create a top-level array containing all tokens from the file.
102102
*/
103103
tokens?: boolean;
104-
105-
/*
106-
* The JSX AST changed the node type for string literals
107-
* inside a JSX Element from `Literal` to `JSXText`.
108-
* When value is `true`, these nodes will be parsed as type `JSXText`.
109-
* When value is `false`, these nodes will be parsed as type `Literal`.
110-
*/
111-
useJSXTextNode?: boolean;
112104
}
113105

114106
const PARSE_DEFAULT_OPTIONS: ParseOptions = {
@@ -120,7 +112,6 @@ const PARSE_DEFAULT_OPTIONS: ParseOptions = {
120112
loggerFn: undefined,
121113
range: false,
122114
tokens: false,
123-
useJSXTextNode: false,
124115
};
125116

126117
declare function parse(

packages/typescript-estree/src/ast-converter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function astConverter(
2525
*/
2626
const instance = new Converter(ast, {
2727
errorOnUnknownASTType: extra.errorOnUnknownASTType || false,
28-
useJSXTextNode: extra.useJSXTextNode || false,
2928
shouldPreserveNodeMaps,
3029
});
3130

packages/typescript-estree/src/convert.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const SyntaxKind = ts.SyntaxKind;
3636

3737
interface ConverterOptions {
3838
errorOnUnknownASTType: boolean;
39-
useJSXTextNode: boolean;
4039
shouldPreserveNodeMaps: boolean;
4140
}
4241

@@ -2250,32 +2249,17 @@ export class Converter {
22502249
});
22512250
}
22522251

2253-
/**
2254-
* The JSX AST changed the node type for string literals
2255-
* inside a JSX Element from `Literal` to `JSXText`. We
2256-
* provide a flag to support both types until `Literal`
2257-
* node type is deprecated in ESLint v5.
2258-
*/
22592252
case SyntaxKind.JsxText: {
22602253
const start = node.getFullStart();
22612254
const end = node.getEnd();
22622255
const text = this.ast.text.slice(start, end);
22632256

2264-
if (this.options.useJSXTextNode) {
2265-
return this.createNode<TSESTree.JSXText>(node, {
2266-
type: AST_NODE_TYPES.JSXText,
2267-
value: unescapeStringLiteralText(text),
2268-
raw: text,
2269-
range: [start, end],
2270-
});
2271-
} else {
2272-
return this.createNode<TSESTree.StringLiteral>(node, {
2273-
type: AST_NODE_TYPES.Literal,
2274-
value: unescapeStringLiteralText(text),
2275-
raw: text,
2276-
range: [start, end],
2277-
});
2278-
}
2257+
return this.createNode<TSESTree.JSXText>(node, {
2258+
type: AST_NODE_TYPES.JSXText,
2259+
value: unescapeStringLiteralText(text),
2260+
raw: text,
2261+
range: [start, end],
2262+
});
22792263
}
22802264

22812265
case SyntaxKind.JsxSpreadAttribute:

packages/typescript-estree/src/parser-options.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export interface Extra {
2727
strict: boolean;
2828
tokens: null | TSESTree.Token[];
2929
tsconfigRootDir: string;
30-
useJSXTextNode: boolean;
3130
moduleResolver: string;
3231
}
3332

@@ -100,14 +99,6 @@ interface ParseOptions {
10099
* Set to true to create a top-level array containing all tokens from the file.
101100
*/
102101
tokens?: boolean;
103-
104-
/*
105-
* The JSX AST changed the node type for string literals
106-
* inside a JSX Element from `Literal` to `JSXText`.
107-
* When value is `true`, these nodes will be parsed as type `JSXText`.
108-
* When value is `false`, these nodes will be parsed as type `Literal`.
109-
*/
110-
useJSXTextNode?: boolean;
111102
}
112103

113104
interface ParseAndGenerateServicesOptions extends ParseOptions {

packages/typescript-estree/src/parser.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ function resetExtra(): void {
129129
strict: false,
130130
tokens: null,
131131
tsconfigRootDir: process.cwd(),
132-
useJSXTextNode: false,
133132
/**
134133
* Unless we can reliably infer otherwise, we default to assuming that this run could be part
135134
* of a long-running session (e.g. in an IDE) and watch programs will therefore be required
@@ -251,17 +250,6 @@ function applyParserOptionsToExtra(options: TSESTreeOptions): void {
251250
extra.filePath = getFileName(extra);
252251
}
253252

254-
/**
255-
* The JSX AST changed the node type for string literals
256-
* inside a JSX Element from `Literal` to `JSXText`.
257-
*
258-
* When value is `true`, these nodes will be parsed as type `JSXText`.
259-
* When value is `false`, these nodes will be parsed as type `Literal`.
260-
*/
261-
if (typeof options.useJSXTextNode === 'boolean' && options.useJSXTextNode) {
262-
extra.useJSXTextNode = true;
263-
}
264-
265253
/**
266254
* Allow the user to cause the parser to error if it encounters an unknown AST Node Type
267255
* (used in testing)

packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export interface EstreeToTsNodeTypes {
100100
| ts.StringLiteral
101101
| ts.NumericLiteral
102102
| ts.RegularExpressionLiteral
103-
| ts.JsxText
104103
| ts.NullLiteral
105104
| ts.BooleanLiteral
106105
| ts.BigIntLiteral;

packages/typescript-estree/tests/ast-alignment/parse.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ function parseWithTypeScriptESTree(text: string, jsx = true): parser.AST<any> {
5050
range: true,
5151
tokens: false,
5252
comment: false,
53-
useJSXTextNode: true,
5453
errorOnUnknownASTType: true,
5554
/**
5655
* Babel will always throw on these types of issues, so we enable

packages/typescript-estree/tests/lib/convert.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('convert', () => {
2727

2828
const instance = new Converter(ast, {
2929
errorOnUnknownASTType: false,
30-
useJSXTextNode: false,
3130
shouldPreserveNodeMaps: false,
3231
});
3332
expect(instance.convertProgram()).toMatchSnapshot();
@@ -38,7 +37,6 @@ describe('convert', () => {
3837

3938
const instance = new Converter(ast, {
4039
errorOnUnknownASTType: false,
41-
useJSXTextNode: false,
4240
shouldPreserveNodeMaps: false,
4341
}) as any;
4442

@@ -50,7 +48,6 @@ describe('convert', () => {
5048

5149
const instance = new Converter(ast, {
5250
errorOnUnknownASTType: false,
53-
useJSXTextNode: false,
5451
shouldPreserveNodeMaps: false,
5552
}) as any;
5653

@@ -62,7 +59,6 @@ describe('convert', () => {
6259

6360
const instance = new Converter(ast, {
6461
errorOnUnknownASTType: false,
65-
useJSXTextNode: false,
6662
shouldPreserveNodeMaps: false,
6763
}) as any;
6864

@@ -76,7 +72,6 @@ describe('convert', () => {
7672

7773
const instance = new Converter(ast, {
7874
errorOnUnknownASTType: false,
79-
useJSXTextNode: false,
8075
shouldPreserveNodeMaps: false,
8176
}) as any;
8277
expect(instance.deeplyCopy(ast)).toMatchSnapshot();
@@ -87,7 +82,6 @@ describe('convert', () => {
8782

8883
const instance = new Converter(ast, {
8984
errorOnUnknownASTType: true,
90-
useJSXTextNode: false,
9185
shouldPreserveNodeMaps: false,
9286
}) as any;
9387

@@ -106,7 +100,6 @@ describe('convert', () => {
106100

107101
const instance = new Converter(ast, {
108102
errorOnUnknownASTType: false,
109-
useJSXTextNode: false,
110103
shouldPreserveNodeMaps: true,
111104
});
112105
instance.convertProgram();
@@ -140,7 +133,6 @@ describe('convert', () => {
140133

141134
const instance = new Converter(ast, {
142135
errorOnUnknownASTType: false,
143-
useJSXTextNode: false,
144136
shouldPreserveNodeMaps: true,
145137
});
146138
instance.convertProgram();
@@ -173,7 +165,6 @@ describe('convert', () => {
173165

174166
const instance = new Converter(ast, {
175167
errorOnUnknownASTType: false,
176-
useJSXTextNode: false,
177168
shouldPreserveNodeMaps: true,
178169
});
179170
const program = instance.convertProgram();
@@ -205,7 +196,6 @@ describe('convert', () => {
205196
const ast = convertCode('');
206197
const instance = new Converter(ast, {
207198
errorOnUnknownASTType: false,
208-
useJSXTextNode: false,
209199
shouldPreserveNodeMaps: true,
210200
});
211201

@@ -250,7 +240,6 @@ describe('convert', () => {
250240

251241
const instance = new Converter(ast, {
252242
errorOnUnknownASTType: false,
253-
useJSXTextNode: false,
254243
shouldPreserveNodeMaps: false,
255244
});
256245
expect(() => instance.convertProgram()).toThrow(

packages/typescript-estree/tests/lib/semanticInfo.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function createOptions(fileName: string): TSESTreeOptions & { cwd?: string } {
2828
tokens: true,
2929
comment: true,
3030
jsx: false,
31-
useJSXTextNode: false,
3231
errorOnUnknownASTType: true,
3332
filePath: fileName,
3433
tsconfigRootDir: path.join(process.cwd(), FIXTURES_DIR),

packages/typescript-estree/tests/snapshots/comments/jsx-attr-and-text-with-url.src.js.shot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Object {
4242
61,
4343
],
4444
"raw": "http://example.com",
45-
"type": "Literal",
45+
"type": "JSXText",
4646
"value": "http://example.com",
4747
},
4848
],

packages/typescript-estree/tests/snapshots/comments/jsx-block-comment.src.js.shot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Object {
4848
],
4949
"raw": "
5050
",
51-
"type": "Literal",
51+
"type": "JSXText",
5252
"value": "
5353
",
5454
},
@@ -103,7 +103,7 @@ Object {
103103
],
104104
"raw": "
105105
",
106-
"type": "Literal",
106+
"type": "JSXText",
107107
"value": "
108108
",
109109
},

packages/typescript-estree/tests/snapshots/comments/jsx-generic-with-comment-in-tag.src.js.shot

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Object {
4343
],
4444
"raw": "
4545
",
46-
"type": "Literal",
46+
"type": "JSXText",
4747
"value": "
4848
",
4949
},
@@ -190,7 +190,7 @@ Object {
190190
],
191191
"raw": "
192192
",
193-
"type": "Literal",
193+
"type": "JSXText",
194194
"value": "
195195
",
196196
},
@@ -374,7 +374,7 @@ Object {
374374
],
375375
"raw": "
376376
",
377-
"type": "Literal",
377+
"type": "JSXText",
378378
"value": "
379379
",
380380
},
@@ -558,7 +558,7 @@ Object {
558558
],
559559
"raw": "
560560
",
561-
"type": "Literal",
561+
"type": "JSXText",
562562
"value": "
563563
",
564564
},
@@ -779,7 +779,7 @@ Object {
779779
"raw": "
780780

781781
",
782-
"type": "Literal",
782+
"type": "JSXText",
783783
"value": "
784784

785785
",
@@ -927,7 +927,7 @@ Object {
927927
],
928928
"raw": "
929929
",
930-
"type": "Literal",
930+
"type": "JSXText",
931931
"value": "
932932
",
933933
},
@@ -1111,7 +1111,7 @@ Object {
11111111
],
11121112
"raw": "
11131113
",
1114-
"type": "Literal",
1114+
"type": "JSXText",
11151115
"value": "
11161116
",
11171117
},
@@ -1295,7 +1295,7 @@ Object {
12951295
],
12961296
"raw": "
12971297
",
1298-
"type": "Literal",
1298+
"type": "JSXText",
12991299
"value": "
13001300
",
13011301
},
@@ -1515,7 +1515,7 @@ Object {
15151515
],
15161516
"raw": "
15171517
",
1518-
"type": "Literal",
1518+
"type": "JSXText",
15191519
"value": "
15201520
",
15211521
},

packages/typescript-estree/tests/snapshots/comments/jsx-tag-comments.src.js.shot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Object {
4848
],
4949
"raw": "
5050
",
51-
"type": "Literal",
51+
"type": "JSXText",
5252
"value": "
5353
",
5454
},

packages/typescript-estree/tests/snapshots/comments/jsx-text-with-multiline-non-comment.src.js.shot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Object {
5151
* test
5252
*/
5353
",
54-
"type": "Literal",
54+
"type": "JSXText",
5555
"value": "
5656
/**
5757
* test

0 commit comments

Comments
 (0)