Skip to content

Commit

Permalink
Change config and default
Browse files Browse the repository at this point in the history
- Change `plugin:regexp/recommended` config
  - Add `regexp/confusing-quantifier` rule.
  - Add `regexp/negation` rule.
  - Add `regexp/no-dupe-disjunctions` rule.
  - Add `regexp/no-empty-alternative` rule.
  - Add `regexp/no-lazy-ends` rule.
  - Add `regexp/no-legacy-features` rule.
  - Add `regexp/no-unused-capturing-group` rule.
  - Add `regexp/no-useless-character-class` rule.
  - Add `regexp/no-useless-dollar-replacements` rule.
  - Add `regexp/no-useless-escape` rule.
  - Add `regexp/no-useless-non-capturing-group` rule.
  - Add `regexp/no-useless-range` rule.
  - Add `regexp/optimal-lookaround-quantifier` rule.
  - Add `regexp/prefer-character-class` rule.
  - Add `regexp/prefer-range` rule.
  - Add `regexp/prefer-unicode-codepoint-escapes` rule.
  - Add `no-empty-character-class` rule.

- Change default option
  - Change `hexadecimalEscape` option of `regexp/letter-case` rule from `ignore` to `lowercase`.
  - Change `controlEscape` option of `regexp/letter-case` rule from `ignore` to `uppercase`.
  • Loading branch information
