Add `regexp/letter-case`/`unicorn/escape-case` conflict resolution to the doc
yvele opened this issue · comments
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.
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.
I welcome pull requests to add notes.