Skip to content

Commit 3e5fc64

Browse files
authored
Maintenance: Update eslintrc and some fix (#173)
1 parent 99009f3 commit 3e5fc64

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

.eslintrc.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
"use strict"
22

3-
// const version = require("./package.json").version
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+
}, {})
411

512
module.exports = {
613
parserOptions: {
@@ -18,6 +25,8 @@ module.exports = {
1825
"plugin:@ota-meshi/+prettier",
1926
],
2027
rules: {
28+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- Lint only
29+
...enableAllRules,
2130
"require-jsdoc": "error",
2231
"no-warning-comments": "warn",
2332
"no-lonely-if": "off",
@@ -42,29 +51,13 @@ module.exports = {
4251
},
4352
],
4453

45-
// https://github.com/ota-meshi/eslint-plugin-regexp/pull/49
4654
"no-empty-character-class": "error",
47-
"regexp/negation": "error",
48-
"regexp/no-dupe-disjunctions": "error",
49-
"regexp/no-useless-character-class": "error",
50-
"regexp/no-useless-escape": "error",
51-
"regexp/no-useless-non-capturing-group": "error",
52-
"regexp/no-useless-non-greedy": "error",
53-
"regexp/no-useless-range": "error",
54-
"regexp/prefer-character-class": "error",
55-
"regexp/prefer-range": "error",
56-
"regexp/prefer-unicode-codepoint-escapes": "error",
5755

56+
"regexp/no-dupe-disjunctions": ["error", { disallowNeverMatch: true }],
5857
"regexp/letter-case": [
5958
"error",
6059
{ hexadecimalEscape: "lowercase", controlEscape: "uppercase" },
6160
],
62-
63-
// others
64-
"regexp/order-in-character-class": "error",
65-
"regexp/prefer-quantifier": "error",
66-
"regexp/prefer-regexp-exec": "error",
67-
"regexp/prefer-regexp-test": "error",
6861
},
6962
overrides: [
7063
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default createRule("no-useless-character-class", {
115115
element.type === "CharacterClassRange"
116116
) {
117117
if (
118-
/^[$(-+./?[{|]$/u.test(text) ||
118+
/^[$()*+./?[{|]$/u.test(text) ||
119119
(flags.unicode && text === "}")
120120
) {
121121
text = `\\${text}`

lib/utils/type-tracker/jsdoc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class JSDoc {
9090
}
9191
const params = (this.params = new JSDocParams())
9292
for (const param of this.genTags("param")) {
93-
const paths: string[] = (param.name || "").split(/\./gu)
93+
const paths: string[] = (param.name || "").split(/\./u)
9494
params.add(paths, param)
9595
}
9696
return params

tools/update-docs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ROOT = path.resolve(__dirname, "../docs/rules")
2525

2626
//eslint-disable-next-line require-jsdoc -- tools
2727
function pickSince(content: string): string | null {
28-
const fileIntro = /^---\n(.*\n)+---\n*/g.exec(content)
28+
const fileIntro = /^---\n(.*\n)+---\n*/.exec(content)
2929
if (fileIntro) {
3030
const since = /since: "?(v\d+\.\d+\.\d+)"?/.exec(fileIntro[0])
3131
if (since) {
@@ -173,11 +173,11 @@ This rule was introduced in eslint-plugin-regexp ${this.since}
173173
public adjustCodeBlocks() {
174174
// Adjust the necessary blank lines before and after the code block so that GitHub can recognize `.md`.
175175
this.content = this.content.replace(
176-
/(<eslint-code-block[\s\S]*?>)\n+```/gmu,
176+
/(<eslint-code-block[\s\S]*?>)\n+```/gu,
177177
"$1\n\n```",
178178
)
179179
this.content = this.content.replace(
180-
/```\n+<\/eslint-code-block>/gmu,
180+
/```\n+<\/eslint-code-block>/gu,
181181
"```\n\n</eslint-code-block>",
182182
)
183183
return this

0 commit comments

Comments
 (0)