reactjs - 未找到规则“简单导入排序/排序”的定义 simple-import-sort/sort
问题描述
我正在使用对 simple-import-sort eslint 插件做出反应。我认为我.eslintrc.js
是对的,但我无法使这个特定的插件工作。我在文件的第一行收到以下错误:
未找到规则“简单导入排序/排序”的定义 simple-import-sort/sort
这是我的配置:
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',
},
};
解决方案
可能是您使用的是 v6。
看起来 v6 没有simple-import-sort/sort
规则,请参阅README 中的用法。这是11 月 15 日 v5 的变化。
您可能需要进行以下更改:
- 'simple-import-sort/sort': 'error',
+ 'simple-import-sort/imports': 'error',
推荐阅读
- r - Tidymodel 包:R 中的通用线性模型 (glm) 和决策树(袋装树、提升树和随机森林)模型
- java - 没有用户服务的 Spring Security x509 身份验证,而不是令牌
- asp.net-core - .Net Core 导出 Excel
- puppeteer - 表情符号在 Chrome Headless 的 PDF 输出中变为灰色
- python - 用于获取文件夹中文件类型总数并将结果写入文件的 Python 脚本
- php - 如何使用多单元格在 FPDF 单元格中添加换行符
- c# - C# - 从 JSON 中提取 HTML
- node.js - 如何在 sequelize 中使用 group by 子句获取嵌套对象
- javascript - 展平对象和限制嵌套数量
- python - 我想在 django 中使用 ORM 获取两个查询数据的结果