-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Remove no-confusing-arrow
because of the deprecation of formatting rules
#276
Conversation
…rules First, this rule was deprecated in ESLint v8.53.0. The alternative is the third-party plugin `@stylistic/eslint-plugin-js`. Second, I sometimes feel annoying on this rule. For example, see: ```js const result = () => (type === 'foo' ? foo() : bar()); /* ^^ Arrow function used ambiguously with a conditional expression [no-confusing-arrow] */ ``` In this case, I think it's enough readable, thanks to `()` around the function body. So, I think this rule is no longer necessary in this shared config. Ref: - https://eslint.org/docs/latest/rules/no-confusing-arrow - https://eslint.org/blog/2023/10/deprecating-formatting-rules - https://eslint.style/packages/js
My problem is that it conflicts with prettier.
There's an option for that: |
@Mouvedia Can you tell me how to reproduce the conflict with Prettier? |
Try
It will be reformatted. |
@Mouvedia Sorry, I didn't understand what you meant. The example code you posted is a problem of Prettier, not |
If you were using |
Ah, I now understand. Assuming the following example: /*eslint-disable no-unused-vars, no-undef*/
/*eslint no-confusing-arrow: ["error", {"allowParens": true}]*/
const fix = () =>
(messageType === 'expected' ? fontFamilyNode.addQuotes() : fontFamilyNode.removeQuotes()); Prettier removes const fix = () =>
- (messageType === 'expected' ? fontFamilyNode.addQuotes() : fontFamilyNode.removeQuotes());
+ messageType === 'expected' ? fontFamilyNode.addQuotes() : fontFamilyNode.removeQuotes(); Then, ESLint emits an error: const fix = () =>
/* ^^ Arrow function used ambiguously with a conditional expression */
messageType === 'expected' ? fontFamilyNode.addQuotes() : fontFamilyNode.removeQuotes(); By the way, if an arrow function is within a single line, Prettier doesn't format the code: const fix2 = () => (type === 'expected' ? addQuotes() : removeQuotes()); In summary, I think removing |
Good to know. |
I'm merging this PR since there are no objections. |
None.
First, this rule was deprecated in ESLint v8.53.0. The alternative is the third-party plugin
@stylistic/eslint-plugin-js
.Second, I sometimes feel annoyed by this rule. For example, see:
In this case, I think it's readable enough, thanks to
()
around the function body.So, I think this rule is no longer necessary for this shared config.
Ref:
Note
This rule was added in #74.