Skip to content

Commit

Permalink
chore: change rules to always report on matcher even when modifier is…
Browse files Browse the repository at this point in the history
… present (#1177)
  • Loading branch information
G-Rath authored Jul 29, 2022
1 parent 6d1663e commit 7b7f7bc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions src/rules/__tests__/prefer-comparison-matcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher: preferredMatcherWhenNegated },
column: 18 + operator.length,
column: 22 + operator.length,
line: 1,
},
],
Expand All @@ -107,7 +107,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher: preferredMatcherWhenNegated },
column: 18 + operator.length,
column: 25 + operator.length,
line: 1,
},
],
Expand All @@ -119,7 +119,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher: preferredMatcherWhenNegated },
column: 27 + operator.length,
column: 31 + operator.length,
line: 1,
},
],
Expand All @@ -131,7 +131,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher },
column: 18 + operator.length,
column: 22 + operator.length,
line: 1,
},
],
Expand All @@ -143,7 +143,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher },
column: 27 + operator.length,
column: 31 + operator.length,
line: 1,
},
],
Expand All @@ -155,7 +155,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher },
column: 30 + operator.length,
column: 34 + operator.length,
line: 1,
},
],
Expand All @@ -167,7 +167,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher },
column: 30 + operator.length,
column: 37 + operator.length,
line: 1,
},
],
Expand All @@ -179,7 +179,7 @@ const generateInvalidCases = (
{
messageId: 'useToBeComparison',
data: { preferredMatcher },
column: 30 + operator.length,
column: 37 + operator.length,
line: 1,
},
],
Expand Down
20 changes: 10 additions & 10 deletions src/rules/__tests__/prefer-equality-matcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).not.${equalityMatcher}(b);`,
),
column: 17,
column: 21,
line: 1,
},
],
Expand All @@ -110,7 +110,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).${equalityMatcher}(b);`,
),
column: 17,
column: 21,
line: 1,
},
],
Expand All @@ -123,7 +123,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.not.${equalityMatcher}(b);`,
),
column: 26,
column: 30,
line: 1,
},
],
Expand All @@ -136,7 +136,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.${equalityMatcher}(b);`,
),
column: 26,
column: 30,
line: 1,
},
],
Expand All @@ -149,7 +149,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.${equalityMatcher}(b);`,
),
column: 29,
column: 33,
line: 1,
},
],
Expand All @@ -162,7 +162,7 @@ ruleTester.run('prefer-equality-matcher: ===', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.${equalityMatcher}(b);`,
),
column: 29,
column: 36,
line: 1,
},
],
Expand Down Expand Up @@ -237,7 +237,7 @@ ruleTester.run('prefer-equality-matcher: !==', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).${equalityMatcher}(b);`,
),
column: 17,
column: 21,
line: 1,
},
],
Expand All @@ -250,7 +250,7 @@ ruleTester.run('prefer-equality-matcher: !==', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).not.${equalityMatcher}(b);`,
),
column: 17,
column: 21,
line: 1,
},
],
Expand All @@ -263,7 +263,7 @@ ruleTester.run('prefer-equality-matcher: !==', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.${equalityMatcher}(b);`,
),
column: 26,
column: 30,
line: 1,
},
],
Expand All @@ -276,7 +276,7 @@ ruleTester.run('prefer-equality-matcher: !==', rule, {
suggestions: expectSuggestions(
equalityMatcher => `expect(a).resolves.not.${equalityMatcher}(b);`,
),
column: 26,
column: 30,
line: 1,
},
],
Expand Down
30 changes: 15 additions & 15 deletions src/rules/__tests__/prefer-to-contain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: "expect(a['includes'](b)).not.toEqual(false);",
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 26, line: 1 }],
errors: [{ messageId: 'useToContain', column: 30, line: 1 }],
},
{
code: "expect(a['includes'](b))['not'].toEqual(false);",
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 26, line: 1 }],
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
},
{
code: "expect(a['includes'](b))['not']['toEqual'](false);",
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 26, line: 1 }],
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
},
{
code: 'expect(a.includes(b)).toEqual(false);',
Expand All @@ -70,12 +70,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect(a.includes(b)).not.toEqual(false);',
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.includes(b)).not.toEqual(true);',
output: 'expect(a).not.toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.includes(b)).toBe(true);',
Expand All @@ -90,12 +90,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect(a.includes(b)).not.toBe(false);',
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.includes(b)).not.toBe(true);',
output: 'expect(a).not.toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.includes(b)).toStrictEqual(true);',
Expand All @@ -110,12 +110,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect(a.includes(b)).not.toStrictEqual(false);',
output: 'expect(a).toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.includes(b)).not.toStrictEqual(true);',
output: 'expect(a).not.toContain(b);',
errors: [{ messageId: 'useToContain', column: 23, line: 1 }],
errors: [{ messageId: 'useToContain', column: 27, line: 1 }],
},
{
code: 'expect(a.test(t).includes(b.test(p))).toEqual(true);',
Expand All @@ -130,12 +130,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect(a.test(t).includes(b.test(p))).not.toEqual(true);',
output: 'expect(a.test(t)).not.toContain(b.test(p));',
errors: [{ messageId: 'useToContain', column: 39, line: 1 }],
errors: [{ messageId: 'useToContain', column: 43, line: 1 }],
},
{
code: 'expect(a.test(t).includes(b.test(p))).not.toEqual(false);',
output: 'expect(a.test(t)).toContain(b.test(p));',
errors: [{ messageId: 'useToContain', column: 39, line: 1 }],
errors: [{ messageId: 'useToContain', column: 43, line: 1 }],
},
{
code: 'expect([{a:1}].includes({a:1})).toBe(true);',
Expand All @@ -150,12 +150,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect([{a:1}].includes({a:1})).not.toBe(true);',
output: 'expect([{a:1}]).not.toContain({a:1});',
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
errors: [{ messageId: 'useToContain', column: 37, line: 1 }],
},
{
code: 'expect([{a:1}].includes({a:1})).not.toBe(false);',
output: 'expect([{a:1}]).toContain({a:1});',
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
errors: [{ messageId: 'useToContain', column: 37, line: 1 }],
},
{
code: 'expect([{a:1}].includes({a:1})).toStrictEqual(true);',
Expand All @@ -170,12 +170,12 @@ ruleTester.run('prefer-to-contain', rule, {
{
code: 'expect([{a:1}].includes({a:1})).not.toStrictEqual(true);',
output: 'expect([{a:1}]).not.toContain({a:1});',
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
errors: [{ messageId: 'useToContain', column: 37, line: 1 }],
},
{
code: 'expect([{a:1}].includes({a:1})).not.toStrictEqual(false);',
output: 'expect([{a:1}]).toContain({a:1});',
errors: [{ messageId: 'useToContain', column: 33, line: 1 }],
errors: [{ messageId: 'useToContain', column: 37, line: 1 }],
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-comparison-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default createRule({
},
messageId: 'useToBeComparison',
data: { preferredMatcher },
node: (negation || matcher).node.property,
node: matcher.node.property,
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-equality-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default createRule({
fix: buildFixer(equalityMatcher),
}),
),
node: (negation || matcher).node.property,
node: matcher.node.property,
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-to-contain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default createRule({
];
},
messageId: 'useToContain',
node: (modifier || matcher).node.property,
node: matcher.node.property,
});
},
};
Expand Down

0 comments on commit 7b7f7bc

Please sign in to comment.