Skip to content

feat: support a user level ignore file via globalIgnoreFile#287

Merged
owlstronaut merged 1 commit into
npm:mainfrom
ljharb:feat/global-ignore-file
May 22, 2026
Merged

feat: support a user level ignore file via globalIgnoreFile#287
owlstronaut merged 1 commit into
npm:mainfrom
ljharb:feat/global-ignore-file

Conversation

@ljharb

@ljharb ljharb commented May 13, 2026

Copy link
Copy Markdown
Contributor

Adds a globalIgnoreFile option pointing to a single ignore file owned by the user and applied to every directory pack. Its parsed contents are injected as a new globalRules synthetic rule set, placed between defaultRules and package.json in the precedence chain. A package's local .npmignore, and any specific path listed in its files array (which feeds strictRules), continue to take precedence over the global rules. The file is read once on the root walker and cached on globalIgnoreRules so child walkers reuse the parsed content without reopening the file. Bundled dependencies never receive the option, since they ship third party code as is.

Includes unit tests for default layering, coexistence with a local .npmignore, the package "files" carve out, missing file no op, subdirectory propagation, and bundled dependency isolation.

Required for npm/cli#9351

@ljharb
ljharb requested a review from a team as a code owner May 13, 2026 19:38
Comment thread lib/index.js
Comment thread test/global-ignore-file.js
Comment thread lib/index.js
Adds a `globalIgnoreFile` option pointing to a single ignore file owned by the user and applied to every directory pack.
Its parsed contents are injected as a new `globalRules` synthetic rule set, placed between `defaultRules` and `package.json` in the precedence chain.
A package's local `.npmignore`, and any specific path listed in its `files` array (which feeds `strictRules`), continue to take precedence over the global rules.
The file is read once on the root walker and cached on `globalIgnoreRules` so child walkers reuse the parsed content without reopening the file.
Bundled dependencies never receive the option, since they ship third party code as is.

Includes unit tests for default layering, coexistence with a local `.npmignore`, the package "files" carve out, missing file no op, subdirectory propagation, and bundled dependency isolation.
@ljharb
ljharb force-pushed the feat/global-ignore-file branch from 004bf73 to f73d516 Compare May 18, 2026 17:05
@owlstronaut
owlstronaut merged commit 1369ec3 into npm:main May 22, 2026
23 checks passed
@github-actions github-actions Bot mentioned this pull request May 22, 2026
owlstronaut pushed a commit that referenced this pull request May 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[11.1.0](v11.0.0...v11.1.0)
(2026-05-22)
### Features
*
[`1369ec3`](1369ec3)
[#287](#287) support a user
level ignore file via globalIgnoreFile (#287) (@ljharb)
### Chores
*
[`e1f3d11`](e1f3d11)
[#289](#289) bump
@npmcli/eslint-config from 6.0.1 to 7.0.0 (#289) (@dependabot[bot])

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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