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
prefer-string-starts-ends-with
: Fix missing parentheses for some cases
#976
prefer-string-starts-ends-with
: Fix missing parentheses for some cases
#976
Conversation
1194a0f
to
1011896
Compare
35b9e29
to
5b3df26
Compare
5b3df26
to
b27b35c
Compare
2cc4b85
to
bc58ccd
Compare
d3a7065
to
f0bf5d6
Compare
rules/utils/need-add-parentheses-to-member-expression-object.js
Outdated
Show resolved
Hide resolved
rules/utils/need-add-parentheses-to-member-expression-object.js
Outdated
Show resolved
Hide resolved
|
||
case 'Literal': { | ||
/* istanbul ignore next */ | ||
if (typeof node.value === 'number' && /^\d+$/.test(node.raw)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this fail on 1.1
or 1e+2
and more? If this is intentional, it would be good with a code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, 1.1.toString();
an 2e+2.toString();
are valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a better one in eslint core, https://github.com/eslint/eslint/blob/cc4871369645c3409dc56ded7a555af8a9f63d51/lib/rules/no-extra-parens.js#L1011, I didn't consider numberic seperators.
no-extra-parens
rule use the same pattern in initial commit. 😄
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1c061de
to
5b524af
Compare
Noticed this bug during #970
is fixed to
Should be
I didn't add to many cases in
needAddParenthesesToMemberExpressionObject
, for now, only some nodes can bestring
. I believe there are other rules need this, we'll add more when we need.