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

parserOptions.ecmaFeatures.jsx option not passed to estree #594

Closed
bradzacher opened this issue Jan 9, 2019 · 2 comments · Fixed by typescript-eslint/typescript-eslint#85
Labels

Comments

@bradzacher
Copy link

What version of TypeScript are you using?
3.1.1

What version of typescript-eslint-parser are you using?
21.0.2

What code were you trying to parse?

const RuleTester = require("eslint").RuleTester;

const ruleTester = new RuleTester({
    parserOptions: {
        ecmaVersion: 6,
        sourceType: "module",
        ecmaFeatures: {
            jsx: true,
        },
    },
    parser: "typescript-eslint-parser",
});

ruleTester.run("no-unused-vars", rule, {
    valid: [
		`
const Foo = function () {}
function render() {
    return (<Foo />);
}
		`,
	],
	invalid: [],
})

What did you expect to happen?
The code should parse successfully, so I can test the rule.

What happened?
Parsing error: \'>\' expected.

see astexplorer repl
Note the parser has the jsx option set to true

@bradzacher
Copy link
Author

Looking at the parser code, it just passes the raw parserOptions object into typescript-estree, however typescript-estree has its jsx option on the root options object, not on ecmaFeatures.

Workaround is to set jsx: true on the base parserOptions object:

 const ruleTester = new RuleTester({
     parserOptions: {
         ecmaVersion: 6,
         sourceType: "module",
-        ecmaFeatures: {
-            jsx: true,
-        },
+        jsx: true,
     },
     parser: "typescript-eslint-parser",
});

@JamesHenry
Copy link
Member

This issue has been migrated to the new project here: typescript-eslint/typescript-eslint#24

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants