Skip to content

build: add eslint.flat.config.js for ESLint v8 - #10967

Merged
kgryte merged 5 commits into
developfrom
philipp/gh54-flat-config
Aug 21, 2026
Merged

build: add eslint.flat.config.js for ESLint v8#10967
kgryte merged 5 commits into
developfrom
philipp/gh54-flat-config

Conversation

@Planeshifter

@Planeshifter Planeshifter commented Mar 15, 2026

Copy link
Copy Markdown
Member

Progresses stdlib-js/metr-issue-tracker#54.

Description

What is the purpose of this pull request?

This pull request:

  • Adds eslint.config.cjs flat config alongside the legacy .eslintrc.* configuration
  • Inlines stdlib rules as a runtime plugin object via lib/node_modules/@stdlib/_tools/eslint/rules/scripts/plugin.js.
  • Reuses existing rule definitions from etc/eslint/rules/.
  • Separates non-clonable rule options (remark plugin instances) from the main rules object to work around structuredClone limitations in ESLint's flat config internals.
  • Adds globals package for flat config environment definitions.
  • Legacy .eslintrc.* files remain in place as the default workflow.

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?

Files under lib/node_modules/ are hard-ignored by ESLint v8 flat config (**/node_modules/** is always ignored). Full lib/ linting via flat config requires ESLint v9, which allows !**/node_modules/ ignore overrides. This is expected and will be resolved in PR 11.

Other

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

Stacked on #10966. Usage: ESLINT_USE_FLAT_CONFIG=true npx eslint -c eslint.config.cjs <file>.

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

This PR was written primarily by Claude Code.


@stdlib-js/reviewers

@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from 676204c to 1b253a7 Compare March 15, 2026 14:29
@socket-security

socket-security Bot commented Mar 15, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​globals@​16.5.01001008596100

View full report

@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from 1b253a7 to fd4e835 Compare March 15, 2026 15:29
@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from fd4e835 to 6cba0ae Compare March 15, 2026 15:34
@socket-security

socket-security Bot commented Mar 15, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from 6cba0ae to 338fb5d Compare March 15, 2026 16:26
@Planeshifter Planeshifter changed the title build: add eslint.config.cjs for JavaScript targets on ESLint v8 build: add eslint.config.cjs for JavaScript targets on ESLint v8 (gh54 part V) Mar 15, 2026
@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from 0d008d7 to 0705d6b Compare March 15, 2026 17:48
@Planeshifter Planeshifter reopened this Mar 15, 2026
@Planeshifter Planeshifter added the METR Pull request associated with the METR project. label Mar 18, 2026
Base automatically changed from philipp/gh54-ts-toolchain-bump to develop August 19, 2026 01:12
@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch 3 times, most recently from 2f7e85f to 0a351ef Compare August 19, 2026 01:35
@Planeshifter
Planeshifter marked this pull request as ready for review August 19, 2026 02:31
@Planeshifter
Planeshifter requested review from a team and kgryte August 19, 2026 02:31
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 19, 2026
Comment thread eslint.flat.config.js
Comment thread eslint.config.cjs Outdated
Comment thread eslint.config.cjs Outdated
Comment thread eslint.config.cjs Outdated
Comment thread eslint.config.cjs Outdated

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left initial comments.

@kgryte kgryte added Needs Discussion Needs further discussion. Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Aug 19, 2026
@kgryte

kgryte commented Aug 19, 2026

Copy link
Copy Markdown
Member

This is expected and will be resolved in PR 11.

This could be a very large gap in time to effectively disable ALL of our custom ESLint rules. Have you thought through the implications of this? How are we going to handle linting in the interim and ensure we don't accumulate a bunch of technical debt?

@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from 81ff4c7 to ca7663f Compare August 20, 2026 05:13
@Planeshifter Planeshifter changed the title build: add eslint.config.cjs for JavaScript targets on ESLint v8 (gh54 part V) build: add eslint.flat.config.js for JavaScript targets on ESLint v8 (gh54 part V) Aug 20, 2026
@Planeshifter

Copy link
Copy Markdown
Member Author

This is expected and will be resolved in PR 11.

This could be a very large gap in time to effectively disable ALL of our custom ESLint rules. Have you thought through the implications of this? How are we going to handle linting in the interim and ensure we don't accumulate a bunch of technical debt?

Renamed the file to eslint.flat.config.js to ensure none of our ESLint tooling is picking up this configuration for now and the PR will not change anything about our existing linting.

@Planeshifter
Planeshifter force-pushed the philipp/gh54-flat-config branch from ca7663f to 6a92161 Compare August 20, 2026 05:19
@Planeshifter
Planeshifter requested a review from kgryte August 20, 2026 05:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 20, 2026

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kgryte kgryte removed Needs Changes Pull request which needs changes before being merged. Needs Discussion Needs further discussion. Needs Review A pull request which needs code review. labels Aug 21, 2026
Planeshifter and others added 5 commits August 21, 2026 03:06
Add flat config alongside the legacy `.eslintrc.*` configuration:

- Create `eslint.config.cjs` with base JS config, override blocks
  for benchmarks, examples, tests, and REPL namespace files
- Inline stdlib rules as a runtime plugin object via
  `lib/node_modules/@stdlib/_tools/eslint/rules/scripts/plugin.js`
- Reuse existing rule definitions from `etc/eslint/rules/`
- Separate non-clonable rule options (remark plugin instances) from
  the main rules object to work around `structuredClone` limitations
  in ESLint's flat config internals
- Add `globals` package for flat config environment definitions
- Legacy `.eslintrc.*` files remain in place as the default workflow

Usage (requires ESLint v8 with flat config enabled):

    ESLINT_USE_FLAT_CONFIG=true npx eslint -c eslint.config.cjs <file>

Note: files under `lib/node_modules/` are hard-ignored by ESLint v8
flat config. Full `lib/` linting via flat config requires ESLint v9,
which allows `!**/node_modules/` ignore overrides.

Ref: stdlib-js/metr-issue-tracker#54
Add a configPath option to stdlib/jsdoc-markdown-remark so the rule loads remark plugins internally while flat config receives only clonable data. Retain the existing config option and cover both forms in the rule tests.

Use the complete rule catalog directly, share the restricted-syntax policy by name, avoid object spread, and keep flat config opt-in through eslint.flat.config.js.
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte
kgryte force-pushed the philipp/gh54-flat-config branch from 54e2f61 to 3f8fbc0 Compare August 21, 2026 10:06
@kgryte kgryte changed the title build: add eslint.flat.config.js for JavaScript targets on ESLint v8 (gh54 part V) build: add eslint.flat.config.js for ESLint v8 Aug 21, 2026
@kgryte
kgryte merged commit 27489d3 into develop Aug 21, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

METR Pull request associated with the METR project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants