Skip to content

Commit

Permalink
fix: ignore SpreadExpressions in no-only-tests and prefer-output-null
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann authored and aladdin-add committed Jul 19, 2023
1 parent dea161d commit 4924042
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/rules/no-only-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {

const onlyProperty = test.properties.find(
(property) =>
property.type === 'Property' &&
property.key.type === 'Identifier' &&
property.key.name === 'only' &&
property.value.type === 'Literal' &&
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/prefer-output-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ module.exports = {
*/
function getTestInfo(key) {
if (test.type === 'ObjectExpression') {
return test.properties.find((item) => item.key.name === key);
return test.properties.find(
(item) => item.type === 'Property' && item.key.name === key
);
}
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/rules/no-only-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ ruleTester.run('no-only-tests', rule, {
'foo',
{ code: 'foo', foo: true },
RuleTester.somethingElse(),
notRuleTester.only()
notRuleTester.only(),
{ ...otherOptions },
],
invalid: [
{ code: 'bar', foo: true },
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/prefer-output-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ruleTester.run('prefer-output-null', rule, {
new RuleTester().run('foo', bar, {
valid: [],
invalid: [
{ ...otherOptions },
{code: 'foo', output: 'bar', errors: ['bar']},
]
});
Expand Down

0 comments on commit 4924042

Please sign in to comment.