ota-meshi committed Apr 14, 2021
1 parent 63d5008 commit 9374ffe
Show file tree
Hide file tree
Showing 39 changed files with 107 additions and 99 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,45 +83,45 @@ The rules with the following star :star: are included in the `plugin:regexp/reco

| Rule ID | Description | |
|:--------|:------------|:---|
| [regexp/confusing-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/confusing-quantifier.html) | disallow confusing quantifiers | |
| [regexp/confusing-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/confusing-quantifier.html) | disallow confusing quantifiers | :star: |
| [regexp/letter-case](https://ota-meshi.github.io/eslint-plugin-regexp/rules/letter-case.html) | enforce into your favorite case | :wrench: |
| [regexp/match-any](https://ota-meshi.github.io/eslint-plugin-regexp/rules/match-any.html) | enforce match any character style | :star::wrench: |
| [regexp/negation](https://ota-meshi.github.io/eslint-plugin-regexp/rules/negation.html) | enforce use of escapes on negation | :wrench: |
| [regexp/negation](https://ota-meshi.github.io/eslint-plugin-regexp/rules/negation.html) | enforce use of escapes on negation | :star::wrench: |
| [regexp/no-assertion-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-assertion-capturing-group.html) | disallow capturing group that captures assertions. | :star: |
| [regexp/no-dupe-characters-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-dupe-characters-character-class.html) | disallow duplicate characters in the RegExp character class | :star: |
| [regexp/no-dupe-disjunctions](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-dupe-disjunctions.html) | disallow duplicate disjunctions | |
| [regexp/no-empty-alternative](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-alternative.html) | disallow alternatives without elements | |
| [regexp/no-dupe-disjunctions](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-dupe-disjunctions.html) | disallow duplicate disjunctions | :star: |
| [regexp/no-empty-alternative](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-alternative.html) | disallow alternatives without elements | :star: |
| [regexp/no-empty-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-group.html) | disallow empty group | :star: |
| [regexp/no-empty-lookarounds-assertion](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-lookarounds-assertion.html) | disallow empty lookahead assertion or empty lookbehind assertion | :star: |
| [regexp/no-escape-backspace](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-escape-backspace.html) | disallow escape backspace (`[\b]`) | :star: |
| [regexp/no-invisible-character](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-invisible-character.html) | disallow invisible raw character | :star::wrench: |
| [regexp/no-lazy-ends](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-lazy-ends.html) | disallow lazy quantifiers at the end of an expression | |
| [regexp/no-legacy-features](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-legacy-features.html) | disallow legacy RegExp features | |
| [regexp/no-lazy-ends](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-lazy-ends.html) | disallow lazy quantifiers at the end of an expression | :star: |
| [regexp/no-legacy-features](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-legacy-features.html) | disallow legacy RegExp features | :star: |
| [regexp/no-octal](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-octal.html) | disallow octal escape sequence | :star: |
| [regexp/no-unused-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-unused-capturing-group.html) | disallow unused capturing group | |
| [regexp/no-unused-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-unused-capturing-group.html) | disallow unused capturing group | :star: |
| [regexp/no-useless-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-backreference.html) | disallow useless backreferences in regular expressions | |
| [regexp/no-useless-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-character-class.html) | disallow character class with one character | :wrench: |
| [regexp/no-useless-dollar-replacements](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-dollar-replacements.html) | disallow useless `$` replacements in replacement string | |
| [regexp/no-useless-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-escape.html) | disallow unnecessary escape characters in RegExp | |
| [regexp/no-useless-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-character-class.html) | disallow character class with one character | :star::wrench: |
| [regexp/no-useless-dollar-replacements](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-dollar-replacements.html) | disallow useless `$` replacements in replacement string | :star: |
| [regexp/no-useless-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-escape.html) | disallow unnecessary escape characters in RegExp | :star: |
| [regexp/no-useless-exactly-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-exactly-quantifier.html) | disallow unnecessary exactly quantifier | :star: |
| [regexp/no-useless-non-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-non-capturing-group.html) | disallow unnecessary Non-capturing group | :wrench: |
| [regexp/no-useless-non-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-non-capturing-group.html) | disallow unnecessary Non-capturing group | :star::wrench: |
| [regexp/no-useless-non-greedy](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-non-greedy.html) | disallow unnecessary quantifier non-greedy (`?`) | :wrench: |
| [regexp/no-useless-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-range.html) | disallow unnecessary range of characters by using a hyphen | :wrench: |
| [regexp/no-useless-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-range.html) | disallow unnecessary range of characters by using a hyphen | :star::wrench: |
| [regexp/no-useless-two-nums-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-two-nums-quantifier.html) | disallow unnecessary `{n,m}` quantifier | :star::wrench: |
| [regexp/optimal-lookaround-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/optimal-lookaround-quantifier.html) | disallow the alternatives of lookarounds that end with a non-constant quantifier | |
| [regexp/optimal-lookaround-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/optimal-lookaround-quantifier.html) | disallow the alternatives of lookarounds that end with a non-constant quantifier | :star: |
| [regexp/order-in-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/order-in-character-class.html) | enforces elements order in character class | :wrench: |
| [regexp/prefer-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-character-class.html) | enforce using character class | :wrench: |
| [regexp/prefer-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-character-class.html) | enforce using character class | :star::wrench: |
| [regexp/prefer-d](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-d.html) | enforce using `\d` | :star::wrench: |
| [regexp/prefer-escape-replacement-dollar-char](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-escape-replacement-dollar-char.html) | enforces escape of replacement `$` character (`$$`). | |
| [regexp/prefer-plus-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-plus-quantifier.html) | enforce using `+` quantifier | :star::wrench: |
| [regexp/prefer-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-quantifier.html) | enforce using quantifier | :wrench: |
| [regexp/prefer-question-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-question-quantifier.html) | enforce using `?` quantifier | :star::wrench: |
| [regexp/prefer-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-range.html) | enforce using character class range | :wrench: |
| [regexp/prefer-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-range.html) | enforce using character class range | :star::wrench: |
| [regexp/prefer-regexp-exec](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-regexp-exec.html) | enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | |
| [regexp/prefer-regexp-test](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-regexp-test.html) | enforce that `RegExp#test` is used instead of `String#match` and `RegExp#exec` | :wrench: |
| [regexp/prefer-star-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-star-quantifier.html) | enforce using `*` quantifier | :star::wrench: |
| [regexp/prefer-t](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-t.html) | enforce using `\t` | :star::wrench: |
| [regexp/prefer-unicode-codepoint-escapes](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-unicode-codepoint-escapes.html) | enforce use of unicode codepoint escapes | :wrench: |
| [regexp/prefer-unicode-codepoint-escapes](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-unicode-codepoint-escapes.html) | enforce use of unicode codepoint escapes | :star::wrench: |
| [regexp/prefer-w](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-w.html) | enforce using `\w` | :star::wrench: |

