Skip to content

Commit 70568b0

Browse files
authored
fix(no-export): treat describe blocks as test files (#1978)
Report exports in files that only contain describe blocks, aligning behavior with the rule documentation.
1 parent 4a8fc22 commit 70568b0

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/rules/__tests__/no-export.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,15 @@ ruleTester.run('no-export', rule, {
8282
code: 'module.export.invalid = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
8383
errors: [{ endColumn: 22, column: 1, messageId: 'unexpectedExport' }],
8484
},
85+
{
86+
code: dedent`
87+
module.exports = function () {};
88+
89+
describe('a test', () => {
90+
expect(1).toBe(1);
91+
});
92+
`,
93+
errors: [{ endColumn: 15, column: 1, messageId: 'unexpectedExport' }],
94+
},
8595
],
8696
});

src/rules/no-export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default createRule({
3333
},
3434

3535
CallExpression(node) {
36-
if (isTypeOfJestFnCall(node, context, ['test'])) {
36+
if (isTypeOfJestFnCall(node, context, ['describe', 'test'])) {
3737
hasTestCase = true;
3838
}
3939
},

0 commit comments

Comments
 (0)