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.

Breaking: make 'useJSXTextNode:true' by default #544

Merged
merged 4 commits into from
Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following additional configuration options are available by specifying them
- It's `true` on `*.tsx` files regardless of this option.
- Otherwise, it respects this option.

- **`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`.
- **`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.

### .eslintrc.json

Expand Down
7 changes: 6 additions & 1 deletion 7 parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const visitorKeys = require("./visitor-keys");
exports.version = require("./package.json").version;

exports.parseForESLint = function parseForESLint(code, options) {
if (options && typeof options.filePath === "string") {
if (typeof options !== "object" || options === null) {
options = { useJSXTextNode: true };
} else if (typeof options.useJSXTextNode !== "boolean") {
options = Object.assign({}, options, { useJSXTextNode: true });
}
if (typeof options.filePath === "string") {
const tsx = options.filePath.endsWith(".tsx");
if (tsx || options.filePath.endsWith(".ts")) {
options = Object.assign({}, options, { jsx: tsx });
Expand Down
6 changes: 3 additions & 3 deletions 6 tests/lib/__snapshots__/comments.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ Object {
],
"raw": "
",
"type": "Literal",
"type": "JSXText",
"value": "
",
},
Expand Down Expand Up @@ -1274,7 +1274,7 @@ Object {
],
"raw": "
",
"type": "Literal",
"type": "JSXText",
"value": "
",
},
Expand Down Expand Up @@ -1960,7 +1960,7 @@ Object {
],
"raw": "
",
"type": "Literal",
"type": "JSXText",
"value": "
",
},
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.