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

Add regexp/letter-case/unicorn/escape-case conflict resolution to the doc #743

Open
yvele opened this issue May 23, 2024 · 2 comments
Open
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@yvele
Copy link

yvele commented May 23, 2024

Information:

  • ESLint version: 8.57.0
  • eslint-plugin-regexp version: 2.6.0

Description

With this rule elabled:

"regexp/letter-case" : "error"

The following code:

const REG = /\u036F/;

is reported as error:

error '\u036F' is not in lowercase regexp/letter-case

but should be automatically fixed to:

- const REG = /\u036F/;
+ const REG = /\u036f/;

Same problem with the u flag /\u036F/u

Note that the rule doc specifies that:

🔧 This rule is automatically fixable by the --fix CLI option.

@yvele yvele changed the title Rule letter-case does not fix unicodeEscape regexp/letter-case does not fix unicodeEscape May 23, 2024
@yvele
Copy link
Author

yvele commented May 23, 2024

Ok I find out that there is a conflict between the regexp/letter-case default options: https://ota-meshi.github.io/eslint-plugin-regexp/rules/letter-case.html#options

{
  "regexp/letter-case": ["error", {
    "unicodeEscape": "lowercase"
  }]
}

And the recommended unicorn/escape-case rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/escape-case.md

Enforces defining escape sequence values with uppercase characters rather than lowercase ones. This promotes readability by making the escaped value more distinguishable from the identifier.

As an example let's see how core-js is doing: https://github.com/zloirock/core-js/blob/f1303f38bd80474f950cadb3e802db1c2618a2c5/tests/eslint/eslint.config.js#L705-L707C21

  // require escape sequences to use uppercase values
  'unicorn/escape-case': ERROR,

  'regexp/letter-case': [ERROR, {
    caseInsensitive: 'lowercase',
    unicodeEscape: 'uppercase',
  }],

Maybe we could explain that conflict in the doc? Because eslint-plugin-unicorn is super widely used.

@yvele yvele changed the title regexp/letter-case does not fix unicodeEscape Add regexp/letter-case/unicorn/escape-case conflict resolution to the doc May 23, 2024
@ota-meshi
Copy link
Owner

I welcome pull requests to add notes.

@ota-meshi ota-meshi added documentation Improvements or additions to documentation help wanted Extra attention is needed labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants