@putout/plugin-remove-useless-escape 5.2.0 → 7.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.
@@ -101,6 +101,9 @@ function isEscaped(raw) {
101
101
  if (!raw.includes('\\'))
102
102
  return false;
103
103
 
104
+ if (raw.includes('\\h') && !raw.includes('\\\\h'))
105
+ return true;
106
+
104
107
  if (/\\\\/g.test(raw))
105
108
  return false;
106
109
 
@@ -143,7 +146,8 @@ function unEscape(raw) {
143
146
  .replaceAll('\\$', '$')
144
147
  .replaceAll('\\{', '{')
145
148
  .replaceAll('\\.', '.')
146
- .replace(/(\\),/, ',');
149
+ .replace(/(\\),/, ',')
150
+ .replaceAll('\\h', 'h');
147
151
 
148
152
  for (const emoji of match(raw)) {
149
153
  raw = raw.replace(createEncodedRegExp(emoji), emoji);
@@ -152,12 +156,11 @@ function unEscape(raw) {
152
156
  return raw;
153
157
  }
154
158
 
155
- function unescapeRegExp(raw) {
156
- return raw
157
- .replaceAll('\\:', ':')
158
- .replaceAll('\\+\\/', '+/')
159
- .replaceAll('\\,', ',');
160
- }
159
+ const unescapeRegExp = (raw) => raw
160
+ .replaceAll('\\:', ':')
161
+ .replaceAll('\\+\\/', '+/')
162
+ .replaceAll('\\,', ',')
163
+ .replaceAll('\\`', '`');
161
164
 
162
165
  const is = (a) => (b) => b.includes(`\\${a}`) && !b.includes(`\\\\${a}`);
163
166
  const isRegExpColon = is(':');
@@ -168,5 +171,8 @@ function isEscapedRegExp(raw) {
168
171
  if (raw.includes('\\/'))
169
172
  return false;
170
173
 
174
+ if (raw.includes('\\`'))
175
+ return true;
176
+
171
177
  return isRegExpColon(raw) || isRegExpSlash(raw) || isComa(raw);
172
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-remove-useless-escape",
3
- "version": "5.2.0",
3
+ "version": "7.0.0",
4
4
  "type": "commonjs",
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",
@@ -11,7 +11,7 @@
11
11
  "changelog": false,
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git://github.com/coderaiser/putout.git"
14
+ "url": "git+https://github.com/coderaiser/putout.git"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "madrun test",
@@ -36,17 +36,18 @@
36
36
  "escape"
37
37
  ],
38
38
  "devDependencies": {
39
+ "@putout/eslint-flat": "^2.0.0",
39
40
  "@putout/plugin-madrun": "*",
40
41
  "@putout/plugin-regexp": "*",
41
- "@putout/test": "^8.0.0",
42
- "c8": "^9.0.0",
43
- "eslint": "^9.0.0-alpha.0",
44
- "eslint-plugin-n": "^17.0.0-0",
45
- "eslint-plugin-putout": "^22.0.0",
42
+ "@putout/test": "^12.0.0",
43
+ "c8": "^10.0.0",
44
+ "eslint": "^9.0.0",
45
+ "eslint-plugin-n": "^17.0.0",
46
+ "eslint-plugin-putout": "^25.0.1",
46
47
  "madrun": "^10.0.0"
47
48
  },
48
49
  "peerDependencies": {
49
- "putout": ">=34"
50
+ "putout": ">=38"
50
51
  },
51
52
  "license": "MIT",
52
53
  "engines": {