Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.eslintrc.js doesn't work with rules "off"

native and have a problem with configuring eslint. This is my .eslintrc.js.

module.exports = {
    "extends": "airbnb",
    "parser": "babel-eslint",
    "env": {
        "jest": true,
    },
    "plugins": [
        "react",
        "node"
    ],
    "rules": {
        "no-use-before-define": "off",
        "react/jsx-filename-extension": "off",
        "node/no-unsupported-features/es-syntax": ["error", {
            "version": ">=6.0.0",
            "ignores": ["modules", "destructuring"]
        }],
        "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
        "react/prop-types": "off",  
    }
};

In App.js,

const { navigation } = this.props;

I got the eslint error.

[eslint] Destructuring are not supported yet on Node 4.0.0. (node/no-unsupported-features) 
[eslint] 'navigation' is missing in props validation (react/prop-types)

And also in In App.js,

<View style={styles.container}>
    <UpArrow title="cancel" />
    <SecondsSpinner seconds={this.state.imageTime} changeImageTime={this.changeImageTime} />
    <DownArrow title="save" />
</View>

I got error

[eslint] JSX not allowed in files with extension '.js' (react/jsx-filename-extension)

So I

  • turned off "react/prop-types",
  • set "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
  • set "ignores": ["destructuring"].

But they dosen't work. I don't know why and how to solve this. Is there any other file to config eslint? Thanks in advance.

EDIT1) "ignores": ["modules"] works. so weird.

EDIT2) I am using vscode and got errors on the editor on and on, so I thought because of .eslintrc file. But now I think it's problem of vscode. I set

"eslint.options": { "configFile": "/Users/com/vscode/AwesomeProject/.eslintrc.js" } 

in Workspace Settings then it works

like image 628
alex Avatar asked Mar 08 '26 04:03

alex


1 Answers

Try:

module.exports = {
    "extends": "airbnb",
    "parser": "babel-eslint",
    "env": {
        "jest": true,
    },
    "plugins": [
        "react",
        "node"
    ],
    "rules": {
        "no-use-before-define": 0,
        "react/jsx-filename-extension": 0,
        "node/no-unsupported-features/es-syntax": ["error", {
            "version": ">=6.0.0",
            "ignores": ["modules", "destructuring"]
        }],
        "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
        "react/prop-types": 0,  
    }
};
like image 190
Deepak Avatar answered Mar 11 '26 08:03

Deepak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!