Repository: ota-meshi/eslint-plugin-regexp
Pull request #262 (2021-07-02 01:06:04)

Update dependency eslint-plugin-regexp to ^0.13.0
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [eslint-plugin-regexp](https://togithub.com/ota-meshi/eslint-plugin-regexp) | [`^0.12.0` -> `^0.13.0`](https://renovatebot.com/diffs/npm/eslint-plugin-regexp/0.12.0/0.13.0) | [![age](https://badges.renovateapi.com/packages/npm/eslint-plugin-regexp/0.13.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/eslint-plugin-regexp/0.13.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/eslint-plugin-regexp/0.13.0/compatibility-slim/0.12.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/eslint-plugin-regexp/0.13.0/confidence-slim/0.12.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>ota-meshi/eslint-plugin-regexp</summary>

### [`v0.13.0`](https://togithub.com/ota-meshi/eslint-plugin-regexp/releases/v0.13.0)

[Compare Source](https://togithub.com/ota-meshi/eslint-plugin-regexp/compare/v0.12.1...v0.13.0)

#### ✨ Enhancements

-   [#&#8203;242](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/242) Added `regexp/no-super-linear-backtracking` rule.
-   [#&#8203;246](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/246) Added `regexp/no-super-linear-move` rule.
-   [#&#8203;250](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/250) Added `plugin:regexp/all` config.

#### :gear: Updates

-   [#&#8203;248](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/248) Changed `regexp/strict` rule to suggest octal fixes.
-   [#&#8203;261](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/261) Added support for `d` flag.
-   [#&#8203;257](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/257) Changed `regexp/optimal-quantifier-concatenation` rule to provide consistent reporting.

#### :bug: Bug fixes

-   [#&#8203;249](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/249) Fixed issue where rules related to regex usage would appear to use unknown call as regexp exec.
-   [#&#8203;259](https://togithub.com/ota-meshi/eslint-plugin-regexp/issues/259) Fixed incorrect pattern parsing when giving RegExp argument to RegExp constructor.

### [`v0.12.1`](https://togithub.com/ota-meshi/eslint-plugin-regexp/releases/v0.12.1)

[Compare Source](https://togithub.com/ota-meshi/eslint-plugin-regexp/compare/v0.12.0...v0.12.1)

#### :bug: Bug Fixes

-   [`5f67457`](https://togithub.com/ota-meshi/eslint-plugin-regexp/commit/5f67457) Fixed false positives for space in RegExp constructor in `regexp/no-invisible-character` rule.

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled due to failing status checks.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/ota-meshi/eslint-plugin-regexp).

RunDevelopment: I added an ignore comment for one detected case of quadratic backtracking.

The other case is a bug. See #264.

Patch:
diff --git a/.github/workflows/NodeCI.yml b/.github/workflows/NodeCI.yml
index ac07536..79a4e00 100644
--- a/.github/workflows/NodeCI.yml
+++ b/.github/workflows/NodeCI.yml
@@ -59,7 +59,7 @@ jobs:
             - name: Test
               run: npm run test:nyc
             - name: Coveralls GitHub Action
-              uses: coverallsapp/github-action@v1.1.2
+              uses: coverallsapp/github-action@1.1.3
               with:
                   github-token: ${{ secrets.GITHUB_TOKEN }}
     update:
diff --git a/lib/rules/negation.ts b/lib/rules/negation.ts
index 2753755..4fe008c 100644
--- a/lib/rules/negation.ts
+++ b/lib/rules/negation.ts
@@ -64,28 +64,14 @@ export default createRule("negation", {
 function getNegationText(
     node: EscapeCharacterSet | UnicodePropertyCharacterSet,
 ) {
-    let text: string
-    if (node.kind === "digit") {
-        text = "d"
-    } else if (node.kind === "space") {
-        text = "s"
-    } else if (node.kind === "word") {
-        text = "w"
-    } else if (node.kind === "property") {
-        text = "p"
+    // they are all of the form: /\\[dswp](?:\{[^{}]+\})?/
+    let kind = node.raw[1]
+
+    if (kind.toLowerCase() === kind) {
+        kind = kind.toUpperCase()
     } else {
-        throw new Error(`unknown kind:${node.kind}`)
-    }
-    if (!node.negate) {
-        text = text.toUpperCase()
-    }
-    if (node.kind === "property") {
-        if (node.value != null) {
-            text += `{${node.key}=${node.value}}`
-        } else {
-            text += `{${node.key}}`
-        }
+        kind = kind.toLowerCase()
     }
 
-    return `\\${text}`
+    return `\\${kind}${node.raw.slice(2)}`
 }
diff --git a/lib/rules/sort-alternatives.ts b/lib/rules/sort-alternatives.ts
index 40362f0..af88ffa 100644
--- a/lib/rules/sort-alternatives.ts
+++ b/lib/rules/sort-alternatives.ts
@@ -204,7 +204,7 @@ function trySortNumberAlternatives(alternatives: Alternative[]): void {
     {
         let start = 0
         for (let i = 0; i < alternatives.length; i++) {
-            if (!/^0|[1-9]\d*$/.test(alternatives[i].raw)) {
+            if (!/^(?:0|[1-9]\d*)$/.test(alternatives[i].raw)) {
                 if (start < i) {
                     numberRanges.push([start, i])
                 }
diff --git a/lib/utils/index.ts b/lib/utils/index.ts
index f94fc4a..c48614d 100644
--- a/lib/utils/index.ts
+++ b/lib/utils/index.ts
@@ -518,7 +518,7 @@ function buildRegExpHelperBase({
         toCharSet: (node, optionFlags) => {
             if (optionFlags) {
                 // Ignore the cache if the flag is specified.
-                return toCharSet(node, flags)
+                return toCharSet(node, optionFlags)
             }
 
             let charSet = cacheCharSet.get(node)
diff --git a/package-lock.json b/package-lock.json
index 38d2ad1..8ab2d1e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
     "name": "eslint-plugin-regexp",
-    "version": "0.13.0",
+    "version": "0.13.1",
     "lockfileVersion": 1,
     "requires": true,
     "dependencies": {
@@ -1327,9 +1327,9 @@
             }
         },
         "@types/estree": {
-            "version": "0.0.49",
-            "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.49.tgz",
-            "integrity": "sha512-K1AFuMe8a+pXmfHTtnwBvqoEylNKVeaiKYkjmcEAdytMQVJ/i9Fu7sc13GxgXdO49gkE7Hy8SyJonUZUn+eVaw==",
+            "version": "0.0.50",
+            "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.50.tgz",
+            "integrity": "sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw==",
             "dev": true
         },
         "@types/glob": {
@@ -6275,9 +6275,9 @@
             }
         },
         "eslint-plugin-regexp": {
-            "version": "0.12.0",
-            "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-0.12.0.tgz",
-            "integrity": "sha512-sHq+6+F4+A7wy+z5xdmv88az5qm3GzT5XwifWSz1oPYNo5Oy2mXij230ULq4S0rL/OOu4kn0AUBhXV05Vb/I5Q==",
+            "version": "0.13.1",
+            "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-0.13.1.tgz",
+            "integrity": "sha512-97kpGlctWIDWlgVbjutIZ7kn98XGsAaUwra/drPr6rbLFArJAo1T5xBUxL4sD7cfmR1+8tJFl2mm4EgFAP4DcA==",
             "dev": true,
             "requires": {
                 "comment-parser": "^1.1.2",
@@ -6285,7 +6285,8 @@
                 "jsdoctypeparser": "^9.0.0",
                 "refa": "^0.8.0",
                 "regexp-ast-analysis": "^0.2.2",
-                "regexpp": "^3.1.0"
+                "regexpp": "^3.2.0",
+                "scslre": "^0.1.5"
             }
         },
         "eslint-plugin-vue": {
diff --git a/package.json b/package.json
index 3790304..cb770c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "eslint-plugin-regexp",
-    "version": "0.13.0",
+    "version": "0.13.1",
     "description": "ESLint plugin for finding RegExp mistakes and RegExp style guide violations.",
     "main": "dist/index.js",
     "files": [
@@ -52,7 +52,7 @@
         "@ota-meshi/eslint-plugin": "^0.7.0",
         "@types/eslint": "^7.2.0",
         "@types/eslint-scope": "^3.7.0",
-        "@types/estree": "^0.0.49",
+        "@types/estree": "^0.0.50",
         "@types/mocha": "^8.0.0",
         "@types/node": "^14.14.39",
         "@typescript-eslint/eslint-plugin": "^4.14.0",
@@ -67,7 +67,7 @@
         "eslint-plugin-jsonc": "^1.0.0",
         "eslint-plugin-node": "^11.1.0",
         "eslint-plugin-prettier": "^3.4.0",
-        "eslint-plugin-regexp": "^0.12.0",
+        "eslint-plugin-regexp": "^0.13.1",
         "eslint-plugin-vue": "^7.5.0",
         "eslint-plugin-yml": "^0.9.0",
         "eslint4b": "^7.3.1",
diff --git a/tools/update-readme.ts b/tools/update-readme.ts
index bf26fd1..aafd0b2 100644
--- a/tools/update-readme.ts
+++ b/tools/update-readme.ts
@@ -35,6 +35,7 @@ fs.writeFileSync(
         )
         .replace(/<!--DOCS_IGNORE_START-->[\s\S]*?<!--DOCS_IGNORE_END-->/gu, "")
         .replace(
+            // eslint-disable-next-line regexp/no-super-linear-backtracking -- it's acceptable here
             /\(https:\/\/ota-meshi.github.io\/eslint-plugin-regexp(.*?)([^/]*\.html)?\)/gu,
             (_ptn, c1: string, c2: string) => {
                 let result = `(.${c1}`


Test patch:
diff --git a/tests/lib/rules/negation.ts b/tests/lib/rules/negation.ts
index dab7861..cdd1097 100644
--- a/tests/lib/rules/negation.ts
+++ b/tests/lib/rules/negation.ts
@@ -87,6 +87,13 @@ tester.run("negation", rule as any, {
                 "Unexpected negated character class. Use '\\p{Script=Hiragana}' instead.",
             ],
         },
+        {
+            code: String.raw`/[^\P{Ll}]/u;`,
+            output: String.raw`/\p{Ll}/u;`,
+            errors: [
+                "Unexpected negated character class. Use '\\p{Ll}' instead.",
+            ],
+        },
         {
             code: String.raw`const s ="[^\\w]"
             new RegExp(s)`,
diff --git a/tests/lib/rules/no-useless-flag.ts b/tests/lib/rules/no-useless-flag.ts
index 45eff00..3fae3c2 100644
--- a/tests/lib/rules/no-useless-flag.ts
+++ b/tests/lib/rules/no-useless-flag.ts
@@ -22,6 +22,7 @@ tester.run("no-useless-flag", rule as any, {
         `/\\b/iu`,
         String.raw`/\x41/i`,
         `/[a-zA-Z]/i`, // in that case you should use the i flag instead of removing it
+        `/\\p{Ll}/iu`,
 
         // m
         `/^foo/m`,