Skip to content

Commit a227562

Browse files
authored
Chore: minor upgrade dev deps (#339)
1 parent 8bd4f86 commit a227562

File tree

70 files changed

+2346
-2386
lines changed

Some content is hidden

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

70 files changed

+2346
-2386
lines changed

.eslintrc.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
"use strict"
22

3-
const { rules } = require("eslint-plugin-regexp")
4-
5-
const enableAllRules = Object.keys(rules)
6-
.map((name) => `regexp/${name}`)
7-
.reduce((p, c) => {
8-
p[c] = "error"
9-
return p
10-
}, {})
11-
123
module.exports = {
134
parserOptions: {
145
sourceType: "script",
@@ -23,9 +14,9 @@ module.exports = {
2314
"plugin:@ota-meshi/+yaml",
2415
// "plugin:@ota-meshi/+md",
2516
"plugin:@ota-meshi/+prettier",
17+
"plugin:regexp/recommended",
2618
],
2719
rules: {
28-
...enableAllRules,
2920
"require-jsdoc": "error",
3021
"no-warning-comments": "warn",
3122
"no-lonely-if": "off",
@@ -34,6 +25,33 @@ module.exports = {
3425

3526
"no-shadow": "off", // ts bug?
3627
"@typescript-eslint/no-shadow": "error",
28+
29+
// regexp next recommended
30+
"regexp/no-contradiction-with-assertion": "error",
31+
"regexp/no-empty-character-class": "error",
32+
"regexp/no-misleading-unicode-character": "error",
33+
"regexp/use-ignore-case": "error",
34+
35+
// regexp Possible Errors
36+
"regexp/no-super-linear-move": "error",
37+
// regexp Best Practices
38+
"regexp/no-octal": "error",
39+
"regexp/no-standalone-backslash": "error",
40+
"regexp/prefer-escape-replacement-dollar-char": "error",
41+
"regexp/prefer-quantifier": "error",
42+
"regexp/prefer-regexp-exec": "error",
43+
"regexp/prefer-regexp-test": "error",
44+
"regexp/require-unicode-regexp": "error",
45+
"regexp/sort-alternatives": "error",
46+
// regexp Stylistic Issues
47+
"regexp/hexadecimal-escape": "error",
48+
"regexp/letter-case": "error",
49+
"regexp/prefer-named-backreference": "error",
50+
"regexp/prefer-named-capture-group": "error",
51+
"regexp/prefer-named-replacement": "error",
52+
"regexp/prefer-result-array-groups": "error",
53+
"regexp/sort-character-class-elements": "error",
54+
"regexp/unicode-escape": "error",
3755
},
3856
overrides: [
3957
{

docs/.vuepress/components/components/RulesSettings.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@
5252
categoryState[category.title].close,
5353
}"
5454
@click="
55-
categoryState[
56-
category.title
57-
].close = !categoryState[category.title].close
55+
categoryState[category.title].close =
56+
!categoryState[category.title].close
5857
"
5958
>
6059
<svg

lib/rules/letter-case.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,22 @@ export default createRule("letter-case", {
171171
if (options.unicodeEscape === "ignore") {
172172
return
173173
}
174-
const parts = /^(\\u\{?)(.*)(\}?)$/u.exec(cNode.raw)!
175-
if (STRING_CASE_CHECKER[options.unicodeEscape](parts[2])) {
174+
const parts = /^(?<prefix>\\u\{?)(?<code>.*)(?<suffix>\}?)$/u.exec(
175+
cNode.raw,
176+
)!
177+
if (
178+
STRING_CASE_CHECKER[options.unicodeEscape](parts.groups!.code)
179+
) {
176180
return
177181
}
178182
report(
179183
regexpContext,
180184
cNode,
181185
options.unicodeEscape,
182-
(converter) => `${parts[1]}${converter(parts[2])}${parts[3]}`,
186+
(converter) =>
187+
`${parts.groups!.prefix}${converter(parts.groups!.code)}${
188+
parts.groups!.suffix
189+
}`,
183190
)
184191
}
185192

@@ -191,15 +198,19 @@ export default createRule("letter-case", {
191198
if (options.hexadecimalEscape === "ignore") {
192199
return
193200
}
194-
const parts = /^\\x(.*)$/u.exec(cNode.raw)!
195-
if (STRING_CASE_CHECKER[options.hexadecimalEscape](parts[1])) {
201+
const parts = /^\\x(?<code>.*)$/u.exec(cNode.raw)!
202+
if (
203+
STRING_CASE_CHECKER[options.hexadecimalEscape](
204+
parts.groups!.code,
205+
)
206+
) {
196207
return
197208
}
198209
report(
199210
regexpContext,
200211
cNode,
201212
options.hexadecimalEscape,
202-
(converter) => `\\x${converter(parts[1])}`,
213+
(converter) => `\\x${converter(parts.groups!.code)}`,
203214
)
204215
}
205216

@@ -211,15 +222,17 @@ export default createRule("letter-case", {
211222
if (options.controlEscape === "ignore") {
212223
return
213224
}
214-
const parts = /^\\c(.*)$/u.exec(cNode.raw)!
215-
if (STRING_CASE_CHECKER[options.controlEscape](parts[1])) {
225+
const parts = /^\\c(?<code>.*)$/u.exec(cNode.raw)!
226+
if (
227+
STRING_CASE_CHECKER[options.controlEscape](parts.groups!.code)
228+
) {
216229
return
217230
}
218231
report(
219232
regexpContext,
220233
cNode,
221234
options.controlEscape,
222-
(converter) => `\\c${converter(parts[1])}`,
235+
(converter) => `\\c${converter(parts.groups!.code)}`,
223236
)
224237
}
225238

lib/rules/no-control-character.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const CONTROL_CHARS = new Map<number, string>([
1515
[CP_CR, "\\r"],
1616
])
1717

18-
const ALLOWED_CONTROL_CHARS = /^\\[0fnrtv]$/
18+
const ALLOWED_CONTROL_CHARS = /^\\[0fnrtv]$/u
1919

2020
export default createRule("no-control-character", {
2121
meta: {
@@ -42,12 +42,8 @@ export default createRule("no-control-character", {
4242
function createVisitor(
4343
regexpContext: RegExpContext,
4444
): RegExpVisitor.Handlers {
45-
const {
46-
node,
47-
patternSource,
48-
getRegexpLocation,
49-
fixReplaceNode,
50-
} = regexpContext
45+
const { node, patternSource, getRegexpLocation, fixReplaceNode } =
46+
regexpContext
5147

5248
/** */
5349
function isBadEscapeRaw(raw: string, cp: number): boolean {

lib/rules/no-dupe-characters-character-class.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,12 @@ export default createRule("no-dupe-characters-character-class", {
408408
// intersection that contain the min/max of the
409409
// character range.
410410
// there is no point in reporting overlaps that can't be fixed.
411-
const interestingRanges = intersection.ranges.filter(
412-
(r) =>
413-
inRange(r, range.min.value) ||
414-
inRange(r, range.max.value),
415-
)
411+
const interestingRanges =
412+
intersection.ranges.filter(
413+
(r) =>
414+
inRange(r, range.min.value) ||
415+
inRange(r, range.max.value),
416+
)
416417

417418
// we might break the ignore case property here
418419
// (see GH #189).

lib/rules/no-dupe-disjunctions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,7 @@ export default createRule("no-dupe-disjunctions", {
701701
messages: {
702702
duplicate:
703703
"Unexpected duplicate alternative. This alternative can be removed.{{cap}}{{exp}}",
704-
subset:
705-
"Unexpected useless alternative. This alternative is a strict subset of {{others}} and can be removed.{{cap}}{{exp}}",
704+
subset: "Unexpected useless alternative. This alternative is a strict subset of {{others}} and can be removed.{{cap}}{{exp}}",
706705
prefixSubset:
707706
"Unexpected useless alternative. This alternative is already covered by {{others}} and can be removed.{{cap}}",
708707
superset:
@@ -741,7 +740,7 @@ export default createRule("no-dupe-disjunctions", {
741740
flags: new RegExpParser().parseFlags(
742741
[
743742
...new Set(
744-
(flagsString || "").replace(/[^gimsuy]/g, ""),
743+
(flagsString || "").replace(/[^gimsuy]/gu, ""),
745744
),
746745
].join(""),
747746
),

lib/rules/no-empty-character-class.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default createRule("no-empty-character-class", {
1414
},
1515
schema: [],
1616
messages: {
17-
empty:
18-
"This character class matches no characters because it is empty.",
17+
empty: "This character class matches no characters because it is empty.",
1918
cannotMatchAny: "This character class cannot match any characters.",
2019
},
2120
type: "suggestion", // "problem",

lib/rules/no-super-linear-move.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,8 @@ export default createRule("no-super-linear-move", {
314314
function createVisitor(
315315
regexpContext: RegExpContext,
316316
): RegExpVisitor.Handlers {
317-
const {
318-
node,
319-
flags,
320-
getRegexpLocation,
321-
getUsageOfPattern,
322-
} = regexpContext
317+
const { node, flags, getRegexpLocation, getUsageOfPattern } =
318+
regexpContext
323319

324320
if (ignoreSticky && flags.sticky) {
325321
return {}

lib/rules/no-trivially-nested-quantifier.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ export default createRule("no-trivially-nested-quantifier", {
146146
fixable: "code",
147147
schema: [],
148148
messages: {
149-
nested:
150-
"These two quantifiers are trivially nested and can be replaced with '{{quant}}'.",
149+
nested: "These two quantifiers are trivially nested and can be replaced with '{{quant}}'.",
151150
childOne: "This nested quantifier can be removed.",
152151
childSimpler:
153152
"This nested quantifier can be simplified to '{{quant}}'.",

lib/rules/no-unused-capturing-group.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default createRule("no-unused-capturing-group", {
7373
const fix = fixableGroups.has(cgNode)
7474
? fixReplaceNode(
7575
cgNode,
76-
cgNode.raw.replace(/^\((?:\?<[^<>]+>)?/, "(?:"),
76+
cgNode.raw.replace(/^\((?:\?<[^<>]+>)?/u, "(?:"),
7777
)
7878
: null
7979

@@ -94,7 +94,8 @@ export default createRule("no-unused-capturing-group", {
9494
* Get all capturing group references
9595
*/
9696
function getCapturingGroupReferences(regexpContext: RegExpContext) {
97-
const capturingGroupReferences = regexpContext.getCapturingGroupReferences()
97+
const capturingGroupReferences =
98+
regexpContext.getCapturingGroupReferences()
9899
if (!capturingGroupReferences.length) {
99100
// unused regexp
100101
return null

0 commit comments

Comments
 (0)