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
Update: Add a fixer for dot-location
#7186
Conversation
@not-an-aardvark, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @gcochard and @pedrottimark to be potential reviewers |
LGTM |
I think fixable: code is correct since you are not just adding or removing whitespace, but tokens as well. |
There's currently no functional difference between |
We've used |
The reasoning in this case would be that we're not actually changing any tokens, either; we're basically changing the amount of whitespace that appears before and after the dot. (That said, we are also moving comments around, so it's not just whitespace.) |
Thank you for this PR! I will be a champion for this change.
By the way, |
|
||
if (dot.type === "Punctuator" && dot.value === ".") { | ||
if (onObject) { | ||
if (!astUtils.isTokenOnSameLine(obj, dot)) { | ||
context.report(node, dot.loc.start, "Expected dot to be on same line as object."); | ||
const neededTextAfterObj = obj.type === "Literal" && typeof obj.value === "number" && /^\d*$/.test(obj.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.
A memo for me: /^\d*$/
will be replaced by astUtils.isDecimalInteger
after #7185 is merged.
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.
#7185 is merged now, so I rebased and switched to astUtils.isDecimalInteger
.
aabfe62
to
8dcaa5e
Compare
LGTM |
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.
LGTM.
@eslint/eslint-team Looks like we need one more supporter.
I'll support this! 👍 |
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.
LGTM
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[x] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
Please check each item to ensure your pull request is ready:
What changes did you make? (Give an overview)
This adds an autofixer for
dot-location
.Given a
MemberExpression
where the dot is in the wrong location, the fixer will move the dot to the correct location. All comments between the object and the property are preserved.Is there anything you'd like reviewers to focus on?
I marked this as
fixable: "code"
, but should it befixable: "whitespace"
instead since it doesn't change the AST?