Closed zisis912 closed 2 years ago
Hi! How can I reproduce what you mean by “it still doesn't do what it is supposed to do. (Disable eslint rules that conflict with prettier ones)”?
when I try to format a javascript file that contains a switch (one of the things eslint and prettier argue about) with prettier, eslint will spam me with indenting errors, since it wants one tab less than prettier. Eslint-config-prettier is supposed to turn off the conflicting rules, and yet it doesnt.
Just try formatting this piece of code with prettier, and eslint should start spamming you with indent errors. At least that's what it did to me.
switch (args[0]) {
case '1':
msg.channel.send ('test1')
break
case '2':
msg.channel.send('test2')
break
case '3':
msg.channel.send('test3')
break
case '4':
msg.channel.send('test4')
break
}
(for context this is code from a discord.js bot command)
It doesn’t for me.
it's obvious that indenting is the problem, no need for the cli helper tool to tell me that.
About the minimal production repo, a big chunk of the commands get activated with the last name of my high school teachers, since I made it when online school was a thing to help us all out with the zoom links. Even apart from that, a lot of the commands show private data since this is a bot only made to be used in 1 server, me and my friends' own one.
So the CLI helper tool shows that you have three conflicting rules. Remove those and all should be good!
Remember:
(Regarding minimal repro repo: That’s something open source maintainers often ask for. It means creating a new repo, without all the things one cannot share, and without all the irrelevant things so that maintainers don’t need to spend time on figuring out where to look.)
wait so.. the entire eslint-config-prettier plugin is just the CLI helper tool? Isn't it supposed to automatically disable the rules for you? Like, why do you add 'prettier' to the extends if you're going to do the work manually anyways?
No, that’s not what I meant. You add 'prettier' to the extends so that it can win over other configs. However, ESLint doesn’t let configs win over you. (Imagine if you couldn’t override rules set by a config!) So there’s a little CLI tool on the side for helping with finding mistakes in your config.
oh I see, but what I'm trying to say is that if i disable indent, semicolons, and linebreak in prettier then it's practically the same as not using it, as imo these are the most important features of it, along with the single quotes.
if i disable indent, semicolons, and linebreak in prettier
That’s not possible. You can configure how much indent, whether you prefer semicolons or not and what linebreak to use, but you can’t disable those things in Prettier.
What you should do is remove indent, semicolon and linebreak rules from ESLint and let Prettier take care of those things.
oh ok, that clarifies things. But I have to do it manually, it cant auto-disable eslint rules that conflict, right?
Correct – the CLI helper tool only lists the problematic rules but does not attempt to automatically update your config file (because that’s near impossible to do in general).
the thing is, many of these are incorrect. For example, ESlint never has a problem with the way prettier uses semicolons.
The description of this package is:
Turns off all rules that are unnecessary or might conflict with Prettier.
So it’s not only about conflicts. It’s a waste of time (it makes ESLint slower) to check things like semicolons twice.
hmm I see. So as you said it suggests me rules that I should turn off because of conflict, and I disable whichever ones I want. Got it
I installed this using
npm install --save-dev eslint-config-prettier
as the instructions said, then added 'prettier' to extends in my.eslintrc.js
and put it last,but it still doesn't do what it is supposed to do. (Disable eslint rules that conflict with prettier ones). You can see that it recognizes the plugin as installed since it doesnt redline
'prettier'
, but it seems to not do anything. The installation process is 2 steps, I don't think I've fucked it up.