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

feat: add no-global-regex-flag-in-query rule #560

Merged
merged 7 commits into from
Mar 31, 2022

Conversation

timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Mar 29, 2022

Checks

  • I have read the contributing guidelines.
  • If some rule is added/updated/removed, I've regenerated the rules list.
  • If some rule meta info is changed, I've regenerated the plugin shared configs.

Changes

  • adds the new rule no-global-regex-flag-in-query

Context

Resolves #559

It's been a long time since I've contributed, feel free to comment on this PR :)

@MichaelDeBoey MichaelDeBoey changed the title feat: add no-global-regex-flag-in-query feat: add no-global-regex-flag-in-query rule Mar 29, 2022
MichaelDeBoey
MichaelDeBoey previously approved these changes Mar 29, 2022
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

@timdeschryver Thanks for implementing this so quickly! I added a couple of comments and asked for some small changes, but should be easy to address.

lib/rules/no-global-regexp-flag-in-query.ts Outdated Show resolved Hide resolved
lib/node-utils/is-node-of-type.ts Outdated Show resolved Hide resolved
lib/rules/no-global-regexp-flag-in-query.ts Outdated Show resolved Hide resolved
tests/lib/rules/no-global-regexp-flag-in-query.test.ts Outdated Show resolved Hide resolved
tests/lib/rules/no-global-regexp-flag-in-query.test.ts Outdated Show resolved Hide resolved
@timdeschryver
Copy link
Member Author

@Belco90 and @MichaelDeBoey thanks for quick review.
I'll address these points tomorrow.
I also was thinking about a fixer that removes the regexp, thoughts?

@Belco90
Copy link
Member

Belco90 commented Mar 30, 2022

I also was thinking about a fixer that removes the regexp, thoughts?

I'd love to have the autofix, and should be fairly simple. However, I didn't want to request including this feature to merge this PR, so I'm happy about merging this one first and then add the autofix in a later PR if that's more convenient to you.

README.md Outdated Show resolved Hide resolved
Copy link
Member Author

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

@Belco90 the last commit refactors the implementation with getDeepestIdentifierNode. It does seem more robust to me, let me know what you think :)

Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

@timdeschryver Much better now, including the autofix function!

Just a couple of small tweaks and should be ready to go.

lib/rules/no-global-regexp-flag-in-query.ts Outdated Show resolved Hide resolved
lib/rules/no-global-regexp-flag-in-query.ts Outdated Show resolved Hide resolved
tests/lib/rules/no-global-regexp-flag-in-query.test.ts Outdated Show resolved Hide resolved
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

This LGTM!

@Belco90 Belco90 merged commit 6e645e6 into main Mar 31, 2022
@Belco90 Belco90 deleted the no-global-regex-flag-in-query branch March 31, 2022 10:16
@github-actions
Copy link

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New rule: no-global-regex-flag-to-query
3 participants