-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lint): remove unneeded parentheses around expressions
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing no-extra-parens rule with a help or a custom rule output filter.
- Loading branch information
Showing
52 changed files
with
183 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
rules: { | ||
'no-extra-parens': require('./no-extra-parens-rule'), | ||
}, | ||
configs: { | ||
recommended: { | ||
plugins: [ | ||
'@internal/eslint-plugin', | ||
], | ||
rules: { | ||
// https://github.com/eslint/eslint/issues/16626 | ||
// https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/errors.js#L66 | ||
'@internal/no-extra-parens': ['error', 'all', { | ||
conditionalAssign: true, | ||
enforceForArrowConditionals: false, | ||
ignoreJSX: 'all', | ||
nestedBinaryExpressions: false, | ||
returnAssign: false, | ||
}], | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const eslint = require('eslint'); | ||
const ruleComposer = require('eslint-rule-composer'); | ||
|
||
const rule = new eslint.Linter().getRules().get('no-extra-parens'); | ||
|
||
module.exports = ruleComposer.filterReports( | ||
rule, | ||
(problem) => { | ||
if (problem.node.type === 'ConditionalExpression' | ||
&& (problem.node.parent.type === 'ConditionalExpression' || problem.node.parent.type === 'SpreadElement') | ||
) { | ||
return false; | ||
} | ||
|
||
return problem; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@internal/eslint-plugin", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"eslint-rule-composer": "^0.3.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.