js-compiler: noEmptyCharacterClass shouldn't hit empty inverted charsets
MODIFY
packages/@romejs/js-compiler/transforms/lint/noEmptyCharacterClass.ts
packages/@romejs/js-compiler/transforms/lint/noEmptyCharacterClass.ts
@@ -12,8 +12,11 @@ export default {
enter(path: Path): TransformExitResult {
const {context, node} = path;
- if (node.type === 'RegExpCharSet') {
- if (node.body.length === 0) {
+ if (
+ node.type === 'RegExpCharSet' &&
+ node.body.length === 0 &&
+ !node.invert
+ ) {
context.addNodeDiagnostic(node, {
category: 'lint/noEmptyCharacterClass',
message:
@@ -21,7 +24,6 @@ export default {
});
return REDUCE_REMOVE;
}
- }
return node;
},

js-compiler: noEmptyCharacterClass shouldn't hit empty inverted charsets