-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
prettier conflicts with no-unexpected-multiline #32
Comments
I did see the previous discussion. W.r.t this particular rule, the plan was to revisit it in the future if the need were to arise. Indeed, turning off the rule works but I am proposing that |
Sorry, I meant "one way is to include this rule in this config to be always turned off". I'm just worried that turning this rule off means people will miss out on ESLint helping them find semicolon mistakes. Perhaps this should be one of the "special rules". I use this rule myself, and have never encountered conflicts with Prettier so far, but it does depend on how you write your code. My point is that this issue needs a little experimentation and thinking about. |
I've now come to the conclusion that we should add the rule as a special rule. |
Ok @lydell, I'd like to work on this. But I might need some help with updating the readme though. |
You can make a PR if you want and I can help getting it across the finish line. |
Released in 2.7.0. |
I am not sure if I run ESLint before Prettier with this config (Prettier as ESLint plugin) and thus can turn {
"extends": [
"airbnb-base",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"no-unexpected-multiline": "error"
},
"plugins": [
"prettier"
]
}
|
@andreyvolokitin With that config Prettier essentially runs at the same time as ESLint, unless you use the |
As a solution you can use |
I have this error, however after disabling no-unexpected-multiline, the next prettier run reformats the code such that the error comes back: };
};
})
- // eslint-disable-next-line no-unexpected-multiline
- ["catch"](function(error) {
+ [
+ // eslint-disable-next-line no-unexpected-multiline
+ "catch"
+ ](function(error) {
console.error("Error during service worker registration:", error);
});
} |
@mbrookes Ah, that’s unfortunate that Prettier moves the comment in that scenario. There are a couple of ways to go:
|
## Summary - Create a new package in `packages/eslint-config-calcite` that contains shared ESLint configurations for importing in other packages. - Setup the components and design-tokens packages to use the new shared ESLint configs. - Add typescript-eslint coverage to our github scripts - Check css files in lint-staged (previously it was only scss) - Disable [`no-unexpected-newline`](https://archive.eslint.org/docs/6.0.0/rules/no-unexpected-multiline), which [conflicts with prettier](prettier/eslint-config-prettier#32) - Various other cleanup, such as formatting json files in `.vscode/` and removing cspell ignore comments in favor of dictionary additions.. - Run `npm run lint` so unrelated changes don't appear in subsequent PRs
## Summary - Create a new package in `packages/eslint-config-calcite` that contains shared ESLint configurations for importing in other packages. - Setup the components and design-tokens packages to use the new shared ESLint configs. - Add typescript-eslint coverage to our github scripts - Check css files in lint-staged (previously it was only scss) - Disable [`no-unexpected-newline`](https://archive.eslint.org/docs/6.0.0/rules/no-unexpected-multiline), which [conflicts with prettier](prettier/eslint-config-prettier#32) - Various other cleanup, such as formatting json files in `.vscode/` and removing cspell ignore comments in favor of dictionary additions.. - Run `npm run lint` so unrelated changes don't appear in subsequent PRs
This scenario is relevant when a shareable config like
airbnb-base
is combined withprettier
. If the ruleno-unexpected-multiline
is enabled, it ends up resulting in a error which can only be resolved by switching off the rule..eslintrc.yml
code snippet
Eslint output:
If I fix the errors:
The text was updated successfully, but these errors were encountered: