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
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 150ffe8

Browse filesBrowse files
authored
Breaking: make 'useJSXTextNode:true' by default (#544)
* Breaking: make 'useJSXTextNode:true' by default * update README.md * modify the description of `useJSXTextNode` option
1 parent 2d22321 commit 150ffe8
Copy full SHA for 150ffe8

File tree

Expand file treeCollapse file tree

3 files changed

+10
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-5
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The following additional configuration options are available by specifying them
4141
- It's `true` on `*.tsx` files regardless of this option.
4242
- Otherwise, it respects this option.
4343

44-
- **`useJSXTextNode`** - default `false`. The JSX AST changed the node type for string literals inside a JSX Element from `Literal` to `JSXText`. When value is `true`, these nodes will be parsed as type `JSXText`. When value is `false`, these nodes will be parsed as type `Literal`.
44+
- **`useJSXTextNode`** - default `true`. Please set `false` if you use this parser on ESLint v4. If this is `false`, the parser creates the AST of JSX texts as the legacy style.
4545

4646
### .eslintrc.json
4747

‎parser.js

Copy file name to clipboardExpand all lines: parser.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const visitorKeys = require("./visitor-keys");
2020
exports.version = require("./package.json").version;
2121

2222
exports.parseForESLint = function parseForESLint(code, options) {
23-
if (options && typeof options.filePath === "string") {
23+
if (typeof options !== "object" || options === null) {
24+
options = { useJSXTextNode: true };
25+
} else if (typeof options.useJSXTextNode !== "boolean") {
26+
options = Object.assign({}, options, { useJSXTextNode: true });
27+
}
28+
if (typeof options.filePath === "string") {
2429
const tsx = options.filePath.endsWith(".tsx");
2530
if (tsx || options.filePath.endsWith(".ts")) {
2631
options = Object.assign({}, options, { jsx: tsx });

‎tests/lib/__snapshots__/comments.js.snap

Copy file name to clipboardExpand all lines: tests/lib/__snapshots__/comments.js.snap
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ Object {
12191219
],
12201220
"raw": "
12211221
",
1222-
"type": "Literal",
1222+
"type": "JSXText",
12231223
"value": "
12241224
",
12251225
},
@@ -1274,7 +1274,7 @@ Object {
12741274
],
12751275
"raw": "
12761276
",
1277-
"type": "Literal",
1277+
"type": "JSXText",
12781278
"value": "
12791279
",
12801280
},
@@ -1960,7 +1960,7 @@ Object {
19601960
],
19611961
"raw": "
19621962
",
1963-
"type": "Literal",
1963+
"type": "JSXText",
19641964
"value": "
19651965
",
19661966
},

0 commit comments

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