Eslint-plugin-react: Unable to allow JSX in .js files without errors

Created on 16 Sep 2016  路  4Comments  路  Source: yannickcr/eslint-plugin-react

I've been stumbling over .eslintrc configs all day trying to fix this one.

At my current job, we use JSX inside of .js files. I don't want to be alerted about this by eslint.

Here's my .eslintrc file, and I've been trying many variations of this.

{
    "parser": "babel-eslint",
    "env": {
    娄   "browser": true,
    娄   "node": true
    },  
    "settings": {
    娄   "ecmascript": 6,
    娄   "jsx": true,
    },  
    "plugins": [
    娄   "react"
    ],  
    "rules": {
    娄   "strict": 2,
    娄   "quotes": 2,
    娄   "no-unused-vars": 2,
    娄   "camelcase": 2,
    娄   "no-underscore-dangle": 2,
    娄   "comma-dangle": ["error", "always"],
    娄   "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], 
    }   
}

The last line in the rules section was pulled from here: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md

I used that exact line and am still getting errors when linting.

Maybe that line doesn't even belong in my .eslintrc? I'm still pretty new to all of this.

What other info should I give you to help make my problem more clear?

Thanks!

All 4 comments

If you have no other .eslintrc files, that should work just fine. Can you provide the command you're running, and the output?

Looks like there was a sneaky .eslintrc.js in the base directory of this project.

That's generally the only place you want all your config files, and you'd want to put "root": true in it :-)

Yeah, this problem was definitely due to some antipatterns and mis-aligned version numbers.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings