-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: singularize variable name in autofix for prefer-array-find rule
- Loading branch information
Showing
5 changed files
with
91 additions
and
15 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
/** | ||
Gather a list of all Scopes starting recursively from the input Scope. | ||
@param {Scope} scope - The Scope to start checking from. | ||
@returns {Scope[]} - The resulting Scopes. | ||
*/ | ||
const getChildScopesRecursive = scope => [ | ||
scope, | ||
...scope.childScopes.flatMap(scope => getChildScopesRecursive(scope)) | ||
]; | ||
|
||
module.exports = getChildScopesRecursive; |
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,18 @@ | ||
'use strict'; | ||
|
||
const {singular: pluralizeSingular} = require('pluralize'); | ||
|
||
/** | ||
Singularizes a word/name, i.e. `items` to `item`. | ||
@param {string} original - The word/name to singularize. | ||
@returns {string|undefined} - The singularized result, or `undefined` if attempting singularization resulted in no change. | ||
*/ | ||
const singular = original => { | ||
const singularized = pluralizeSingular(original); | ||
if (singularized !== original) { | ||
return singularized; | ||
} | ||
}; | ||
|
||
module.exports = singular; |
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