vscode eslint 报以下提示

image.png

点击提示跳转过去:光标指向
image.png

感觉是什么地方配置的问题
.eslintrc.js

/* eslint-disable */
module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/essential',
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  },
  parserOptions: {
    parser: 'babel-eslint',
  },
  rules: {
    // don't require .vue extension when importing
    'import/extensions': ['error', 'always', {
      js: 'never',
      vue: 'never',
    }],
    // disallow reassignment of function parameters
    // disallow parameter object manipulation except for specific exclusions
    'no-param-reassign': ['error', {
      props: true,
      ignorePropertyModificationsFor: [
        'state', // for vuex state
        'acc', // for reduce accumulators
        'e', // for e.returnvalue
      ],
    }],
    // allow optionalDependencies
    'import/no-extraneous-dependencies': ['error', {
      optionalDependencies: ['test/unit/index.js'],
    }],
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'guard-for-in': 'off',
    'linebreak-style': 'off',
    'no-param-reassign': 'off',
    'no-plusplus': 'off',
    'no-restricted-syntax': 'off',
    'no-mixed-operators': 'off',
    'no-template-curly-in-string': 'off',
    'max-len': 'off',
    'no-underscore-dangle': 'off',
    'radix': 'off',
    'prefer-destructuring': 'off',
    'no-shadow': 'off',
    'mini-css-extract-plugin': 'off',
  },
};
阅读 2.3k
1 个回答

在你的配置文件中对 import/extensions 这条规则进行了配置,报错信息说 找不到 import/extensions 这条规则。这条规则包含在 eslint-plugin-import 插件中,但好像你没有安装。

npm install -D eslint-plugin-import

然后把配置文件加上:

module.exports = {
  ...
  plugins: ['import'],
};

试下看看。

推荐问题