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

ESLint throwing no-unused-vars for reactjs data component

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

'TasksComponent' is assigned a value but never used. (no-unused-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"
        ]
    }
};

你有规矩吗

jsx-uses-varsjsx-uses-react

已添加到您的 eslint 配置中?

我认为这些应该可以解决您的问题。