Skip to content

Commit c11da25

Browse files
committed
## 1.9.0 - April 2022
* Removes `replacement.function === 'string'` validation, it's not necessary, eslint already validates json. (Test already added at invalid-regex-detailed-rule.e2e-test.js) * Fixes spelling in tests
1 parent c8f9e5a commit c11da25

File tree

8 files changed

+1200
-1326
lines changed

8 files changed

+1200
-1326
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
* This bug required that the same rule can be defined with different error levels, that is not possible at the moment on eslint. Error level is not available at plugin level (as indicate by ESLint official documentation: "Keep in mind that the error level is not part of context.options, as the error level cannot be known or modified from inside a rule"). So I came up a different approach, which not only **allows to use "the same" rule with different error levels**, but also **allows Mixing custom set of regex rules**, this is useful for creating package/libraries/plugins with your own set of rules and sharing it with others.
77
* Fixes #16, Unable to use both "ignore" and "inspect" inside "files" property.
88
* Fixes an issue with remaining source calculation and minified files.
9+
* Removes `replacement.function === 'string'` validation, it's not necessary, eslint already validates json.
910
* Improves project configuration.
1011
* Now uses [`any-eslint-parser`](https://www.npmjs.com/package/any-eslint-parser)
1112
* Improves documentation.
1213
* Mixing
14+
* Fixes spelling in tests.
1315

1416
## 1.8.0 - August 2021
1517

lib/rules/invalid-regex-rule.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,16 @@ function createReplacement(replacement) {
117117
switch (typeof replacement) {
118118
case 'string':
119119
return (from, found) => fixer => fixer.replaceTextRange([from + found.patternIndex, from + found.nextChar], replacement)
120-
case 'object':
121-
if (typeof replacement.function === 'string') {
122-
const replacementFunction = buildReplacementFunction(replacement.function)
123-
if (typeof replacementFunction === 'function') {
124-
return (from, found) =>
125-
fixer => fixer.replaceTextRange(
126-
[from + found.patternIndex, from + found.nextChar],
127-
replacementFunction(found.$)
128-
)
129-
}
120+
case 'object':{
121+
const replacementFunction = buildReplacementFunction(replacement.function)
122+
if (typeof replacementFunction === 'function') {
123+
return (from, found) =>
124+
fixer => fixer.replaceTextRange(
125+
[from + found.patternIndex, from + found.nextChar],
126+
replacementFunction(found.$)
127+
)
130128
}
129+
}
131130
}
132131
return () => undefined
133132
}

0 commit comments

Comments
 (0)