Skip to content

Change default configuration of prefer-d #712

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
RunDevelopment opened this issue Mar 22, 2024 · 1 comment · Fixed by #715
Closed

Change default configuration of prefer-d #712

RunDevelopment opened this issue Mar 22, 2024 · 1 comment · Fixed by #715

Comments

@RunDevelopment
Copy link
Collaborator

I just added eslint-plugin-regexp to a code base with some regexes and the prefer-d rule wanted to replace all character classes like this [0-9a-f] with this [\da-f]. While I think that prefer-d has a place in our recommended config, but I think it's too aggressive by default. [0-9a-f] -> [\da-f] is a minor stylistic change to enforce consistency, but it will increase the diff for existing code bases and it won't improve the readability. Since 0-9 is relatively common from what I've seen, prefer-d currently causes a lot of noise for little gain.

So I think it might be a good idea to change the default configuration of prefer-d from insideCharacterClass: "d" to insideCharacterClass: "ignore". This would still transform [0-9] -> \d but it will leave [0-9a-f] and [\da-f] as is.

With this change, prefer-d will report strictly fewer errors, so this is a minor change according to ESLint's semver policy.

What do you think @ota-meshi?

@ota-meshi
Copy link
Owner

Sounds good to me!

With this change, prefer-d will report strictly fewer errors, so this is a minor change according to ESLint's semver policy.

Yeah, I think we can do it in a minor version 👍

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

Successfully merging a pull request may close this issue.

2 participants