我继承了一个项目,我不再想要这个插件或规则了。我已经将simple-import-sort的所有实例从package.json和eslint.rc中删除。我在任何地方都找不到这件事.
然而,当我运行我的服务器时,会出现这个错误。
如果我没有明确的插件或simple-import-sort规则,我不明白是什么原因导致了这个错误。
我的eslintrc贴在下面:
const fs = require('fs')
const foldersUnderSrc = fs
.readdirSync('src', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/strict',
],
env: {
browser: true,
jasmine: true,
jest: true,
},
plugins: ['react', 'react-hooks', 'jsx-a11y'],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-explicit-any': 0,
'no-async-promise-executor': 0,
'no-console': 0,
'no-irregular-whitespace': 0,
'react/jsx-key': 0,
'no-restricted-imports': [
2,
{
paths: [
{
name: 'lodash',
message:
"Do not import from `lodash` directly, as we don't support tree-shaking for it. Instead, import the function you're trying to use, e.g. `import debounce from 'lodash/debounce'`",
},
],
},
],
'react-hooks/exhaustive-deps': 1,
'react/jsx-sort-default-props': [
'warn',
{
ignoreCase: false,
},
],
'react-hooks/rules-of-hooks': 1,
'react/prop-types': 0,
'react/display-name': 0,
'react/no-unescaped-entities': 0,
'jsx-a11y/no-autofocus': 0,
'jsx-a11y/media-has-caption': 0,
'@typescript-eslint/no-empty-function': 0,
'react/jsx-uses-react': 0,
'react/react-in-jsx-scope': 0
},
settings: {
react: {
pragma: 'React',
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
globals: {
global: 'readonly',
Atomics: 'readonly',
process: true,
SharedArrayBuffer: 'readonly',
Promise: 'readonly',
Buffer: 'readonly',
WeakSet: 'readonly',
setImmediate: 'readonly',
setInterval: 'readonly',
setTimeout: 'readonly',
shallow: 'readonly',
page: 'readonly',
},
}发布于 2022-11-04 10:55:12
我也犯了同样的错误:我将以下内容添加到.eslintrc中:
按照下面的代码,现在我不再有这些错误了。但我不知道为什么会这样。
"plugins": ["prettier", "react", "react-hooks", "simple-import-sort", "react-native"],
"rules": {
"simple-import-sort/imports": "off",
"simple-import-sort/exports": "off,
}https://stackoverflow.com/questions/73085589
复制相似问题