prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.4k stars 254 forks source link

Arrow parens lint error #147

Closed EdwardBarton closed 4 years ago

EdwardBarton commented 4 years ago

I am receiving a linting error regarding arrow parens, despite having the latest versions of prettier (2.0.5), eslint-config-prettier (6.11.0), and eslint-plugin-prettier (3.1.3)

image

Here is a snippet from my .eslintrc.js

extends: [
    'airbnb-typescript',
    'plugin:cypress/recommended',
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
    'prettier/@typescript-eslint',
    'prettier/react',
  ],
  plugins: ['react-hooks', 'jest', '@typescript-eslint'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
    project: './tsconfig.json',
  }

Additionally, here is my .prettierrc.js file:

module.exports = {
  semi: false,
  printWidth: 80,
  tabWidth: 2,
  useTabs: false,
  singleQuote: true,
  trailingComma: 'all',
  bracketSpacing: true,
  jsxBracketSameLine: false,
}

If I comment out plugin:prettier/recommended the lint error goes away, but I'd prefer to extend from the recommended config.

lydell commented 4 years ago

Hi!

This repo is just a config that turns off a bunch of ESLint rules, so this is not the right place to report this issue. The thing that lets you run Prettier from within ESLint comes from eslint-plugin-prettier. But I’ll try to help anyway.

The way to debug these types of issues is to reduce the number of tools you use at once.

  1. First, try running prettier --write some/file.ts. Does it do arrowParens as expected? (First remove some parens and see if Prettier puts them back.) After this step you’ll know if there’s any problem with your Prettier setup.

  2. Then, try running eslint some/file.ts. Does it report that you should remove parens? After this step, you’ll know if there’s any problem with your ESLint/eslint-plugin-prettier setup.

  3. Finally, run from within VSCode. Do you get errors only now? Then, the problem is with the ESLint plugin for VSCode.

When you know if the problem seems to come from Prettier, ESLint or VSCode, start reducing your config. Remove things piece by piece until you have a minimal reproduction. Many times when doing this, I find that the problem was due to a configuration mistake by me! If not, you’ve now got a minimal repro to share in an issue for the appropriate project.

Hope this helps!

EdwardBarton commented 4 years ago

@lydell I am so sorry for posting in the wrong repo! Thanks to your helpful troubleshooting steps, I was able to determine that it was indeed a problem with the VSCode extension. Uninstalling/re-installing the extension fixed the issue! Sorry again.

Thanks for your help!