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 onRegExpFlags to RegExpValidator.Options and deprecate onFlags #50

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi commented Jan 16, 2023

This PR deprecates onFlags in RegExpValidator.Options and adds onRegExpFlags option instead.

The current RegExpValidator.Options onFlags has too many arguments because it has as many arguments as the number of flags. (And we know that more flags will be added in the future. e.g. https://github.com/tc39/proposal-regexp-v-flag)
This has always been a warning to the ESLint we use.

/home/runner/work/regexpp/regexpp/src/parser.ts
Warning:   65:5  warning  Method 'onFlags' has too many parameters (9). Maximum allowed is 8  max-params

/home/runner/work/regexpp/regexpp/src/validator.ts
Warning:   602:5  warning  Method 'onFlags' has too many parameters (9). Maximum allowed is 8  max-params

So instead of giving each flag as multiple arguments, I think it's better to have a single object with the flags information.

However, changing onFlags would be a breaking change, so I think it makes sense to leave onFlags as a deprecated option and introduce a new onRegExpFlags. The name of onRegExpFlags was named with reference to RegularExpressionFlags used in ES specifications.

https://tc39.es/ecma262/#prod-RegularExpressionFlags

@ota-meshi ota-meshi requested a review from a team January 16, 2023 03:36
src/validator.ts Outdated Show resolved Hide resolved
src/validator.ts Outdated Show resolved Hide resolved
Co-authored-by: Michaël De Boey <[email protected]>
@MichaelDeBoey MichaelDeBoey merged commit 999b69a into main Jan 17, 2023
@MichaelDeBoey MichaelDeBoey deleted the add-onRegExpFlags branch January 17, 2023 00:26
@github-actions
Copy link

🎉 This PR is included in version 4.3.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.

2 participants