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

Update rule define-macros-order for custom macros #2501

Merged
merged 9 commits into from
Sep 2, 2024

Conversation

Ericlm
Copy link
Contributor

@Ericlm Ericlm commented Jul 8, 2024

⚠️ Newbie alert ⚠️
This is my very first contribution to this project so I hope I did the things well; but don't hesitate to tell me what is not right. 😄

This PR adds the ability to use the define macro order rule for any macro specified in the order array. This allows users to specify definePage for example or any macro wanted.

Basically, I added a CallExpression that checks whether the Identifier is included into the order array but not in the ORDER_SCHEMA as this is already checked with earlier events (onDefineExposeExit etc.)
I removed the enum from the properties of the rule as it's no longer limited to ORDER_SCHEMA. And finally, I've added new tests.

I also have some questions:

  • If defineExpose is declared inside the order, I guess it should be ignored? Otherwise it would conflict with defineExposeLast I guess.
  • Maybe the check could be more performant if there was no check against ORDER_SCHEMA in the condition? (removing the callbacks and the call to has()).

See #2499

@FloEdelmann FloEdelmann linked an issue Jul 9, 2024 that may be closed by this pull request
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.

If defineExpose is declared inside the order, I guess it should be ignored? Otherwise it would conflict with defineExposeLast I guess.

Yeah, it would conflict. However, it's better to not fail silently, but to validate the options: If defineExposeLast is true and defineExpose is declared inside the order, throw an error.

Anyway, thanks for picking this up so fast!

docs/rules/define-macros-order.md Outdated Show resolved Hide resolved
lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tests/lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
@Ericlm Ericlm requested a review from FloEdelmann July 9, 2024 13:26
lib/rules/define-macros-order.js Outdated Show resolved Hide resolved
docs/rules/define-macros-order.md Outdated Show resolved Hide resolved
lib/rules/define-macros-order.js Show resolved Hide resolved
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.

Looks good to me now. Thank you for your first contribution!

@Ericlm
Copy link
Contributor Author

Ericlm commented Jul 9, 2024

You're welcome! Really happy to add this 😁

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! Thank you!

@ota-meshi ota-meshi merged commit 6ebd607 into vuejs:master Sep 2, 2024
10 checks passed
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.

Allow specifying custom macros in vue/define-macros-order
3 participants