Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

Definition for rule 'no-useless-backreference' was not found

项目中使用了 ESLint,然后每个 JS 文件首行都会报这个提示:

Definition for rule 'no-useless-backreference' was not found

ESLint 配置如下:

module.exports = {
    parser: 'babel-eslint',     // ESLint 默认使用Espree作为其解析器,平常项目中我一般使用babel-eslint作为parser。
    extends: [
        'eslint-config-alloy',
        'eslint-config-alloy/react',
        // 'plugin:prettier/recommended'
    ],
    parserOptions: {
        "ecmaVersion": 2019,       // 指定ECMAScript版本,默认为5
        "sourceType": "module",    // 设置为 "script" (默认) 或 "module"
        "ecmaFeatures": {
            "jsx": true            // 启用jsx
        }
    },
    settings: {
        "react": {
            "version": "detect",    // 自动选择你已安装的版本
        }
    },
    // 插件名称可以省略 eslint-plugin- 前缀。
    plugins: [
        "prettier"
    ],
    env: {
        browser: true,
        node: true,
        "es6": true,    // 启用除了 modules 以外的所有 ECMAScript 6 特性(该选项会自动设置 ecmaVersion 解析器选项为 6)
    },
    globals: {
        // 你的全局变量(设置为 false 表示它不允许被重新赋值)
        //
        // 比如:
        // jQuery: false,
        // $: false
    },
    rules: {
        // allow debugger during development
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        "indent": ["error", "tab"],
        // 关闭react默认的props-type验证
        'react/prop-types': [0],
        'default-case-last': 'off',
        'no-unused-vars': 'warn'
    }
}

纳闷了,各位大佬,求解?谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

更新一下eslint的版本试试。
no-useless-backreference应该是新的规则,你extends中继承的规则中使用了这个规则,但在当前版本的eslint中找不到这个规则导致报错。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...