ESLint为reactjs数据组件抛出no-unused-vars

时间:2018-06-12 17:50:59

标签: reactjs eslint react-component eslintrc

有谁知道如何解决这个linting问题?它声称我没有使用TasksComponent。谢谢!

  

'TasksComponent'被赋值但从未使用过。 (无未使用-VARS)

describe('root tests', () => {

    it('renders without crashing', () => {
        const TasksComponent = TasksWithData(Tasks);
        const root = document.createElement('root');
        ReactDOM.render(<TasksComponent {...taskconfig} />, root);
        ReactDOM.unmountComponentAtNode(root);
    });

});

这是我的.eslintrc文件:

module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "jest": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "indent": [
            "error",
            4
        ],
        "quotes": [
            "warn",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};

1 个答案:

答案 0 :(得分:2)

你有规则

jsx-uses-varsjsx-uses-react

添加到你的eslint配置?

我认为那些应该解决你的问题。