使用Vuetify和ESLint安装NuxtJs。配置文件是自动创建的。进入它,由于导入的颜色,我看到了两个错误(linter 和 IDE):nuxt.config.js
import colors from 'vuetify/es5/util/colors';
ESLint: 'vuetify' 应该列在项目的依赖中。运行“npm i -S vuetify”以添加它(导入/无外部依赖项)
模块未在 package.json 依赖项中列出
配置文件:
// .eslintrc.js
module.exports = {
env: {
browser: true,
node: true,
es2021: true,
},
extends: [
'eslint:recommended',
'airbnb-base',
'plugin:nuxt/recommended',
'plugin:vue/recommended',
'plugin:vuetify/base',
'plugin:@typescript-eslint/recommended',
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
plugins: [
'vue',
'@typescript-eslint',
],
rules: {
'vue/script-indent': [
'error', 2, {
baseIndent: 1,
switchCase: 0,
ignores: [],
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'import/prefer-default-export': 'off',
camelcase: ['error', {
properties: 'never',
}],
},
overrides: [
{
files: ['*.vue'],
rules: {
indent: 'off',
camelcase: 'off',
},
},
],
settings: {
'import/resolver': {
nuxt: {
extensions: [
'.ts',
'.js',
'.vue',
],
},
},
'import/core-modules': [
'vue',
'vuex',
],
},
};
如何克服?
解决方案:
vuetify
作为开发依赖安装(npm install vuetify --save-dev
);.eslintrc.js
添加规则: