我用的是简单的导入类型的eslint插件。我认为我的.eslintrc.js是正确的,但我不能使这个具体的插件工作。我在文件的第一行中得到以下错误:
规则‘simple-导入-排序/排序’的定义不是简单-导入-排序/排序
这是我的配置:
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'airbnb-typescript',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/recommended',
'plugin:jest/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'prettier',
'prettier/@typescript-eslint',
'prettier/react',
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
},
ignorePatterns: ['*.js'],
plugins: ['react', 'prettier', 'import', 'simple-import-sort'],
rules: {
'prettier/prettier': ['error'],
'no-underscore-dangle': 'off',
'no-async-promise-executor': 'warn',
'no-unused-vars': 'error',
'object-shorthand': ["error", "always"],
'react/destructuring-assignment': ['off', 'never'],
'react/jsx-filename-extension': ['warn', { extensions: ['.tsx', '.js', '.jsx'] }],
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/no-unescaped-entities': 'off',
'react/jsx-no-undef': ['error', { allowGlobals: true }],
'react/jsx-props-no-spreading': 'warn',
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'off',
'sort-imports': 'off',
'simple-import-sort/sort': 'error',
'import/order': 'off',
'import/prefer-default-export': 'off',
'import/extensions': 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
// '@typescript-eslint/camelcase': ['error', { properties: 'never' }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
},
};发布于 2020-11-19 05:14:54
这可能是因为您正在使用v6。
看起来v6没有simple-import-sort/sort规则,参见自述文件中的用法。这是一个11月15日从v5换乘。
您可能需要进行以下更改:
- 'simple-import-sort/sort': 'error',
+ 'simple-import-sort/imports': 'error',发布于 2020-12-21 14:25:32
表单版本6.0.0的简单-导入-排序:
{
"rules": {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
}
}发布于 2022-11-04 11:10:43
我还不得不在.eslintrc中的“插件”中添加“简单导入排序”:
{
"plugins": ["simple-import-sort"]
}然后它就消除了错误。
https://stackoverflow.com/questions/64905158
复制相似问题