Skip to content

feat: apply ESLint bulk suppressions below ESLint 10 - #310

Merged
alexander-akait merged 1 commit into
mainfrom
test/eslint-suppressions
Sep 7, 2026
Merged

feat: apply ESLint bulk suppressions below ESLint 10#310
alexander-akait merged 1 commit into
mainfrom
test/eslint-suppressions

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

Closes #291. Supersedes #292, whose conflicts this carries forward instead.

Bulk suppressions now work on every ESLint this plugin supports:

  • ESLint 10 takes applySuppressions and suppressionsLocation as constructor options, and the plugin already hands unrecognised ESLint options to the ESLint class as they are. Nothing needed.
  • ESLint 9.24 and later ships the same SuppressionsService but wires it into its CLI alone, and the constructor rejects the options outright with Invalid Options: - Unknown options: applySuppressions. The plugin now drives the service itself after linting.
  • Below 9.24 the option raises an error naming the version it needs, rather than silently reporting the very violations the user recorded as suppressed.

The ESLint 9 path resolves the file and the paths recorded inside it against ESLint's cwd, and reads the default name eslint-suppressions.json when no location is given — the same rules ESLint 10 applies, so one config behaves identically on both and the tests run unmodified against each.

Two details behind that:

  • ESLint's exports hides the service, so it is loaded by absolute path rather than by specifier. The package directory comes from resolving eslint/package.json, which respects eslintPath and works on Windows. feat: support bulk suppressions #292 stripped /lib/api.js off the resolved entry with a POSIX-only regexp, so its fallback silently did nothing there.
  • DEFAULT_SUPPRESSIONS_FILENAME is an ESLint 10 addition. ESLint 9 hardcodes the name in its CLI, so reading the constant gave undefined and a paths[1] must be of type string crash — caught only by running the suite against 9.

Credit for finding the bug and for the shape of these cases goes to @viddo.

What kind of change does this PR introduce?

feat.

Did you add tests for your changes?

Yes. test/suppressions.test.js covers eight cases: no file, the default file, a named suppressionsLocation, an absolute one, a nested file recorded relative to cwd, a suppressions file outside cwd reached with ../, partial suppression that still reports the rest, and a location naming no file. They are gated at ESLint 9.24 and run on both majors — 132 passing on ESLint 10, 134 on ESLint 9 (the two eslintrc suites also run there). I checked they hold something: deleting applySuppressions from getESLintOptions turns three of them red on ESLint 10, and the ESLint 9 path was written against a failing suite.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

The README's Suppressions section under ## ESLint covers the options, the cwd caveat and the version requirement. The changeset is a minor.

Use of AI

Written with Claude Code, driven interactively. I asked it to fold #292 into this PR; it established that ESLint 10 makes #292's private-API module unnecessary, wrote the ESLint 9 fallback against the same service, and found the two portability defects above by running the suite on both majors. I reviewed the result.

Note

The first commit of this PR reached main already, through #311's squash while this was stacked under it. What is left here is the feature.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy

@alexander-akait
alexander-akait force-pushed the test/eslint-suppressions branch from 8231e93 to 127dfd3 Compare September 7, 2026 15:06
ESLint 10 takes `applySuppressions` and `suppressionsLocation` as constructor
options and the plugin already passes them through. ESLint 9.24 ships the same
service but wires it into its CLI alone, so the plugin now drives it after
linting, resolving the file and the paths inside it against ESLint's `cwd`
exactly as ESLint 10 does. Below 9.24 the option raises an error naming the
version rather than silently reporting what was meant to be suppressed.

The service is read by path because ESLint's `exports` hides it; the manifest
is resolved through `eslint/package.json`, which works on Windows too. Covers
an absolute `suppressionsLocation`, a nested file and a suppressions file
outside `cwd`, the cases #292 raised.

Closes #291. Supersedes #292.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy
@alexander-akait
alexander-akait force-pushed the test/eslint-suppressions branch from dedbecb to 751d480 Compare September 7, 2026 15:41
@alexander-akait alexander-akait changed the title test: cover ESLint bulk suppressions feat: apply ESLint bulk suppressions below ESLint 10 Sep 7, 2026
@alexander-akait
alexander-akait merged commit 8ed83c6 into main Sep 7, 2026
13 checks passed
@alexander-akait
alexander-akait deleted the test/eslint-suppressions branch September 7, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors despite bulk suppressions

1 participant