Comments (26)
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.
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.
Any movement on this issue lately? It'd be a really helpful feature to have.
from prettier-vscode.
Can't wait for this. Tired of unnecessary git diffs in package.json
as npm
also formats it on each install.
from prettier-vscode.
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.
This would be a great feature. Why would we want to prettify anything in .gitignore - especially node_modules?
from prettier-vscode.
Seems like a good idea to me. Would you dare to take a crack at a PR?
from prettier-vscode.
yea sure, i'll try to get to it this week :)
from prettier-vscode.
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.
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.
What's your use case ?
- Ignore files completely
- Having different config per language
- Having different config per files (same language)
- Other?
from prettier-vscode.
@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.
Would prettier/prettier#2195 fit your needs? I won't duplicate a feature which may be in prettier ;-)
from prettier-vscode.
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.
@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.
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.
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.
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.
Will a .prettierignore
fit your needs?
prettier/prettier#2412
from prettier-vscode.
yes but as understand this feature is not released yet
from prettier-vscode.
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
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
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.
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.
@azz Got it :-) and you are right.
In the end it will still do something: Log a message (in any case).
from prettier-vscode.
We still have to do it. @joaovieira volunteer ? 😃 #198
from prettier-vscode.
Could we just ignore all files from .gitignore
? (might be a setting)
from prettier-vscode.
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)
- Editor scrolls to bottom when format large file using prettier HOT 4
- Extension only looks for .gitignore or .prettierignore when using Prettier v3, does not allow both HOT 1
- Use LanguageStatusItem API for the status bar item HOT 1
- prettier bug in Vue
- Prettier extension deletes line of code after pasting
- icons
- Prettier doesn't appear in the list of formatters HOT 5
- Installed Prettier extension does not format and gives following error: Cannot find module 'prettier' HOT 1
- `prettier-vscode` doesn't respond to changes in `prettier.config.mjs` until the workspace reloads HOT 4
- Cannot use any prettier plugins with `yarn 4 + PnP`
- Do not put css comments on new line HOT 1
- I have done all kinds of things but my prettier does not format on save. HOT 1
- I need to completely uninstall prettier an reinstall it. HOT 1
- Title: Feature Request: Improved Support for C Language in Prettier Extension
- Prettier does not format in multi-folder repositories whilst using the .code-workspace config. HOT 1
- Use NODE_COMPILE_CACHE when detecting node v22+
- Extension causes high cpu load
- experimentalTernaries not respected using prettier-vscode plugin HOT 1
- When I set Prettier: Single Attribute Per Line, the css style in the <style> tag of the vue file was invalid.
- in bash file a piece of code is treated like a comment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-vscode.