@putout/plugin-remove-useless-escape 8.0.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,7 +27,6 @@ npm i @putout/plugin-remove-useless-escape
27
27
  const t = 'hello \"world\"';
28
28
  const s1 = `hello \"world\"`;
29
29
  const s = `hello \'world\'`;
30
- const reg = /\w\:/g;
31
30
  ```
32
31
 
33
32
  ## ✅ Example of correct code
@@ -36,7 +35,6 @@ const reg = /\w\:/g;
36
35
  const t = 'hello "world"';
37
36
  const s1 = `hello "world"`;
38
37
  const s = `hello 'world'`;
39
- const reg = /\w:/g;
40
38
  ```
41
39
 
42
40
  ## Comparison
@@ -1,9 +1,4 @@
1
1
  import emojiRegex from 'emoji-regex';
2
- import {types, operator} from 'putout';
3
-
4
- const {replaceWith} = operator;
5
- const {regExpLiteral} = types;
6
- const {assign} = Object;
7
2
 
8
3
  export const report = () => 'Unnecessary escape character';
9
4
 
@@ -16,25 +11,6 @@ export const fix = (path) => {
16
11
  return;
17
12
  }
18
13
 
19
- if (path.isRegExpLiteral()) {
20
- const {pattern, flags} = path.node;
21
-
22
- const unescaped = unescapeRegExp(pattern);
23
- const raw = `/${unescaped}/`;
24
-
25
- const regExpNode = assign(regExpLiteral(unescaped, flags), {
26
- value: unescaped,
27
- raw,
28
- extra: {
29
- raw,
30
- rawValue: unescaped,
31
- },
32
- });
33
-
34
- replaceWith(path, regExpNode);
35
- return;
36
- }
37
-
38
14
  for (const tmpl of path.node.quasis) {
39
15
  const {raw} = tmpl.value;
40
16
  tmpl.value.raw = unEscape(raw);
@@ -42,12 +18,6 @@ export const fix = (path) => {
42
18
  };
43
19
 
44
20
  export const traverse = ({push}) => ({
45
- 'RegExpLiteral'(path) {
46
- const {raw} = path.node;
47
-
48
- if (isEscapedRegExp(raw))
49
- push(path);
50
- },
51
21
  '"__"'(path) {
52
22
  const {raw} = path.node;
53
23
 
@@ -152,24 +122,3 @@ function unEscape(raw) {
152
122
 
153
123
  return raw;
154
124
  }
155
-
156
- const unescapeRegExp = (raw) => raw
157
- .replaceAll('\\:', ':')
158
- .replaceAll('\\+\\/', '+/')
159
- .replaceAll('\\,', ',')
160
- .replaceAll('\\`', '`');
161
-
162
- const is = (a) => (b) => b.includes(`\\${a}`) && !b.includes(`\\\\${a}`);
163
- const isRegExpColon = is(':');
164
- const isComa = is(',');
165
- const isRegExpSlash = (a) => a.includes('\\\\\\\\');
166
-
167
- function isEscapedRegExp(raw) {
168
- if (raw.includes('\\/'))
169
- return false;
170
-
171
- if (raw.includes('\\`'))
172
- return true;
173
-
174
- return isRegExpColon(raw) || isRegExpSlash(raw) || isComa(raw);
175
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-remove-useless-escape",
3
- "version": "8.0.0",
3
+ "version": "9.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to find and remove useless escape",
@@ -39,15 +39,15 @@
39
39
  "@putout/eslint-flat": "^3.0.0",
40
40
  "@putout/plugin-madrun": "*",
41
41
  "@putout/plugin-regexp": "*",
42
- "@putout/test": "^13.0.0",
42
+ "@putout/test": "^14.0.0",
43
43
  "c8": "^10.0.0",
44
- "eslint": "^9.0.0",
44
+ "eslint": "v10.0.0-alpha.0",
45
45
  "eslint-plugin-n": "^17.0.0",
46
- "eslint-plugin-putout": "^26.0.0",
46
+ "eslint-plugin-putout": "^29.0.0",
47
47
  "madrun": "^11.0.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "putout": ">=40"
50
+ "putout": ">=41"
51
51
  },
52
52
  "license": "MIT",
53
53
  "engines": {