feat: add Node.js recommended presets - #2241
Merged
Merged
Conversation
Deploying rslint with
|
| Latest commit: |
5157459
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fe86a0c8.rslint.pages.dev |
| Branch Preview URL: | https://feat-node-presets.rslint.pages.dev |
fansenze
marked this pull request as draft
September 21, 2026 13:33
Contributor
fansenze
marked this pull request as ready for review
September 21, 2026 14:06
chenjiahan
reviewed
Sep 22, 2026
elecmonkey
reviewed
Sep 22, 2026
elecmonkey
reviewed
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The native
node/*rules currently require manual configuration. Add the three recommended Node.js presets to@rslint/core, including the language settings needed for their rules to work in ES modules and CommonJS.Changes
nodePlugin.configs.recommended,nodePlugin.configs.recommendedModule, andnodePlugin.configs.recommendedScript, using camelCase keys for the corresponding presets in eslint-plugin-n@18.3.0.node/*prefix. Preserve upstream globals access levels,sourceType, and the syntax rule'signoresoptions. The unimplementedprocess-exit-as-throwrule is explicitly documented and omitted.recommendedselect the nearest valid working-directory package's type and apply.cjs/.mjsoverrides, including dotfiles. Keep package lookup and globals loading lazy so importing the core root does not load environment assets.recommended,recommendedModule, andrecommendedScriptto upstreamrecommended,recommended-module, andrecommended-script. Fix three broken links in the Node publication-rule documentation exposed by the docs build.The presets use core's bundled globals catalog: all 134 globals supplied by upstream retain their access levels, with seven additional globals from core's newer catalog. Auto selection uses
process.cwd(), as upstream does, but runs whenrecommendedis accessed instead of at import time. APIcwddoes not affect it; callers whose process directory differs from the lint project, or nested packages with different types, should use explicit presets.sourceTypeaffects lint scopes, not TypeScript parsing.Usage
Validation
On macOS arm64 with Node.js 22.18.0:
pnpm --filter @rslint/core build:bin— passed.pnpm --filter @rslint/core build:js— passed, including declarations.CI=true pnpm --dir packages/rslint exec rs test run tests/define-config.test.ts tests/config-loader.test.ts tests/globals.test.ts— 99 passed.CI=true pnpm --dir packages/rslint-test-tools exec rs test run tests/cli/js-config/presets.test.ts tests/cli/js-config/language-options-globals.test.ts— 50 passed.TMPDIRbeneath an ESM package, reproduced the missing-package fixture failure before the fix.TMPDIR=<isolated-dir> CI=true pnpm --dir packages/rslint-test-tools exec rs test run tests/cli/js-config/presets.test.ts— all 37 passed after adding the CommonJS fixture boundary.pnpm pack, installed the tarballs into an isolated temporary project withoutglobals, and ran the packaged CLI: all three presets passed in both module and CommonJS packages across.js,.mjs, and.cjs(6 runs, 18 files). Verified root import loads no globals assets and preset normalization loads onlynode.jsonandes2021.json.eslint-plugin-n@18.3.0package: all 13 rule configurations and 134 upstream globals match after prefix mapping; confirmed the upstream duplicateObject.fromEntriesdiagnostics from the syntax and builtins rules.pnpm --filter @rslint/website build— passed; verified the rendered preset names, API mapping links, and the repaired anchor.pnpm run format:check,pnpm run check-spellwith all changed text paths explicitly supplied, andgit diff --check— passed.No Go implementation changed. Full-repository tests and other platforms were not run.