首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何摆脱“简单规则的定义”--未发现导入-排序/导入‘?

我如何摆脱“简单规则的定义”--未发现导入-排序/导入‘?
EN

Stack Overflow用户
提问于 2022-07-22 20:06:03
回答 1查看 278关注 0票数 0

我继承了一个项目,我不再想要这个插件或规则了。我已经将simple-import-sort的所有实例从package.json和eslint.rc中删除。我在任何地方都找不到这件事.

然而,当我运行我的服务器时,会出现这个错误。

如果我没有明确的插件或simple-import-sort规则,我不明白是什么原因导致了这个错误。

我的eslintrc贴在下面:

代码语言:javascript
复制
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',
    },
}
代码语言:javascript
复制
EN

回答 1

Stack Overflow用户

发布于 2022-11-04 10:55:12

我也犯了同样的错误:我将以下内容添加到.eslintrc中:

  • "simple-import-sort"
  • "simple-import-sort/imports":"off",
  • "simple-import-sort/exports":"off“,

按照下面的代码,现在我不再有这些错误了。但我不知道为什么会这样。

代码语言:javascript
复制
"plugins": ["prettier", "react", "react-hooks", "simple-import-sort", "react-native"],
"rules": {
   "simple-import-sort/imports": "off",
   "simple-import-sort/exports": "off,
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73085589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档