Skip to content

Commit a217bee

Browse files
Don't trigger no-incorrect-deep-equal for regular expression (#276)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent 26903de commit a217bee

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

rules/no-incorrect-deep-equal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const create = context => {
3434
const deepEqual = '[callee.property.name="deepEqual"]';
3535
const notDeepEqual = '[callee.property.name="notDeepEqual"]';
3636

37-
const argumentsLiteral = ':matches([arguments.0.type="Literal"],[arguments.1.type="Literal"])';
37+
const argumentsLiteral = ':matches([arguments.0.type="Literal"][arguments.0.regex="undefined"],[arguments.1.type="Literal"][arguments.1.regex="undefined"])';
3838
const argumentsUndefined = ':matches([arguments.0.type="Identifier"][arguments.0.name="undefined"],[arguments.1.type="Identifier"][arguments.1.name="undefined"])';
3939
const argumentsTemplate = ':matches([arguments.0.type="TemplateLiteral"],[arguments.1.type="TemplateLiteral"])';
4040

test/no-incorrect-deep-equal.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ ruleTester.run('no-incorrect-deep-equal', rule, {
4040
test('x', t => {
4141
t.notDeepEqual(expression, []);
4242
});
43+
`,
44+
`
45+
${header}
46+
test('x', t => {
47+
t.deepEqual(expression, /regex/);
48+
});
49+
`,
50+
`
51+
${header}
52+
test('x', t => {
53+
t.deepEqual(/regex/, expression);
54+
});
4355
`
4456
],
4557
invalid: [

0 commit comments

Comments
 (0)