npm-pkg-lint 4.4.2 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -111,6 +111,28 @@ Verifies the presence of files specified in:
111
111
  - `bin`
112
112
  - `man`
113
113
 
114
+ ## `exports` paths
115
+
116
+ Requires all values in `exports` to start with `./`.
117
+
118
+ **Why?** The Node.js specification requires export paths to be relative paths starting with `./`.
119
+ Values not starting with `./` will be treated as package names by some runtimes and bundlers, which is almost certainly not the intent.
120
+
121
+ ## `import` before `require` in `exports`
122
+
123
+ Requires `import` and `module`, if either is present alongside `require`, to come before `require` in `exports`.
124
+
125
+ **Why?** Some runtimes and bundlers evaluate conditions in order and stop at the first match.
126
+ If `require` is listed before `import` (or `module`), ESM-capable consumers that support both may unexpectedly pick up the CJS build.
127
+ `module` is treated as an alias for `import` as it serves the same purpose for bundlers such as webpack.
128
+
129
+ ## `default` in `exports`
130
+
131
+ Requires `default`, if present, to be the last condition in `exports`.
132
+
133
+ **Why?** The `default` condition is a catch-all fallback.
134
+ If it is listed before more specific conditions (e.g. `require` or `import`) those conditions will never be reached by runtimes that support them.
135
+
114
136
  ## TypeScript `types` in `exports`
115
137
 
116
138
  Requires `types` to be the first condition in `exports`.
@@ -135,6 +157,23 @@ Requires only one of the two fields `types` and `typings` to be used, not both.
135
157
 
136
158
  **Why?** `typings` is an alias for `types` and if both are set it is unclear which is to be used (and could potentially be set to different values).
137
159
 
160
+ ## Protocol dependencies
161
+
162
+ Disallows dependencies that resolve outside the registry across all dependency fields (`dependencies`, `devDependencies`, `peerDependencies`, `optionalDependencies`).
163
+
164
+ **Why?** Protocol specifiers such as `file:`, `link:`, `github:` or `git+https:` reference local paths or remote git repositories instead of versioned registry packages.
165
+ Published packages should only depend on registry packages so that consumers can reliably install the same code.
166
+
167
+ Disallowed protocols:
168
+
169
+ - `file:` - local filesystem path
170
+ - `link:` - symlink
171
+ - `github:` / `gitlab:` / `bitbucket:` - platform shorthand
172
+ - `git:` / `git+https:` / `git+http:` / `git+ssh:` / `git+file:` - arbitrary git URL
173
+ - `http:` / `https:` - direct URL tarball
174
+ - `user/repo` - Github shorthand (without `github:` prefix)
175
+ - `user@host:path` - git URL (e.g. `git@github.com:user/repo.git`)
176
+
138
177
  ## Disallowed dependencies
139
178
 
140
179
  Disallows certain packages from being included as `dependencies` (use `devDependencies` or `peerDependencies` instead).