-1

I use ESLint to check my react code. However, it cannot identify the variable in react component tag. ESLint throw the error 'no-unused-vars' to me(the variable 'Comp'). But I have been used this variable in my code

export function TestHoc() {
    return function (Comp) {
        class testHocComponent extends PureComponent{
            render(){
                const props={
                    'x':1,
                    'y':2,
                    'z':3
                };

                return (
                    <Comp {...props}/>
                );
            }
        }
        return testHocComponent;
    };
}

And here is the configuration of my ESLint

"env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true
},
"parserOptions": {
    "ecmaVersion": 6,
    "ecmaFeatures": {
        "experimentalObjectRestSpread": true,
        "jsx": true,
        "arrowFunctions": true,
        "classes": true,
        "modules": true,
        "defaultParams": true
    },
    "sourceType": "module"
},
"parser": "babel-eslint",
"plugins": [
    "react"
],
Surya Purohit
  • 1,090
  • 1
  • 9
  • 29
Stephen Mu
  • 13
  • 4

1 Answers1

0

Adding {rules": { "react/jsx-uses-vars": 2 } can help you out. You can spare some time to read this.

Surya Purohit
  • 1,090
  • 1
  • 9
  • 29