0

My eslint/prettier setup seems to be fixing things that it is not configured to fix, it’s doing a full replace of all semi-colons and single quotes but I don't believe that is included in our eslint/prettier setup. I have co-workers who run the same linter all the time (this was just pulled from master) so when I run it, it should not be making style changes to every js file in the project…

I know eslint supports hierarchies so, theoretically, a prettier file in my system might have been causing this to happen but I’ve added "root": true to the file and I continue to have the issue.

This is the .eslintrc.json file:

{
  "root": true, // <- this is the only change I've made
  "extends": [
    "airbnb-base",
    "plugin:react/recommended",
    "plugin:prettier/recommended"
  ],

  "plugins": [
    "react",
    "jsx-a11y",
    "prettier"
  ],

  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "modules": true
    }
  },

  "globals": {
    "document": true,
    "window": true
  }
}


Every time the above is run I get errors such like:

7:14  error  Replace `"form"` with `'form'`    prettier/prettier
9:2   error  Delete `;`                        prettier/prettier

I've tried running yarn lint --debug and I didn't see any outside linter/prettier scripts that would be overriding the above.

I'm not a JS expert by any means, I sort of believe that prettier is configured by default to remove semi-colons and double quotes but the fact that this does not happen for my coworkers leads me to believe that this configuration should disable that but it is not for me.


For further context, I do have the Prettier plugin for Atom but I have tried running this with it disabled and even uninstalled. I've also uninstalled my global Prettier package.

tfantina
  • 788
  • 11
  • 37
  • 2
    what's your `prettierrc` config – Krzysztof Krzeszewski Sep 13 '21 at 13:40
  • what happens if you remove the lines with `"prettier"` from your `extends` and `plugins` section? – malarres Sep 13 '21 at 14:29
  • @malarres the overall number of errors decreases by about 75, but it seems like many of the errors are still the same just not thrown by prettier: `error Strings must use singlequote quotes` – tfantina Sep 13 '21 at 14:36
  • @KrzysztofKrzeszewski there is no `prettierrc` file in the project. – tfantina Sep 13 '21 at 14:38
  • @tfantina when you `extend` a given set you're adapting as default those rules. So the singlequotes are coming either from airbnb-base or react/recommended. You can test that by not extending at all – malarres Sep 13 '21 at 14:40
  • Hmm, thank you. If I remove all extends the linter does throw fewer errors but it also dosen't lint the remaining errors are: `17:1 error Parsing error: The keyword 'import' is reserved` – tfantina Sep 13 '21 at 15:09
  • We ended up adding specific prettier rules to `.eslintrc.json` to match my setup (fortunately it's a small team of me and one other dev working on this project and he was the one pushing to do this), it feels like a concession, I really wish I knew why this was happening. – tfantina Sep 15 '21 at 12:08

0 Answers0