From 26cdd78783d4bde09e98013dce8c1511323b5be5 Mon Sep 17 00:00:00 2001 From: Sigurd Gerke Date: Tue, 16 Jul 2024 07:06:28 +0200 Subject: [PATCH] Only highlight {it,describe}.only, not its arguments --- lib/rules/no-only.js | 1 + tests/lib/rules/no-only.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/rules/no-only.js b/lib/rules/no-only.js index aa049d1..6d2aa4b 100644 --- a/lib/rules/no-only.js +++ b/lib/rules/no-only.js @@ -17,6 +17,7 @@ module.exports = { if (['describe', 'it'].includes(callee.object.name) && callee.property.name === 'only') { context.report({ node, + loc: { start: callee.object.loc.start, end: callee.property.loc.end }, message: `Unexpected ${callee.object.name}.only`, }); } diff --git a/tests/lib/rules/no-only.js b/tests/lib/rules/no-only.js index ae42d7a..0f5c855 100644 --- a/tests/lib/rules/no-only.js +++ b/tests/lib/rules/no-only.js @@ -19,6 +19,8 @@ ruleTester.run('no-only', rule, { type: 'CallExpression', line: 1, column: 1, + endLine: 1, + endColumn: 14, }], }, { @@ -28,6 +30,8 @@ ruleTester.run('no-only', rule, { type: 'CallExpression', line: 1, column: 1, + endLine: 1, + endColumn: 8, }], }, { @@ -37,6 +41,8 @@ ruleTester.run('no-only', rule, { type: 'CallExpression', line: 1, column: 22, + endLine: 1, + endColumn: 29, }], }, { @@ -47,12 +53,16 @@ ruleTester.run('no-only', rule, { type: 'CallExpression', line: 1, column: 1, + endLine: 1, + endColumn: 14, }, { message: 'Unexpected it.only', type: 'CallExpression', line: 1, column: 27, + endLine: 1, + endColumn: 34, }, ], },