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

The thing just doesnt work. #214

Closed
zisis912 opened this issue Dec 24, 2021 · 14 comments
Closed

The thing just doesnt work. #214

zisis912 opened this issue Dec 24, 2021 · 14 comments

Comments

@zisis912
Copy link

zisis912 commented Dec 24, 2021

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,
image

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.

@lydell
Copy link
Member

lydell commented Dec 26, 2021

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)”?

@zisis912
Copy link
Author

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)

@lydell
Copy link
Member

lydell commented Dec 27, 2021

It doesn’t for me.

  • You can use the CLI helper tool to find some problems with your config.
  • If that doesn’t help, can you make a minimal reproduction repo? (That’s usually a good way to find the problem onesefl, btw.)

@zisis912
Copy link
Author

zisis912 commented Dec 27, 2021

it's obvious that indenting is the problem, no need for the cli helper tool to tell me that.
image

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.

@lydell
Copy link
Member

lydell commented Dec 28, 2021

So the CLI helper tool shows that you have three conflicting rules. Remove those and all should be good!

Remember:

  • To put "prettier" last in "extends", so it "wins" over other configs.
  • That "extends" never wins over "rules". I assume you set "indent", "linebreak-style" and "semi" in "rules".

(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.)

@zisis912
Copy link
Author

zisis912 commented Jan 8, 2022

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?

@lydell
Copy link
Member

lydell commented Jan 8, 2022

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.

@zisis912
Copy link
Author

zisis912 commented Jan 9, 2022

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.

@lydell
Copy link
Member

lydell commented Jan 9, 2022

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.

@lydell lydell closed this as completed in 23c8169 Jan 14, 2022
@zisis912
Copy link
Author

oh ok, that clarifies things. But I have to do it manually, it cant auto-disable eslint rules that conflict, right?

@lydell
Copy link
Member

lydell commented Jan 16, 2022

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).

@zisis912
Copy link
Author

the thing is, many of these are incorrect. For example, ESlint never has a problem with the way prettier uses semicolons.

@lydell
Copy link
Member

lydell commented Mar 14, 2022

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.

@zisis912
Copy link
Author

zisis912 commented Mar 14, 2022

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

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

No branches or pull requests

2 participants