npm-pkg-lint 5.3.2 → 5.4.0
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 +41 -1
- package/dist/config.d.ts +25 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +7 -0
- package/dist/index.js +204 -84
- package/dist/index.js.map +4 -4
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Core principles:
|
|
|
19
19
|
|
|
20
20
|
```
|
|
21
21
|
usage: index.js [-h] [-v] [-t TARBALL] [-p PKGFILE] [--cache CACHE]
|
|
22
|
-
[--allow-dependency DEPENDENCY] [--allow-types-dependencies]
|
|
22
|
+
[--config FILE] [--allow-dependency DEPENDENCY] [--allow-types-dependencies]
|
|
23
23
|
[--allow-file FILE] [--ignore-missing-fields]
|
|
24
24
|
[--ignore-node-version [MAJOR]]
|
|
25
25
|
|
|
@@ -33,6 +33,7 @@ optional arguments:
|
|
|
33
33
|
-p PKGFILE, --pkgfile PKGFILE
|
|
34
34
|
specify package.json location
|
|
35
35
|
--cache CACHE specify cache directory
|
|
36
|
+
--config FILE specify configuration file
|
|
36
37
|
--allow-dependency DEPENDENCY
|
|
37
38
|
explicitly allow given dependency (can be given
|
|
38
39
|
multiple times or as a comma-separated list)
|
|
@@ -58,6 +59,44 @@ This can be used to quickly examine packages from https://www.npmjs.com/:
|
|
|
58
59
|
|
|
59
60
|
> curl -s \$(npm view lodash dist.tarball) | npx npm-pkg-lint -t -
|
|
60
61
|
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Options can be set in a configuration file instead of (or in addition to) command-line arguments.
|
|
65
|
+
The configuration file is an ES module with the configuration as default export:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { defineConfig } from "npm-pkg-lint/config";
|
|
69
|
+
|
|
70
|
+
export default defineConfig({
|
|
71
|
+
allowTypesDependencies: true,
|
|
72
|
+
allowFiles: ["**/*.spec.ts"],
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The configuration can be stored in one of these locations:
|
|
77
|
+
|
|
78
|
+
1. `npm-pkg-lint.config.{js,mjs,ts,mts}`
|
|
79
|
+
2. `config/npm-pkg-lint.config.{js,mjs,ts,mts}`
|
|
80
|
+
3. `.github/npm-pkg-lint.config.{js,mjs,ts,mts}`
|
|
81
|
+
4. `.gitlab/npm-pkg-lint.config.{js,mjs,ts,mts}`
|
|
82
|
+
|
|
83
|
+
It is an error if more than one configuration file is found.
|
|
84
|
+
Use `--config` to specify the filename explicitly.
|
|
85
|
+
|
|
86
|
+
> [!NOTE]
|
|
87
|
+
> TypeScript configuration files (`.ts` and `.mts`) are loaded using Node.js native type stripping and requires a Node.js version supporting it.
|
|
88
|
+
|
|
89
|
+
| Option | CLI argument | Type |
|
|
90
|
+
| ------------------------ | ---------------------------- | --------------------- |
|
|
91
|
+
| `allowDependencies` | `--allow-dependency` | `string[]` |
|
|
92
|
+
| `allowFiles` | `--allow-file` | `string[]` |
|
|
93
|
+
| `allowTypesDependencies` | `--allow-types-dependencies` | `boolean` |
|
|
94
|
+
| `ignoreMissingFields` | `--ignore-missing-fields` | `boolean` |
|
|
95
|
+
| `ignoreNodeVersion` | `--ignore-node-version` | `boolean` or `number` |
|
|
96
|
+
|
|
97
|
+
If an option is set both on the command line and in the configuration file the command line takes precedence.
|
|
98
|
+
For lists (`allowDependencies` and `allowFiles`) the command line replaces the list from the configuration file, they are not merged.
|
|
99
|
+
|
|
61
100
|
## Github Action
|
|
62
101
|
|
|
63
102
|
This tool can be used directly with Github Actions:
|
|
@@ -80,6 +119,7 @@ This tool can be used directly with Github Actions:
|
|
|
80
119
|
| allow-dependencies | `-` | Comma-separated list of dependencies to explicitly allow even if they would yield an error |
|
|
81
120
|
| allow-files | `-` | Comma-separated list of filenames or globs to explicitly allow in tarball even if they would yield an error |
|
|
82
121
|
| build | `"build"` | Build command (executed with `npm run`). Set to `false` to disable build. |
|
|
122
|
+
| config | `-` | Path to configuration file (see `--config` CLI argument) |
|
|
83
123
|
| folders | `"."` | Space-separated list of folder to run in. |
|
|
84
124
|
| ignore-node-version | - | Ignore error for outdated node version (see --ignore-node-version CLI argument) |
|
|
85
125
|
| npm-pack | `true` | When enabled `npm pack` is run automatically |
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options available in the configuration file.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface UserConfig {
|
|
7
|
+
/** Dependencies explicitly allowed even if they would yield an error */
|
|
8
|
+
readonly allowDependencies?: string[];
|
|
9
|
+
/** Filenames or globs explicitly allowed in the tarball */
|
|
10
|
+
readonly allowFiles?: string[];
|
|
11
|
+
/** Allow production dependencies to `@types/*` */
|
|
12
|
+
readonly allowTypesDependencies?: boolean;
|
|
13
|
+
/** Ignore errors for missing fields */
|
|
14
|
+
readonly ignoreMissingFields?: boolean;
|
|
15
|
+
/** Ignore error for outdated node version, optionally restricted to a major version */
|
|
16
|
+
readonly ignoreNodeVersion?: boolean | number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper providing type checking and autocompletion for the configuration file.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function defineConfig(config: UserConfig): UserConfig;
|
|
24
|
+
|
|
25
|
+
export {};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// src/config/define-config.ts
|
|
7
|
+
function defineConfig(config) {
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
defineConfig
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/config/define-config.ts"],
|
|
4
|
+
"sourcesContent": ["/* istanbul ignore file -- IDE helper only */\n\nimport { type UserConfig } from \"./types\";\n\n/**\n * Helper providing type checking and autocompletion for the configuration file.\n *\n * @public\n */\nexport function defineConfig(config: UserConfig): UserConfig {\n\treturn config;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AASO,SAAS,aAAa,QAAgC;AAC5D,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|