GithubHelp home page GithubHelp logo

Comments (26)

CiGit avatar CiGit commented on June 6, 2024 3

I was mentioning //prettier-ignore which is not for an entire file and thus doesn't let us pass it to the next formatter (I think).

And I've seen a use case: not all files are processed the same way, build files vs babel files.
For that case I think the right solution would be to provide different options (trailing-comma I can think of) but that's an other issue :-)

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024 2

Hum ... right...
As a current work around:

  • Disable formatOnSave
  • set prettier.jsonEnable:[] (ie disable 'json' formatting)
  • Remove // Place your settings in this file to overwrite the default settings and any other comment. But it may still fail with a trailing comment.
    Edit: Choose one of those.

from prettier-vscode.

kengoldfarb avatar kengoldfarb commented on June 6, 2024 1

Any movement on this issue lately? It'd be a really helpful feature to have.

from prettier-vscode.

joaovieira avatar joaovieira commented on June 6, 2024 1

Can't wait for this. Tired of unnecessary git diffs in package.json as npm also formats it on each install.

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024 1

It should once implemented. I see a new settings called ignorePath which defaults to .prettierignore syntaxe is the same as a the one used in gitignore

from prettier-vscode.

jackson-sandland avatar jackson-sandland commented on June 6, 2024 1

This would be a great feature. Why would we want to prettify anything in .gitignore - especially node_modules?

from prettier-vscode.

esbenp avatar esbenp commented on June 6, 2024

Seems like a good idea to me. Would you dare to take a crack at a PR?

from prettier-vscode.

raphi011 avatar raphi011 commented on June 6, 2024

yea sure, i'll try to get to it this week :)

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

If you find your webpack config getting ugly maybe the best thing to do would be to open an issue on prettier.
I'm not against that option even if I personally see no use case currently. You can still put a // prettier-ignore on a block you don't want prettier to modify.

If this is tackled, I think it shouldn't break EVERY formatter, this way you can still format your ignored files with the default formatter (or any other formatter) to have it indented correctly.

from prettier-vscode.

raphi011 avatar raphi011 commented on June 6, 2024

I went to the prettier issues and someone asked a similiar question here.

They said we should create an option for the extensions which use prettier, not for prettier itself.

I agree with not breaking other formatters!

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

What's your use case ?

  • Ignore files completely
  • Having different config per language
  • Having different config per files (same language)
  • Other?

from prettier-vscode.

kengoldfarb avatar kengoldfarb commented on June 6, 2024

@CiGit ignoring files completely. Specifically, I'm seeing prettier destroy my flow-type module definitions. Temporarily turning off format on save or putting in a bunch of // prettier-ignore comments is a workaround but not ideal.

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

Would prettier/prettier#2195 fit your needs? I won't duplicate a feature which may be in prettier ;-)

from prettier-vscode.

kengoldfarb avatar kengoldfarb commented on June 6, 2024

Yes, if they actually implement it. However, prettier/prettier#1428 and prettier/prettier#787 makes it look like it hasn't been a priority.

from prettier-vscode.

mgutz avatar mgutz commented on June 6, 2024

@CiGit Prettier raises an error when saving vscode's settings.json. See Microsoft/vscode#29701. Obviously it's not valid JSON since it has comments but it's how the configuration is. Would be nice to be able to ignore that file.

from prettier-vscode.

tereshhhchenko avatar tereshhhchenko commented on June 6, 2024

I have the same issue with webpack.config.js - I don't want to run prettier for this file.
I tried to add webpack.config.js in .eslitignore and in eslintIgnore in package.json.
No luck.

It would be nice if Prettier could take .eslitignore into account.

I also tried to use overrides

{
"overrides": [{
    "files": ["webpack.config.js"],
    "rules": {
      "comma-dangle": ["error", "never"]
    }
  }]
}

But it didn't work for me: both prettier and eslint plugin for vscode ignore that.

Am I doing smth wrong?

from prettier-vscode.

tereshhhchenko avatar tereshhhchenko commented on June 6, 2024

My project's simplified structure:

[dev]
[test]
webpack.config.js
.eslintrc

What I ended up is to move my eslint config into a folder and create multiple .eslintrc files that extend from base config.

[eslint-config]
    .eslintrc  // Actual configuration
[dev]
    .eslintrc 
        { "extends": "../eslint-config/.eslintrc" }
[test]
    .eslintrc 
        { "extends": "../eslint-config/.eslintrc" }
webpack.config.js
.eslintrc
     { "extends": "./eslint-config/.eslintrc",  "rules": {  "comma-dangle": ["error", "never"] } }

Not clean enough, but at least works.

from prettier-vscode.

ButuzGOL avatar ButuzGOL commented on June 6, 2024

vote for this feature because i have three projects in one env and only one is using Prettier and it makes big pain to enable/disable formatOnSave

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

Will a .prettierignore fit your needs?
prettier/prettier#2412

from prettier-vscode.

ButuzGOL avatar ButuzGOL commented on June 6, 2024

yes but as understand this feature is not released yet

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

Not yet, maybe in next prettier release (it has been merged) :-)
While we are at it:

  • Prevent formatting only on formatOnSave
  • Prevent formatting always (formatOnSave, User wants to format)

Arguments so far:

Prevent on save

@azz

Its bad UX to format something on save that should be formatted. When it is an explicit action (like alt-shift-f) the UX is ok.

Certainly was should NOT be formatted

Prevent always

@CiGit

If you ignore it, means you don't want it to be formatted, ever. We will prevent a mistake.

Side note

This is not an argument but we can't implement to prevent only on save without changing the complete architecture. VSCode's API doesn't give us any reason on why format was called (maybe I've not found)

from prettier-vscode.

azz avatar azz commented on June 6, 2024

To be clear, I wasn't arguing for prevent only on save, I was explaining why it is something people will tend to expect from the extension.

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

@azz Got it :-) and you are right.
In the end it will still do something: Log a message (in any case).

from prettier-vscode.

CiGit avatar CiGit commented on June 6, 2024

We still have to do it. @joaovieira volunteer ? 😃 #198

from prettier-vscode.

jantimon avatar jantimon commented on June 6, 2024

Could we just ignore all files from .gitignore? (might be a setting)

from prettier-vscode.

github-actions avatar github-actions commented on June 6, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from prettier-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.