-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max J. Polster
committed
Mar 6, 2024
1 parent
ced3e82
commit 0873433
Showing
2 changed files
with
40 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
|
||
# 2.0.0 | ||
+ **Breaking change:** Requires node 14 or above. | ||
# 4.0 | ||
+ **Breaking change:** Config now uses rules as top level properties instead of patterns and rules in a separate object. | ||
+ **Breaking change:** Version 3 package locks are now the only supported format. | ||
+ **Breaking change:** `--fix-duplicates` argument has been removed. Update dependencies or use npm overrides if necessary. | ||
|
||
# 3.1 | ||
+ Support version 2 package lock files. | ||
|
||
# 3.0.0 | ||
# 3.0 | ||
+ **Breaking change:** The config format has been changed: | ||
+ Rule names are now camel cased. | ||
+ An `extends` property can be used to move common properties to other files. | ||
+ A config can now also be a filename, or an array of configs. | ||
+ New command line flag added `--fix-duplicates`. | ||
|
||
# 3.1.0 | ||
+ Support version 2 package lock files. | ||
# 2.0 | ||
+ **Breaking change:** Requires node 14 or above. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,50 @@ | ||
# @netatwork/check-npm-dependencies | ||
A linter for bundled npm dependencies | ||
A linter for package locks. | ||
|
||
## Installation | ||
```bash | ||
npm i -D @netatwork/check-npm-dependencies | ||
``` | ||
|
||
## Configuration | ||
```json5 | ||
```js | ||
// package.json | ||
{ | ||
"nawCheckNpmDependencies": { | ||
"dev": false, | ||
"patterns": [ | ||
"*" | ||
], | ||
"rules": { | ||
"noDuplicates": true, | ||
"noMissmatch": true | ||
} | ||
} | ||
... | ||
"nawCheckNpmDependencies": { | ||
"extends": "./some-shared-config.json", | ||
"noDuplicates": [ | ||
"@example/*" | ||
], | ||
"sameVersions": [ | ||
"@example/*", | ||
[ | ||
"example-a-*", | ||
"example-b" | ||
] | ||
] | ||
} | ||
} | ||
``` | ||
+ nawCheckNpmDependencies `<Config>` - Can be one of the following: | ||
+ `<Config[]>` - An array of configuration objects. | ||
+ `<string>` - A filename of a json(5) file to load the config from. | ||
+ `<object>` - An object with the following properties: | ||
+ extends `<string>` - Optional. A filename of a json(5) file to load and use as fallback for unspecified properties. | ||
+ dev `<boolean>` - Optional. True, to also check dev dependencies. Default is `false`. | ||
+ patterns `<string[]>` - Optional. An array of gitignore like patterns to include packages. If not specified, all packages are checked. | ||
+ rules `<object>` - Optional. An object with rules to use. If not specified, all rules are used. | ||
+ `noDuplicates` - Assert that no package is installed on multiple paths. | ||
+ `noMissmatch` - Assert that only one version is required. | ||
+ **nawCheckNpmDependencies** `<Config>` - Can be a path to load the config from or an object with the following options: | ||
+ **extends** `<string>` - A path to load a config from to extend. | ||
+ **noDuplicates** `<string[]>` - An array of package name patterns to check for duplicates. | ||
+ In the example above, all packages within the `@example` scope are checked for duplicates. | ||
+ **sameVersions** `<(string | string[])[]>` - An array of patterns or pattern groups to ensure that all packages within a group have the same versions. | ||
+ In the example above, all packages within the `@example` scope are checked for the same version and `example-a-*` and `example-b` are checked for the same version. | ||
|
||
## Usage | ||
Run from a script: | ||
```bash | ||
npx naw-check-npm-dependencies | ||
# Run via npx: | ||
npx naw-check-npm-dependencies [...args] | ||
``` | ||
Or add a script to your `package.json` | ||
```json5 | ||
```js | ||
// Or add to your package.json: | ||
{ | ||
"scripts": { | ||
"test": "naw-check-npm-dependencies && ..." | ||
} | ||
"scripts": { | ||
"test": "naw-check-npm-dependencies ..." | ||
} | ||
} | ||
``` | ||
|
||
Some issues can be resolved automatically:<br> | ||
If `--fix-duplicates` is specified, the cli will attempt to remove duplicate package installations and then perform a clean install: | ||
```bash | ||
npx naw-check-npm-dependencies --fix-duplicates | ||
``` | ||
+ `--context | -c <path>` - The path at which to look for a `package.json` and `package-lock.json`. |