【问题标题】:Not able to ignore Rule in Eslint无法忽略 Eslint 中的规则
【发布时间】:2018-06-20 10:40:15
【问题描述】:

我的 .eslintrc 中有以下内容(此处为项目 https://github.com/jrgleason/jest/tree/UPGRADE

overrides: [
...
    {
        files: [
            'e2e/__tests__/**/*',
        ],
        rules: {
            'import/no-unresolved': "off",
        },
    },
]

但是当我跑步时,我看到...

代码/jest/e2e/测试/haste_map_sha1.test.js 14:26 错误无法解析模块“jest-haste-map”导入/未解决的路径

为什么不关机?

【问题讨论】:

    标签: eslint


    【解决方案1】:

    这是因为您使用了无效的 json 格式:

        {
            files: [
                'e2e/__tests__/**/*',
                'packages/babel-jest/**/*.test.js',
                'packages/babel-plugin-jest-hoist/**/*.test.js',
                'packages/babel-preset-jest/**/*.test.js',
                'packages/eslint-config-fb-strict/**/*.test.js',
                'packages/eslint-plugin-jest/**/*.test.js',
                'packages/jest-changed-files/**/*.test.js',
                'packages/jest-circus/**/*.test.js',
                'packages/jest-diff/**/*.test.js',
                'packages/jest-docblock/**/*.test.js',
                'packages/jest-editor-support/**/*.test.js',
                'packages/jest/**/*.test.js',
                'packages/pretty-format/**/*.test.js',
            ],
            rules: {
                'import/no-unresolved': "off",
                'flowtype/require-valid-file-annotation': [2, 'always'],
            },
        },
    

    这些应该是双引号。

    更新: eslint 支持 JSON5,​​所以试试: 'import/no-unresolved': "off",

    【讨论】:

    • 该代码不是 JSON,而是一个 JavaScript 对象。
    【解决方案2】:

    答案是因为 ESLINT 中的错误,我不能这样做

    请看这里https://github.com/eslint/eslint/issues/9025

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-15
      • 2018-05-27
      • 2018-01-08
      • 2020-05-10
      • 1970-01-01
      • 2017-05-10
      • 2020-12-06
      • 2018-03-16
      相关资源
      最近更新 更多