eslint-plugin-regexp
Advanced tools
Comparing version
@@ -19,3 +19,3 @@ "use strict"; | ||
create(context) { | ||
function createVisitor({ node, getRegexpLocation, fixReplaceNode, }) { | ||
function createVisitor({ node, getRegexpLocation, fixReplaceNode, toCharSet, flags, }) { | ||
return { | ||
@@ -27,12 +27,20 @@ onCharacterClassEnter(ccNode) { | ||
const element = ccNode.elements[0]; | ||
if (element.type === "CharacterSet") { | ||
const negatedCharSet = getNegationText(element); | ||
context.report({ | ||
node, | ||
loc: getRegexpLocation(ccNode), | ||
messageId: "unexpected", | ||
data: { negatedCharSet }, | ||
fix: fixReplaceNode(ccNode, negatedCharSet), | ||
}); | ||
if (element.type !== "CharacterSet") { | ||
return; | ||
} | ||
if (flags.ignoreCase && element.kind === "property") { | ||
const ccSet = toCharSet(ccNode); | ||
const negatedElementSet = toCharSet(Object.assign(Object.assign({}, element), { negate: !element.negate })); | ||
if (!ccSet.equals(negatedElementSet)) { | ||
return; | ||
} | ||
} | ||
const negatedCharSet = getNegationText(element); | ||
context.report({ | ||
node, | ||
loc: getRegexpLocation(ccNode), | ||
messageId: "unexpected", | ||
data: { negatedCharSet }, | ||
fix: fixReplaceNode(ccNode, negatedCharSet), | ||
}); | ||
}, | ||
@@ -39,0 +47,0 @@ }; |
{ | ||
"name": "eslint-plugin-regexp", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "ESLint plugin for finding RegExp mistakes and RegExp style guide violations.", | ||
@@ -91,7 +91,7 @@ "main": "dist/index.js", | ||
"jsdoctypeparser": "^9.0.0", | ||
"refa": "^0.8.0", | ||
"regexp-ast-analysis": "^0.2.2", | ||
"refa": "^0.9.0", | ||
"regexp-ast-analysis": "^0.2.3", | ||
"regexpp": "^3.2.0", | ||
"scslre": "^0.1.5" | ||
"scslre": "^0.1.6" | ||
} | ||
} |
488429
0.09%12107
0.07%- Removed
Updated
Updated
Updated