Skip to content

build: fix line reporting for no-empty-lines-between-requires lint rule - #14320

Merged
kgryte merged 1 commit into
developfrom
philipp/fix-no-empty-lines-between-requires-line-location
Aug 16, 2026
Merged

build: fix line reporting for no-empty-lines-between-requires lint rule#14320
kgryte merged 1 commit into
developfrom
philipp/fix-no-empty-lines-between-requires-line-location

Conversation

@Planeshifter

@Planeshifter Planeshifter commented Aug 16, 2026

Copy link
Copy Markdown
Member

Resolves stdlib-js/metr-issue-tracker#153.

Description

What is the purpose of this pull request?

This pull request:

  • changes the no-empty-lines-between-requires ESLint rule to report errors on the first require statement after the empty lines, rather than on the empty lines themselves
  • enables targeted suppression via // eslint-disable-line stdlib/no-empty-lines-between-requires
  • adds a test case verifying that inline disable comments work

Previously, the rule reported errors with node: null and a synthetic loc pointing at the blank lines between require statements. Since blank lines contain no code, // eslint-disable-line comments could not be placed there, making per-line suppression impossible. The only workaround was disabling the rule for the entire file.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

The key change in context.report():

- context.report({
-     'node': null,
-     'message': 'Unexpected empty line between require statements.',
-     'loc': loc,
-     'fix': fix
- });
+ context.report({
+     'node': currNode,
+     'message': 'Unexpected empty line between require statements.',
+     'fix': fix
+ });

By reporting on currNode (the require statement after the gap), ESLint uses that node's location. Users can now append // eslint-disable-line stdlib/no-empty-lines-between-requires to suppress the rule on that specific line.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written primarily by Claude Code under my direction.


@stdlib-js/reviewers

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) <noreply@anthropic.com>

---
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
---
@stdlib-bot stdlib-bot added the Tools Issue or pull request related to project tooling. label Aug 16, 2026
@Planeshifter Planeshifter changed the title fix: report no-empty-lines-between-requires error on the require line build: report no-empty-lines-between-requires error on the require line Aug 16, 2026
@Planeshifter
Planeshifter marked this pull request as ready for review August 16, 2026 04:41
@Planeshifter
Planeshifter requested review from a team and kgryte August 16, 2026 04:41
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 16, 2026
@kgryte kgryte changed the title build: report no-empty-lines-between-requires error on the require line build: fix line reporting for no-empty-lines-between-requires lint rule Aug 16, 2026
@kgryte
kgryte merged commit 7751a62 into develop Aug 16, 2026
56 checks passed
@kgryte
kgryte deleted the philipp/fix-no-empty-lines-between-requires-line-location branch August 16, 2026 06:19
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: fix line location in no-empty-lines-between-requires rule

3 participants