首页 > 解决方案 > How to remove prettier plugin from ESLint in VS Code?

问题描述

I've been using prettier plugin for ESLint for a while and now I've got project with different .eslintrc.js. My config use to be like:

module.exports = {
  ...
  extends: [
    'airbnb',
    'prettier',
    'prettier/react',
  ],
  ...
  plugins: [
    'react',
    'prettier',
  ],
  rules: {
    'prettier/prettier': [
      'error',
      {
        'trailingComma': 'es5',
        'singleQuote': true,
        'printWidth': 120,
      }
    ],
    'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx'] }],
  },
  ...
};

I got rid of all of those rules & plugins & extensions, however, I still get this error:

Failed to load plugin prettier: Cannot find module 'eslint-plugin-prettier' Happened while validating /.../file.js This can happen for a couple of reasons: 1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc). 2. If ESLint is installed globally, then make sure 'eslint-plugin-prettier' is installed globally as well. 3. If ESLint is installed locally, then 'eslint-plugin-prettier' isn't installed correctly.

I don't really want to use it no more, but this error doesn't allow me to use ESLint at all. Could this be because plugin is installed globally as well? How do I get rid of this plugin?

What I tried so far:

标签: visual-studio-codeeslintprettier

解决方案


Turned out that I had .eslintrc.js configuration in the upper folder which had a priority to load. Removing this file and keeping an existing one in project fixed my problem.


推荐阅读