Skip to content

Commit

Permalink
Don't trigger no-incorrect-deep-equal for regular expression (#276)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
mikaoelitiana and sindresorhus committed Feb 20, 2020
1 parent 26903de commit a217bee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/no-incorrect-deep-equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const create = context => {
const deepEqual = '[callee.property.name="deepEqual"]';
const notDeepEqual = '[callee.property.name="notDeepEqual"]';

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

Expand Down
12 changes: 12 additions & 0 deletions test/no-incorrect-deep-equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ ruleTester.run('no-incorrect-deep-equal', rule, {
test('x', t => {
t.notDeepEqual(expression, []);
});
`,
`
${header}
test('x', t => {
t.deepEqual(expression, /regex/);
});
`,
`
${header}
test('x', t => {
t.deepEqual(/regex/, expression);
});
`
],
invalid: [
Expand Down

0 comments on commit a217bee

Please sign in to comment.