The Wayback Machine - http://web.archive.org/web/20211015083158/https://github.com/prettier/prettier-atom/issues/413
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support disabling specific ESLint rule fixes #413

Open

revelt opened this issue Apr 20, 2018 · 7 comments
Open

support disabling specific ESLint rule fixes #413

revelt opened this issue Apr 20, 2018 · 7 comments

Comments

@revelt
Copy link

@revelt revelt commented Apr 20, 2018

When I was using only ESLint Atom plugin linter-eslint, it had this preferences setting where I could stop it from removing my .only tests from AVA unit tests:
screen shot 2018-04-20 at 07 21 09

This meant that any occurrences of t.only would get flagged as errors and husky precommit hook would call ESLint and block the commit.

Now I switched to Prettier and Prettier doesn't have a setting to block the automatic fixing of ESLint issues. My AVA tests' t.only gets removed upon saving:

ava_eslint

This means, I have to either turn off the rules ava/no-only-test & ava/no-skip-test completely (but I risk my t.onlyies spilling into the production code) OR turn on and off Prettier when sorting out unit tests (which is tedious).

Before you say it's ESLint problem not prettier-atom's

eslint/eslint#7549 was closed (imho short-sightedly). Furthermore, linter-eslint has nailed this already, they added a field which lets you whitelist the rules to stop auto-fixing. It even works with Prettier turned off. It's just a matter for Prettier to mirror the setting in its own GUI field in prettier-atom.

Before you say it's Prettier's problem not prettier-atom's

Correct me if I'm wrong, but in Atom+ESLint+Prettier setup, there are only two setup locations: eslintrc or this plugin's config window in Atom Preferences GUI. If the former is out, this leaves us only latter. Which means, you will have to add some sort of a field in preferences GUI... of this plugin, not Prettier's.

Proposed solution

As @not-an-aardvark suggested in eslint/eslint#7549 (comment), you can do that in command line:

eslint myFile.js --fix --rule 'some-rule-i-like: off'

If we could somehow add a settings field in GUI, same like ESLint's:

screen shot 2018-04-20 at 07 21 09

and wire it up to the place where Prettier actually calls ESLint fix function, to pass in the ignored-for-fixing rules, that could be the solution?

PS. It's perplexing why has nobody had this issue yet — are guys not using Prettier or Atom or AVA unit tests? We're many months into this setup, all components are not new anymore... Yet I can't find anybody complaining about this... {end of rant}

@robwise
Copy link
Collaborator

@robwise robwise commented Apr 22, 2018

There are several ways to use prettier-atom + eslint together. Are you using the "ESLint Integration" option? This uses prettier-eslint under the hood, so we'd need that repo to support this option before we could make any changes here.

As an alternative, if linter-eslint is working well for you, I would look into running prettier as an eslint rule. Then you could just turn prettier-atom off for that project and it should work I think.

@revelt
Copy link
Author

@revelt revelt commented Apr 23, 2018

@robwise thanks for quick response!

Are you using the "ESLint Integration" option?

Yes

..if linter-eslint is working well for you..

linter-eslint is fine, it has the "Disable specific rules from fixes" field in Preferences GUI in Atom. Once I turn Prettier off via status bar, AVA tests are not "fixed", ESLint ecosystem itself is working fine.

@robwise
Copy link
Collaborator

@robwise robwise commented Apr 24, 2018

Yeah with the ESLint Integration option on, it's using prettier-eslint under the hood.

I would need an API from that package that allows disabling of fixing certain rules in order to reimplement what linter-eslint does.

In other words, prettier-atom isn't directly talking to eslint the way linter-eslint does, instead, we are going through a middleman (prettier-eslint) and they need to expose this ability to us.

linter-eslint is fine, it has the "Disable specific rules from fixes" field in Preferences GUI in Atom. Once I turn Prettier off via status bar, AVA tests are not "fixed", ESLint ecosystem itself is working fine.

Yes, then I would definitely check out running prettier as an eslint rule and just turn off prettier-atom entirely. This may turn out to meet your needs exactly.

Alternatively, you can ask prettier-eslint to expose this ability and we can implement something similar to linter-eslint on prettier-atom.

@revelt
Copy link
Author

@revelt revelt commented Apr 24, 2018

I'd be up for running prettier as an ESLint rule but what about other files, like MD or JSON or all others that prettier formats but ESLint doesn't understand? Will they be cleaned as well via ESLint?

@robwise
Copy link
Collaborator

@robwise robwise commented Apr 25, 2018

No, that's a good point, you could also try blacklisting the JavaScript files in prettier-atom so that linter-eslint takes over for those, but you still have prettier-atom for everything else.

Like I said though, I'm happy to add this option to prettier-atom if you can convince the prettier-eslint guys to support it in their API.

@revelt
Copy link
Author

@revelt revelt commented Apr 25, 2018

Wow, blackisting *.js in prettier-atom and enabling linter-eslint "Fix errors on save" (and closing the yellow warning popup) did the trick! Thank you sir. +1 +1 +1

I'd say let's keep this issue open? Because the problem is there on the promised solution to users (advising to disable linter-eslint "fix errors on save" and switching to prettier-atom etc)... What do you think?

@robwise
Copy link
Collaborator

@robwise robwise commented Apr 25, 2018

Yeah for sure, I'm glad you got it working finally but it definitely would be easier if we could have an option like linter-eslint. Can you make an issue over at prettier-eslint to get that option added to the API? Otherwise my hands are tied because everything is going through that package before it gets to ESLint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants