From f1e15490ba4d9b1d3e72e276a6b8fb06d695e27e Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 22 Oct 2023 12:32:08 +0200 Subject: [PATCH 1/3] test(no-disabled-tests): add failing tests for error ranges --- tests/no-disabled-tests.test.ts | 94 +++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 9 deletions(-) diff --git a/tests/no-disabled-tests.test.ts b/tests/no-disabled-tests.test.ts index 8631664..6c69256 100644 --- a/tests/no-disabled-tests.test.ts +++ b/tests/no-disabled-tests.test.ts @@ -37,45 +37,121 @@ ruleTester.run(RULE_NAME, rule, { code: 'describe.skip("foo", function () {})', errors: [ { + column: 10, + endColumn: 14, + endLine: 1, + line: 1, messageId: 'disabledSuite' } ] }, { code: 'it("contains a call to pending", function () { pending() })', - errors: [{ messageId: 'pendingTest', column: 48, line: 1 }] + errors: [ + { + column: 48, + endColumn: 57, + endLine: 1, + line: 1, + messageId: 'pendingTest' + } + ] }, { code: 'xtest("foo", function () {})', - errors: [{ messageId: 'disabledTest', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 6, + endLine: 1, + line: 1, + messageId: 'disabledTest' + } + ] }, { code: 'xit.each``("foo", function () {})', - errors: [{ messageId: 'disabledTest', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 4, + endLine: 1, + line: 1, + messageId: 'disabledTest' + } + ] }, { code: 'xtest.each``("foo", function () {})', - errors: [{ messageId: 'disabledTest', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 6, + endLine: 1, + line: 1, + messageId: 'disabledTest' + } + ] }, { code: 'xit.each([])("foo", function () {})', - errors: [{ messageId: 'disabledTest', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 4, + endLine: 1, + line: 1, + messageId: 'disabledTest' + } + ] }, { code: 'it("has title but no callback")', - errors: [{ messageId: 'missingFunction', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 32, + endLine: 1, + line: 1, + messageId: 'missingFunction' + } + ] }, { code: 'test("has title but no callback")', - errors: [{ messageId: 'missingFunction', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 34, + endLine: 1, + line: 1, + messageId: 'missingFunction' + } + ] }, { code: 'it("contains a call to pending", function () { pending() })', - errors: [{ messageId: 'pendingTest', column: 48, line: 1 }] + errors: [ + { + column: 48, + endColumn: 57, + endLine: 1, + line: 1, + messageId: 'pendingTest' + } + ] }, { code: 'pending();', - errors: [{ messageId: 'pending', column: 1, line: 1 }] + errors: [ + { + column: 1, + endColumn: 10, + endLine: 1, + line: 1, + messageId: 'pending' + } + ] } ] }) From 1ef11ca9384b873c482e0be00bd2a5f6ab8c2a0f Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 22 Oct 2023 12:49:12 +0200 Subject: [PATCH 2/3] feat(no-disabled-tests): make error ranges smaller Fixes #270. --- src/rules/no-disabled-tests.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rules/no-disabled-tests.ts b/src/rules/no-disabled-tests.ts index eb88631..4f92b41 100644 --- a/src/rules/no-disabled-tests.ts +++ b/src/rules/no-disabled-tests.ts @@ -48,10 +48,11 @@ export default createEslintRule({ } } - if (vitestFnCall.name.startsWith('x') || vitestFnCall.members.some(s => getAccessorValue(s) === 'skip')) { + const skipMember = vitestFnCall.members.find(s => getAccessorValue(s) === 'skip') + if (vitestFnCall.name.startsWith('x') || skipMember !== undefined) { context.report({ messageId: vitestFnCall.type === 'describe' ? 'disabledSuite' : 'disabledTest', - node + node: skipMember ?? vitestFnCall.head.node }) } }, From b93183ab318cfb3ee0f487f404ec201afcfc96d5 Mon Sep 17 00:00:00 2001 From: Verite Mugabo Date: Sun, 22 Oct 2023 19:12:51 -0400 Subject: [PATCH 3/3] feat: updated format --- tests/prefer-lowercase-title.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/prefer-lowercase-title.test.ts b/tests/prefer-lowercase-title.test.ts index 78931c8..2e88715 100644 --- a/tests/prefer-lowercase-title.test.ts +++ b/tests/prefer-lowercase-title.test.ts @@ -64,6 +64,6 @@ ruleTester.run(RULE_NAME, rule, { } } ] - }, + } ] })