<!--RULES_TABLE_END-->
Expand Down
32 changes: 16 additions & 16 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@ The rules with the following star :star: are included in the `plugin:regexp/reco

| Rule ID | Description | |
|:--------|:------------|:---|
| [regexp/confusing-quantifier](./confusing-quantifier.md) | disallow confusing quantifiers | |
| [regexp/confusing-quantifier](./confusing-quantifier.md) | disallow confusing quantifiers | :star: |
| [regexp/letter-case](./letter-case.md) | enforce into your favorite case | :wrench: |
| [regexp/match-any](./match-any.md) | enforce match any character style | :star::wrench: |
| [regexp/negation](./negation.md) | enforce use of escapes on negation | :wrench: |
| [regexp/negation](./negation.md) | enforce use of escapes on negation | :star::wrench: |
| [regexp/no-assertion-capturing-group](./no-assertion-capturing-group.md) | disallow capturing group that captures assertions. | :star: |
| [regexp/no-dupe-characters-character-class](./no-dupe-characters-character-class.md) | disallow duplicate characters in the RegExp character class | :star: |
| [regexp/no-dupe-disjunctions](./no-dupe-disjunctions.md) | disallow duplicate disjunctions | |
| [regexp/no-empty-alternative](./no-empty-alternative.md) | disallow alternatives without elements | |
| [regexp/no-dupe-disjunctions](./no-dupe-disjunctions.md) | disallow duplicate disjunctions | :star: |
| [regexp/no-empty-alternative](./no-empty-alternative.md) | disallow alternatives without elements | :star: |
| [regexp/no-empty-group](./no-empty-group.md) | disallow empty group | :star: |
| [regexp/no-empty-lookarounds-assertion](./no-empty-lookarounds-assertion.md) | disallow empty lookahead assertion or empty lookbehind assertion | :star: |
| [regexp/no-escape-backspace](./no-escape-backspace.md) | disallow escape backspace (`[\b]`) | :star: |
| [regexp/no-invisible-character](./no-invisible-character.md) | disallow invisible raw character | :star::wrench: |
| [regexp/no-lazy-ends](./no-lazy-ends.md) | disallow lazy quantifiers at the end of an expression | |
| [regexp/no-legacy-features](./no-legacy-features.md) | disallow legacy RegExp features | |
| [regexp/no-lazy-ends](./no-lazy-ends.md) | disallow lazy quantifiers at the end of an expression | :star: |
| [regexp/no-legacy-features](./no-legacy-features.md) | disallow legacy RegExp features | :star: |
| [regexp/no-octal](./no-octal.md) | disallow octal escape sequence | :star: |
| [regexp/no-unused-capturing-group](./no-unused-capturing-group.md) | disallow unused capturing group | |
| [regexp/no-unused-capturing-group](./no-unused-capturing-group.md) | disallow unused capturing group | :star: |
| [regexp/no-useless-backreference](./no-useless-backreference.md) | disallow useless backreferences in regular expressions | |
| [regexp/no-useless-character-class](./no-useless-character-class.md) | disallow character class with one character | :wrench: |
| [regexp/no-useless-dollar-replacements](./no-useless-dollar-replacements.md) | disallow useless `$` replacements in replacement string | |
| [regexp/no-useless-escape](./no-useless-escape.md) | disallow unnecessary escape characters in RegExp | |
| [regexp/no-useless-character-class](./no-useless-character-class.md) | disallow character class with one character | :star::wrench: |
| [regexp/no-useless-dollar-replacements](./no-useless-dollar-replacements.md) | disallow useless `$` replacements in replacement string | :star: |
| [regexp/no-useless-escape](./no-useless-escape.md) | disallow unnecessary escape characters in RegExp | :star: |
| [regexp/no-useless-exactly-quantifier](./no-useless-exactly-quantifier.md) | disallow unnecessary exactly quantifier | :star: |
| [regexp/no-useless-non-capturing-group](./no-useless-non-capturing-group.md) | disallow unnecessary Non-capturing group | :wrench: |
| [regexp/no-useless-non-capturing-group](./no-useless-non-capturing-group.md) | disallow unnecessary Non-capturing group | :star::wrench: |
| [regexp/no-useless-non-greedy](./no-useless-non-greedy.md) | disallow unnecessary quantifier non-greedy (`?`) | :wrench: |
| [regexp/no-useless-range](./no-useless-range.md) | disallow unnecessary range of characters by using a hyphen | :wrench: |
| [regexp/no-useless-range](./no-useless-range.md) | disallow unnecessary range of characters by using a hyphen | :star::wrench: |
| [regexp/no-useless-two-nums-quantifier](./no-useless-two-nums-quantifier.md) | disallow unnecessary `{n,m}` quantifier | :star::wrench: |
| [regexp/optimal-lookaround-quantifier](./optimal-lookaround-quantifier.md) | disallow the alternatives of lookarounds that end with a non-constant quantifier | |
| [regexp/optimal-lookaround-quantifier](./optimal-lookaround-quantifier.md) | disallow the alternatives of lookarounds that end with a non-constant quantifier | :star: |
| [regexp/order-in-character-class](./order-in-character-class.md) | enforces elements order in character class | :wrench: |
| [regexp/prefer-character-class](./prefer-character-class.md) | enforce using character class | :wrench: |
| [regexp/prefer-character-class](./prefer-character-class.md) | enforce using character class | :star::wrench: |
| [regexp/prefer-d](./prefer-d.md) | enforce using `\d` | :star::wrench: |
| [regexp/prefer-escape-replacement-dollar-char](./prefer-escape-replacement-dollar-char.md) | enforces escape of replacement `$` character (`$$`). | |
| [regexp/prefer-plus-quantifier](./prefer-plus-quantifier.md) | enforce using `+` quantifier | :star::wrench: |
| [regexp/prefer-quantifier](./prefer-quantifier.md) | enforce using quantifier | :wrench: |
| [regexp/prefer-question-quantifier](./prefer-question-quantifier.md) | enforce using `?` quantifier | :star::wrench: |
| [regexp/prefer-range](./prefer-range.md) | enforce using character class range | :wrench: |
| [regexp/prefer-range](./prefer-range.md) | enforce using character class range | :star::wrench: |
| [regexp/prefer-regexp-exec](./prefer-regexp-exec.md) | enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | |
| [regexp/prefer-regexp-test](./prefer-regexp-test.md) | enforce that `RegExp#test` is used instead of `String#match` and `RegExp#exec` | :wrench: |
| [regexp/prefer-star-quantifier](./prefer-star-quantifier.md) | enforce using `*` quantifier | :star::wrench: |
| [regexp/prefer-t](./prefer-t.md) | enforce using `\t` | :star::wrench: |
| [regexp/prefer-unicode-codepoint-escapes](./prefer-unicode-codepoint-escapes.md) | enforce use of unicode codepoint escapes | :wrench: |
| [regexp/prefer-unicode-codepoint-escapes](./prefer-unicode-codepoint-escapes.md) | enforce use of unicode codepoint escapes | :star::wrench: |
| [regexp/prefer-w](./prefer-w.md) | enforce using `\w` | :star::wrench: |
2 changes: 2 additions & 0 deletions docs/rules/confusing-quantifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.8.0"

