Closed andiShan11 closed 9 months ago
Yes, this package splits up the no-unused-vars
rule into no-unused-vars
and no-unused-imports
. You have put the varsIgnorePattern
into the no-unused-vars
rule and not the no-unused-imports
rule.
Try
"unused-imports/no-unused-imports": [ "error", {vars: "local", varsIgnorePattern: "React|createElement"}]
if the .eslintrc.js is like below. "rules": { 'react/jsx-no-undef': [2, { allowGlobals: true }], 'react/jsx-uses-vars': "error", 'react/jsx-uses-react': "error", 'no-unused-vars': [ 2, { vars: 'local', args: 'after-used', varsIgnorePattern: 'React|createElement', }, ], }
then
import React from 'react';
work well.however, if the .eslintrc.js is like below. "rules": { 'react/jsx-no-undef': [2, { allowGlobals: true }], 'react/jsx-uses-vars': "error", 'react/jsx-uses-react': "error", "no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off", "unused-imports/no-unused-imports": "error", "unused-imports/no-unused-vars": [ "warn", { vars: "local", varsIgnorePattern: 'React|createElement', args: "after-used", argsIgnorePattern: "^_" } ] } then
import React from 'react';
React will be marked wrongly as a unused import.