ESLint и PHPStorm не видит import

Установил NuxtJs с Vuetify и ESLint. Конфигурационный файл nuxt.config.js создался автоматически. Перейдя в него увидел две ошибки(линтера и IDE) из-за импортируемых цветов import colors from 'vuetify/es5/util/colors';:

ESLint: 'vuetify' should be listed in the project's dependencies. Run 'npm i -S vuetify' to add it (import/no-extraneous-dependencies)

Module is not listed in package.json dependencies

Конфигурационные файлы:

// .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',
    ],
  },
};

Как это можно победить?


Ответы (1 шт):

Автор решения: Не быть рабом на Руси

Решение проблемы:

  • Установить vuetify как зависимость для разработки(npm install vuetify --save-dev);
  • В .eslintrc.js добавить правило:
      'import/no-extraneous-dependencies': [
        'error', {
          devDependencies: true,
        },
      ],
    
→ Ссылка