Skip to content

feat(node): add no-restricted-import rule - #2184

Merged
elecmonkey merged 2 commits into
mainfrom
feat/node-no-restricted-import
Sep 16, 2026
Merged

elecmonkey merged 2 commits into
mainfrom
feat/node-no-restricted-import

Conversation

@fansenze

@fansenze fansenze commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Add node/no-restricted-import to restrict imports and re-exports by module name or resolved file path.

Refs #475.

Changes

  • Port the rule from eslint-plugin-n v18.3.0, including literal dynamic imports, type-only imports, ordered glob exclusions, custom messages, and absolute-path restrictions.
  • Reuse the Node import visitor and resolver, rslint's JavaScript value and UTF-16 helpers, and tsgo's path utilities. Share the small glob adapter with path conversion; keep restriction ordering and diagnostics in the rule.
  • Keep normalized paths at the resolver/VFS boundary and match native filesystem paths without rewriting the user's glob. Cover Windows rooted paths, drive letters, UNC shares, and platform-specific separators using tsgo and Go's standard library.
  • Avoid compiling regular expressions for literal patterns and reuse resolution options within each file.
  • Add the schema, documentation, all 31 upstream cases and 10 documentation cases, plus Go coverage for options, AST forms, Unicode, and path resolution.

Validation: scoped Go tests passed on macOS arm64 and Linux arm64, and CI Go tests passed on Linux x64. Native Windows npm integration passed, including all 41 cases in the new rule's upstream/documentation mirror. Locally, four JS integration files have 219 passing tests and 3 existing skips; eight real source files have all 32 diagnostics matching the pinned upstream. Catalog checks, scoped golangci-lint, builds, formatting (including an independent rule Markdown check), and explicit changed-file spell checks passed. Temporary Go benchmarks were run and are excluded from this PR.

Current CI limitations: the Windows Go job hit linker memory exhaustion (VirtualAlloc, errno 1455) before reaching the affected unit-test packages. GitHub rejected a targeted rerun while the encompassing workflow remains active. The CI spell step failed during installation because the freshly released cspell-glob dependency does not satisfy minimumReleaseAge; the local changed-file spell check passed.

@elecmonkey
elecmonkey enabled auto-merge (squash) September 16, 2026 09:33
@elecmonkey
elecmonkey merged commit eaa9cc7 into main Sep 16, 2026
25 of 28 checks passed
@elecmonkey
elecmonkey deleted the feat/node-no-restricted-import branch September 16, 2026 09:56
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.

2 participants