> disallow confusing quantifiers
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

Confusing quantifiers are ones which imply one thing but don't deliver on that.
Expand Down
10 changes: 4 additions & 6 deletions docs/rules/letter-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var foo = /\ca/
"regexp/letter-case": ["error", {
"caseInsensitive": "lowercase", // or "uppercase" or "ignore"
"unicodeEscape": "lowercase", // or "uppercase" or "ignore"
"hexadecimalEscape": "ignore", // or "lowercase" or "uppercase"
"controlEscape": "ignore", // or "lowercase" or "uppercase"
"hexadecimalEscape": "lowercase", // or "uppercase" or "ignore"
"controlEscape": "uppercase", // or "lowercase" or "ignore"
}]
}
```
Expand All @@ -55,10 +55,8 @@ var foo = /\ca/
- Properties
- `caseInsensitive` ... Specifies the letter case when the `i` flag is present. Default is `"lowercase"`.
- `unicodeEscape` ... Specifies the letter case when the unicode escapes. Default is `"lowercase"`.
- `hexadecimalEscape` ... Specifies the letter case when the hexadecimal escapes. Default is `"ignore"`.
(The default value will change to `"lowercase"` in the next major version.)
- `controlEscape` ... Specifies the letter case when the control escapes (e.g. `\cX`). Default is `"ignore"`.
(The default value will change to `"uppercase"` in the next major version.)
- `hexadecimalEscape` ... Specifies the letter case when the hexadecimal escapes. Default is `"ignolowercasere"`.
- `controlEscape` ... Specifies the letter case when the control escapes (e.g. `\cX`). Default is `"uppercase"`.

## :rocket: Version

Expand Down
1 change: 1 addition & 0 deletions docs/rules/negation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ since: "v0.4.0"

> enforce use of escapes on negation
- :gear: This rule is included in `"plugin:regexp/recommended"`.
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.

## :book: Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-dupe-disjunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.4.0"

> disallow duplicate disjunctions
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

This rule disallows duplicate disjunctions.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-empty-alternative.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.8.0"

> disallow alternatives without elements
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

While (re-)writing long regular expressions, it can happen that one forgets to
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-lazy-ends.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.8.0"

> disallow lazy quantifiers at the end of an expression
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

If a lazily quantified element is the last element matched by an expression
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-legacy-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.6.0"

> disallow legacy RegExp features
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

This rule disallow legacy RegExp features.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-unused-capturing-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ since: "v0.6.0"

> disallow unused capturing group
- :gear: This rule is included in `"plugin:regexp/recommended"`.

## :book: Rule Details

This rule aims to optimize regular expressions by replacing unused capturing groups with non-capturing groups.
Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-useless-character-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ since: "v0.3.0"

> disallow character class with one character
- :gear: This rule is included in `"plugin:regexp/recommended"`.
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.

## :book: Rule Details
Expand Down
Loading

0 comments on commit 9374ffe

Please sign in to comment.