Skip to content

Commit 696308d

Browse files
Added rule categories (#206)
* Added categories * Generate README * Updated website
1 parent 1c7b3b5 commit 696308d

File tree

66 files changed

+277
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+277
-136
lines changed

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,60 +95,72 @@ The rules with the following star :star: are included in the `plugin:regexp/reco
9595

9696
<!--RULES_TABLE_START-->
9797

98+
### Possible Errors
99+
98100
| Rule ID | Description | |
99101
|:--------|:------------|:---|
100-
| [regexp/confusing-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/confusing-quantifier.html) | disallow confusing quantifiers | |
101-
| [regexp/control-character-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/control-character-escape.html) | enforce consistent escaping of control characters | :wrench: |
102-
| [regexp/hexadecimal-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/hexadecimal-escape.html) | enforce consistent usage of hexadecimal escape | :wrench: |
103-
| [regexp/letter-case](https://ota-meshi.github.io/eslint-plugin-regexp/rules/letter-case.html) | enforce into your favorite case | :wrench: |
104-
| [regexp/match-any](https://ota-meshi.github.io/eslint-plugin-regexp/rules/match-any.html) | enforce match any character style | :star::wrench: |
105-
| [regexp/negation](https://ota-meshi.github.io/eslint-plugin-regexp/rules/negation.html) | enforce use of escapes on negation | :wrench: |
106102
| [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: |
107-
| [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::wrench: |
108103
| [regexp/no-dupe-disjunctions](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-dupe-disjunctions.html) | disallow duplicate disjunctions | |
109104
| [regexp/no-empty-alternative](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-alternative.html) | disallow alternatives without elements | |
110105
| [regexp/no-empty-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-empty-group.html) | disallow empty group | :star: |
111106
| [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: |
112107
| [regexp/no-escape-backspace](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-escape-backspace.html) | disallow escape backspace (`[\b]`) | :star: |
113-
| [regexp/no-invisible-character](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-invisible-character.html) | disallow invisible raw character | :star::wrench: |
114108
| [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 | |
109+
| [regexp/no-optional-assertion](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-optional-assertion.html) | disallow optional assertions | |
110+
| [regexp/no-potentially-useless-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-potentially-useless-backreference.html) | disallow backreferences that reference a group that might not be matched | |
111+
| [regexp/no-useless-assertions](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-assertions.html) | disallow assertions that are known to always accept (or reject) | |
112+
| [regexp/no-useless-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-backreference.html) | disallow useless backreferences in regular expressions | :star: |
113+
| [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 | |
114+
115+
### Best Practices
116+
117+
| Rule ID | Description | |
118+
|:--------|:------------|:---|
119+
| [regexp/confusing-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/confusing-quantifier.html) | disallow confusing quantifiers | |
120+
| [regexp/control-character-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/control-character-escape.html) | enforce consistent escaping of control characters | :wrench: |
121+
| [regexp/negation](https://ota-meshi.github.io/eslint-plugin-regexp/rules/negation.html) | enforce use of escapes on negation | :wrench: |
122+
| [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::wrench: |
123+
| [regexp/no-invisible-character](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-invisible-character.html) | disallow invisible raw character | :star::wrench: |
115124
| [regexp/no-legacy-features](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-legacy-features.html) | disallow legacy RegExp features | |
116125
| [regexp/no-non-standard-flag](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-non-standard-flag.html) | disallow non-standard flags | |
117126
| [regexp/no-obscure-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-obscure-range.html) | disallow obscure character ranges | |
118127
| [regexp/no-octal](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-octal.html) | disallow octal escape sequence | :star: |
119-
| [regexp/no-optional-assertion](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-optional-assertion.html) | disallow optional assertions | |
120-
| [regexp/no-potentially-useless-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-potentially-useless-backreference.html) | disallow backreferences that reference a group that might not be matched | |
121128
| [regexp/no-standalone-backslash](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-standalone-backslash.html) | disallow standalone backslashes (`\`) | |
122129
| [regexp/no-trivially-nested-assertion](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-trivially-nested-assertion.html) | disallow trivially nested assertions | :wrench: |
123130
| [regexp/no-trivially-nested-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-trivially-nested-quantifier.html) | disallow nested quantifiers that can be rewritten as one quantifier | :wrench: |
124131
| [regexp/no-unused-capturing-group](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-unused-capturing-group.html) | disallow unused capturing group | |
125-
| [regexp/no-useless-assertions](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-assertions.html) | disallow assertions that are known to always accept (or reject) | |
126-
| [regexp/no-useless-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-backreference.html) | disallow useless backreferences in regular expressions | :star: |
127132
| [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: |
128-
| [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 | |
129-
| [regexp/no-useless-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-escape.html) | disallow unnecessary escape characters in RegExp | |
130133
| [regexp/no-useless-exactly-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-exactly-quantifier.html) | disallow unnecessary exactly quantifier | :star: |
131134
| [regexp/no-useless-flag](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-flag.html) | disallow unnecessary regex flags | :wrench: |
132135
| [regexp/no-useless-lazy](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-lazy.html) | disallow unnecessarily non-greedy quantifiers | :wrench: |
133-
| [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: |
134136
| [regexp/no-useless-non-greedy](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-non-greedy.html) | disallow unnecessarily non-greedy quantifiers | :wrench: |
135137
| [regexp/no-useless-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-quantifier.html) | disallow quantifiers that can be removed | :wrench: |
136138
| [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: |
137139
| [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: |
138140
| [regexp/no-zero-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-zero-quantifier.html) | disallow quantifiers with a maximum of zero | |
139141
| [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 | |
140-
| [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: |
141-
| [regexp/prefer-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-character-class.html) | enforce using character class | :wrench: |
142-
| [regexp/prefer-d](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-d.html) | enforce using `\d` | :star::wrench: |
143142
| [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 (`$$`). | |
144-
| [regexp/prefer-named-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-named-backreference.html) | enforce using named backreferences | :wrench: |
145-
| [regexp/prefer-plus-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-plus-quantifier.html) | enforce using `+` quantifier | :star::wrench: |
146143
| [regexp/prefer-predefined-assertion](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-predefined-assertion.html) | prefer predefined assertion over equivalent lookarounds | :wrench: |
147144
| [regexp/prefer-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-quantifier.html) | enforce using quantifier | :wrench: |
148-
| [regexp/prefer-question-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-question-quantifier.html) | enforce using `?` quantifier | :star::wrench: |
149145
| [regexp/prefer-range](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-range.html) | enforce using character class range | :wrench: |
150146
| [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 | |
151147
| [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: |
148+
149+
### Stylistic Issues
150+
151+
| Rule ID | Description | |
152+
|:--------|:------------|:---|
153+
| [regexp/hexadecimal-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/hexadecimal-escape.html) | enforce consistent usage of hexadecimal escape | :wrench: |
154+
| [regexp/letter-case](https://ota-meshi.github.io/eslint-plugin-regexp/rules/letter-case.html) | enforce into your favorite case | :wrench: |
155+
| [regexp/match-any](https://ota-meshi.github.io/eslint-plugin-regexp/rules/match-any.html) | enforce match any character style | :star::wrench: |
156+
| [regexp/no-useless-escape](https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-escape.html) | disallow unnecessary escape characters in RegExp | |
157+
| [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: |
158+
| [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: |
159+
| [regexp/prefer-character-class](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-character-class.html) | enforce using character class | :wrench: |
160+
| [regexp/prefer-d](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-d.html) | enforce using `\d` | :star::wrench: |
161+
| [regexp/prefer-named-backreference](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-named-backreference.html) | enforce using named backreferences | :wrench: |
162+
| [regexp/prefer-plus-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-plus-quantifier.html) | enforce using `+` quantifier | :star::wrench: |
163+
| [regexp/prefer-question-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-question-quantifier.html) | enforce using `?` quantifier | :star::wrench: |
152164
| [regexp/prefer-star-quantifier](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-star-quantifier.html) | enforce using `*` quantifier | :star::wrench: |
153165
| [regexp/prefer-t](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-t.html) | enforce using `\t` | :star::wrench: |
154166
| [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: |

docs/.vuepress/components/rules/index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import * as coreRules from "../../../../node_modules/eslint4b/dist/core-rules"
44
import plugin from "../../../../"
55

66
const CATEGORY_TITLES = {
7-
recommended: "Recommended",
8-
uncategorized: "Uncategorized",
7+
"Possible Errors": "Possible Errors",
8+
"Best Practices": "Best Practices",
9+
"Stylistic Issues": "Stylistic Issues",
910
"eslint-core-rules@Possible Errors": "ESLint core rules(Possible Errors)",
1011
"eslint-core-rules@Best Practices": "ESLint core rules(Best Practices)",
1112
"eslint-core-rules@Strict Mode": "ESLint core rules(Strict Mode)",
@@ -16,21 +17,23 @@ const CATEGORY_TITLES = {
1617
"eslint-core-rules@ECMAScript 6": "ESLint core rules(ECMAScript 6)",
1718
}
1819
const CATEGORY_INDEX = {
19-
recommended: 2,
20-
uncategorized: 4,
21-
"eslint-plugin-vue": 5,
22-
"eslint-core-rules@Possible Errors": 6,
23-
"eslint-core-rules@Best Practices": 7,
24-
"eslint-core-rules@Strict Mode": 8,
25-
"eslint-core-rules@Variables": 9,
26-
"[email protected] and CommonJS": 10,
27-
"eslint-core-rules@Stylistic Issues": 11,
28-
"eslint-core-rules@ECMAScript 6": 12,
20+
"Possible Errors": 1,
21+
"Best Practices": 2,
22+
"Stylistic Issues": 3,
23+
"eslint-plugin-vue": 10,
24+
"eslint-core-rules@Possible Errors": 20,
25+
"eslint-core-rules@Best Practices": 21,
26+
"eslint-core-rules@Strict Mode": 22,
27+
"eslint-core-rules@Variables": 23,
28+
"[email protected] and CommonJS": 24,
29+
"eslint-core-rules@Stylistic Issues": 25,
30+
"eslint-core-rules@ECMAScript 6": 26,
2931
}
3032
const CATEGORY_CLASSES = {
3133
base: "eslint-plugin-regexp__category",
32-
recommended: "eslint-plugin-regexp__category",
33-
uncategorized: "eslint-plugin-regexp__category",
34+
"Possible Errors": "eslint-plugin-regexp__category",
35+
"Best Practices": "eslint-plugin-regexp__category",
36+
"Stylistic Issues": "eslint-plugin-regexp__category",
3437
}
3538

3639
const allRules = []
@@ -40,9 +43,6 @@ for (const k of Object.keys(plugin.rules)) {
4043
if (rule.meta.deprecated) {
4144
continue
4245
}
43-
rule.meta.docs.category = rule.meta.docs.recommended
44-
? "recommended"
45-
: "uncategorized"
4646
allRules.push({
4747
classes: "eslint-plugin-regexp__rule",
4848
category: rule.meta.docs.category,

docs/.vuepress/config.js

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ function ruleToLink({
88
return [`/rules/${ruleName}`, ruleId]
99
}
1010

11+
/** @type {Record<import("../../lib/types").RuleCategory | "deprecated", import("../../lib/types").RuleModule[]>} */
12+
const categories = {
13+
"Best Practices": [],
14+
"Possible Errors": [],
15+
"Stylistic Issues": [],
16+
deprecated: [],
17+
}
18+
19+
for (const rule of rules) {
20+
if (rule.meta.deprecated) {
21+
categories.deprecated.push(rule)
22+
} else {
23+
categories[rule.meta.docs.category].push(rule)
24+
}
25+
}
26+
1127
module.exports = {
1228
base: "/eslint-plugin-regexp/",
1329
title: "eslint-plugin-regexp",
@@ -52,44 +68,26 @@ module.exports = {
5268
"/rules/": [
5369
"/rules/",
5470
{
55-
title: "Recommended",
71+
title: "Possible Errors",
5672
collapsable: false,
57-
children: rules
58-
.filter(
59-
(rule) =>
60-
rule.meta.docs.recommended &&
61-
!rule.meta.deprecated,
62-
)
63-
.map(ruleToLink),
73+
children: categories["Possible Errors"].map(ruleToLink),
6474
},
65-
...(rules.some(
66-
(rule) =>
67-
!rule.meta.docs.recommended && !rule.meta.deprecated,
68-
)
69-
? [
70-
{
71-
title: "Uncategorized",
72-
collapsable: false,
73-
children: rules
74-
.filter(
75-
(rule) =>
76-
!rule.meta.docs.recommended &&
77-
!rule.meta.deprecated,
78-
)
79-
.map(ruleToLink),
80-
},
81-
]
82-
: []),
83-
84-
// Rules in no category.
85-
...(rules.some((rule) => rule.meta.deprecated)
75+
{
76+
title: "Best Practices",
77+
collapsable: false,
78+
children: categories["Best Practices"].map(ruleToLink),
79+
},
80+
{
81+
title: "Stylistic Issues",
82+
collapsable: false,
83+
children: categories["Stylistic Issues"].map(ruleToLink),
84+
},
85+
...(categories.deprecated.length >= 1
8686
? [
8787
{
8888
title: "Deprecated",
8989
collapsable: false,
90-
children: rules
91-
.filter((rule) => rule.meta.deprecated)
92-
.map(ruleToLink),
90+
children: categories.deprecated.map(ruleToLink),
9391
},
9492
]
9593
: []),

0 commit comments

Comments
 (0)