From 05980f32a9b8013123ec05ba2dc0bce454430b56 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 15 Aug 2026 23:39:12 -0500 Subject: [PATCH] fix: report `no-empty-lines-between-requires` error on the require line Previously the rule reported errors with `node: null` and a synthetic location pointing at the blank lines between require statements. Since blank lines have no code, `eslint-disable-line` comments could not target them, making per-line suppression impossible. Change `context.report()` to use the current require node (`currNode`) so the error is reported on the first require statement after the empty lines. Users can now append `// eslint-disable-line stdlib/no-empty-lines-between-requires` to suppress the rule on a targeted basis. Co-Authored-By: Claude Opus 5 (1M context) --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lib/main.js | 14 +------- .../test/fixtures/invalid.js | 36 ++++++++++++------- .../test/fixtures/valid.js | 14 ++++++++ 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/lib/main.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/lib/main.js index d4b8f6b11f66..ad2c915b004a 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/lib/main.js @@ -165,21 +165,9 @@ function main( context ) { * @param {ASTNode} currNode - current require node */ function report( prevNode, currNode ) { - var loc = { - 'start': { - 'line': prevNode.loc.end.line + 1, - 'column': 0 - }, - 'end': { - 'line': currNode.loc.start.line, - 'column': 0 - } - }; - context.report({ - 'node': null, + 'node': currNode, 'message': 'Unexpected empty line between require statements.', - 'loc': loc, 'fix': fix }); diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/invalid.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/invalid.js index 74b1d52c3a4b..a0a6487df11a 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/invalid.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/invalid.js @@ -34,7 +34,8 @@ var test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 } ], 'output': [ @@ -63,7 +64,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 8 } ], 'output': [ @@ -92,7 +94,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 8 } ], 'output': [ @@ -121,7 +124,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 } ], 'output': [ @@ -151,11 +155,13 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 }, { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 9 } ], 'output': [ @@ -185,7 +191,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 8 } ], 'output': [ @@ -214,7 +221,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 } ], 'output': [ @@ -241,7 +249,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 6 } ], 'output': [ @@ -268,7 +277,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 } ], 'output': [ @@ -298,7 +308,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 7 } ], 'output': [ @@ -330,7 +341,8 @@ test = { 'errors': [ { 'message': 'Unexpected empty line between require statements.', - 'type': null + 'type': 'VariableDeclaration', + 'line': 9 } ], 'output': [ diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/valid.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/valid.js index 658b136c16de..a7e0415e659f 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/valid.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-lines-between-requires/test/fixtures/valid.js @@ -172,6 +172,20 @@ test = { }; valid.push( test ); +// Inline disable comment suppresses the rule for a specific require: +test = { + 'code': [ + '\'use strict\';', + '', + '// MODULES //', + '', + 'var tape = require( \'tape\' );', + '', + 'var isnan = require( \'@stdlib/math/base/assert/is-nan\' ); // eslint-disable-line no-empty-lines-between-requires' + ].join( '\n' ) +}; +valid.push( test ); + // EXPORTS //