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
Request: Override rules in file #1154
Comments
We're having the same problem at fb. |
Dupe of #98? But glad this is getting some fresh exposure. |
Further discussion: #62 |
I recently bumped into this too. I solved it by running prettier through ESLint using eslint-plugin-prettier. .eslintrc.js: module.exports = {
// ...
rules: {
// ...
"prettier/prettier": ["error", { trailingComma: "es5" }],
},
}; frontend/.eslintrc.js: const parentConfig = require("../.eslintrc");
const parentPrettierOptions = parentConfig.rules["prettier/prettier"][1];
module.exports = {
// ...
rules: {
// ...
"prettier/prettier": [
"error",
Object.assign({}, parentPrettierOptions, { trailingComma: "all" })
],
},
}; So in case you need something now the above is a potential solution :) |
node 8 is going to be released in 1.5 week and supports trailing commas for function calls. I think that we should get people to upgrade when it's ready rather than add complexity inside of prettier. |
@vjeux Not sure why this was closed. @blainekasten posted a specific example of why overrides are needed. Just because that particular issue is fixed doesn't remove the need for overrides in some form (beyond the paltry set of command line options that currently exist). |
If you have another use case for overrides, please create a different issue, and we can try to figure out a solution. I'm interested in solving the problems people have, not implementing whatever solution they think would solve their problem :) |
NVM, looks like, there are multiple ops open (and closed) proposing something similar, making a strong case, and giving other use cases, so this one can stay closed. |
There is a strong argument against this. And honestly I don't really want this. But there is a bit of an interop issue with certain rules in different environments.
Issue
Rule:
trailingComma: 'all'
This rule works great when your code is fed through Babel, but fails when executed directly. example:
Environments
This specifically happens to me because I write es6 code for the client, which is transpiled through Babel.
And then I write es6-ish code for node, which is not transpiled.
So therefore, when my editor automatically prettifies the node code, it breaks.
Solutions?
Easiest solution seems to be to have an eslint style comment in a file over-riding rules. Example:
// prettier-rule trailingComma=es5
I'm curious your thoughts on this, or if you have a better idea of how I can use prettier in different environments like this.
The text was updated successfully, but these errors were encountered: