Skip to content
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

Improve auto-fix for vue/define-macros-order rule #1863

Merged
merged 3 commits into from May 14, 2022

Conversation

edikdeisling
Copy link
Contributor

@edikdeisling edikdeisling commented Apr 22, 2022

In PR #1861 was decided to create separate PR for these improvements

There are two fixes here:

  1. Fix extra newlines appear
  2. Fix corner case a();b() -> b()a();

@@ -232,13 +232,12 @@ function create(context) {
const targetComment = sourceCode.getTokenAfter(beforeTargetToken, {
includeComments: true
})
const textSpace = getTextBetweenTokens(beforeTargetToken, targetComment)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing fixes these newlines https://github.com/vuejs/eslint-plugin-vue/pull/1861/files#diff-6ebdd3c21be70e29ce94a2f399884fd220d4fe9bba358ade66b0bceb325d3102L158

Before we took space before the target token and added it after the moving token.
Now we take space after the target token and added it after the moving token.

@edikdeisling
Copy link
Contributor Author

edikdeisling commented Apr 22, 2022

I ran it in my project and the result was great. The only annoying thing left is this:
image
There is an option to introduce "newLineAfterDefineMacros: true" option maybe... For now, I've done nothing

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@FloEdelmann FloEdelmann changed the title vue/define-macros-order improvements Improve auto-fix for vue/define-macros-order rule May 13, 2022
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ota-meshi
Copy link
Member

There is an option to introduce "newLineAfterDefineMacros: true" option maybe... For now, I've done nothing

I think we shouldn't add options for auto-fix. Because the aims of the rule is to check.

@ota-meshi ota-meshi merged commit b0639d7 into vuejs:master May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants