Rule proposal: fix trailing underscore
#599 opened on Mar 12, 2020
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
Description
Currently catch-error-name and prevent-abbreviations auto-fix may add _ to variables, like error_ to avoid syntax error. Main purpose of this rule is to remove unnessassary trailing underscore.
Run prevent-abbreviations against this code
const cur = 1;
const curr = 2;
const current = 3;
will fix to
const current_ = 1;
const current__ = 2;
const current = 3;
Someday, we decide not to use current anymore, so the tailing underscore of current_ and current__ become weird, we can have a rule to reorganize them.
Fail
const foo_ = 1;
const foo = 1;
const foo__ = 1;
Pass
const foo = 1;
const foo = 1;
const foo_ = 1;
Additionally maybe we can also fix trailing numbers, like
const array2 = [];
const array4 = [];
Should be
const array = [];
const array2 = [];
I don't have any idea about name of this rule, if it only work on _, we can have a funny name, because this rule should not disabled by anyone.