steelbrain / babel-plugin-remove-unused-vars

Babel plugin to remove unused variables and imports (Babel autofix for ESLint's no-unused-vars)
MIT License
18 stars 0 forks source link

use in .eslintrc.js file don't work. #2

Closed acpplife closed 5 years ago

acpplife commented 5 years ago

I installed this plugin,then add the plugin to .eslintrc file。The error in code don't show any more. Am i use it wrong?

    parser: 'babel-eslint',
    extends: ['airbnb', 'prettier', 'plugin:compat/recommended'],
    plugins: [
        "react-hooks",
        "babel-plugin-remove-unused-vars"
    ],
    rules: {
        'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
        'react/jsx-wrap-multilines': 0,
        'react/prop-types': 0,
        'react/forbid-prop-types': 0,
        'react/jsx-one-expression-per-line': 0,
        'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }],
        'import/no-extraneous-dependencies': [2, { optionalDependencies: true }],
        'jsx-a11y/no-noninteractive-element-interactions': 0,
        'jsx-a11y/click-events-have-key-events': 0,
        'jsx-a11y/no-static-element-interactions': 0,
        'jsx-a11y/anchor-is-valid': 0,
        'no-underscore-dangle': 0,
        "indent": ['error', 2, { "ignoredNodes": ["TemplateLiteral *"] }],
        "react-hooks/rules-of-hooks": "error", // 检查 Hook 的规则
        "react-hooks/exhaustive-deps": "warn", // 检查 effect 的依赖
        "react/no-array-index-key": 0,
        'no-trailing-spaces': ["error", { "skipBlankLines": true }],
        "react/destructuring-assignment": 0,
        "comma-spacing": ["error", { "before": false, "after": true }],
        "object-curly-spacing": ["error", "always"],
        "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
        "no-unused-vars": "error"
    },
    settings: {
        polyfills: ['fetch', 'promises', 'url'],
    },
};

img

acpplife commented 5 years ago

sorry,it's not a eslint-plugin,my mistake. do you have the plan to use this in eslint-plugin? Thanks!

steelbrain commented 5 years ago

Hi

I don't have any plans to use this in the ESLint plugin, the ESLint plugin already has the marking capabilities, it could easily remove the mark nodes too. You could try to request the maintainers of that feature.

In the past, they have rejected such requests saying it's a dangerous feature, people expect --fix to be conservative, any bug in the plugin (and it has had many bugs over the years) could break things terribly.

I chose to keep it in this babel plugin because it's much more explicit, you are running a very specific thing instead of telling ESLint to fix everything (non destructively).

acpplife commented 5 years ago

ok.Thanks for your reply~