Skip to content

[lfx] Add preliminary docs for Lockfile Lint #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions websites/lfx.rushstack.io/docs/pages/cli/lflint-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: lockfile-lint check
---

> You can use `lflint` as a shorthand for the `lockfile-lint` shell command. In CI scripts, it is recommended to include the full name for readability.

```
usage: lockfile-lint check [-h]

This command applies the policies that are configured in lockfile-lint.json,
reporting any problems found in your PNPM workspace.

Optional arguments:
-h, --help Show this help message and exit.
```
15 changes: 15 additions & 0 deletions websites/lfx.rushstack.io/docs/pages/cli/lflint-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: lockfile-lint init
---

> You can use `lflint` as a shorthand for the `lockfile-lint` shell command. In CI scripts, it is recommended to include the full name for readability.

```
usage: lockfile-lint init [-h]

This command initializes a new lockfile-lint.json config file. The created
template file includes source code comments that document the settings.

Optional arguments:
-h, --help Show this help message and exit.
```
20 changes: 20 additions & 0 deletions websites/lfx.rushstack.io/docs/pages/cli/lfx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: lockfile-explorer
---

> You can use `lfx` as a shorthand for the `lockfile-explorer` shell command. In CI scripts, it is recommended to include the full name for readability.

```
usage: lockfile-explorer [-h] [-d] [--subspace SUBSPACE_NAME]

Lockfile Explorer is a desktop app for investigating and solving version
conflicts in a PNPM workspace.

Optional arguments:
-h, --help Show this help message and exit.
-d, --debug Show the full call stack if an error occurs while
executing the tool
--subspace SUBSPACE_NAME
Specifies an individual Rush subspace to check. The
default value is "default".
```
99 changes: 99 additions & 0 deletions websites/lfx.rushstack.io/docs/pages/lint/lockfile-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Introduction
---

**Lockfile Lint** is a companion tool for preventing problems from reoccurring, after you've solved them using Lockfile Explorer. Similar to ESLint, it provides a config file **lockfile-lint.json** where you can define rules that check for various issues in your lockfile.

## Quick start

1. Lockfile Lint is included in the same package as Lockfile Explorer. If you didn't do so already, install it like this:

```shell
npm install --global @rushstack/lockfile-explorer
```

2. Create the **lockfile-lint.json** config file:

```shell
cd my-rush-repo

lockfile-lint init
```

3. Edit the config file to enable policies that you want to check.

4. Test the policies:

```shell
lockfile-lint check
```

If issues are found, the output might look like this:

```
Rush Lockfile Lint - https://lfx.rushstack.io/

Checking project "my-toolchain"
Checking project "my-app"
Checking project "my-controls"

PROBLEM: [restrict-versions] The version of "whatwg-fetch" should match "2.x"; actual version is "3.6.2"

PROBLEM: [restrict-versions] The version of "colors" should match "2.x"; actual version is "1.4.0"
```

5. Add `lockfile-lint` to your CI validation pipeline. When the tool reports problems, the process exit code will be nonzero, causing the build to fail.

## Config file

**common/config/lockfile-lint/lockfile-lint.json**

```js
/**
* Config file for Lockfile Lint. For more info, please visit: https://lfx.rushstack.io
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/lockfile-explorer/lockfile-lint.schema.json",

/**
* The list of rules to be checked by Lockfile Lint. For each rule configuration, the
* type of rule is determined by the `rule` field.
*/
"rules": [
// /**
// * The `restrict-versions` rule enforces that direct and indirect dependencies must
// * satisfy a specified version range.
// */
// {
// "rule": "restrict-versions",
//
// /**
// * The name of a workspace project to analyze.
// */
// "project": "@my-company/my-app",
//
// /**
// * Indicates the package versions to be checked. The `requiredVersions` key is
// * the name of an NPM package, and the value is a SemVer range. If the project has
// * that NPM package as a dependency, then its version must satisfy the SemVer range.
// * This check also applies to devDependencies and peerDependencies, as well as any
// * indirect dependencies of the project.
// */
// "requiredVersions": {
// /**
// * For example, if `react-router` appears anywhere in the dependency graph of
// * `@my-company/my-app`, then it must be version 5 or 6.
// */
// "react-router": "5.x || 6.x",
// "react": "^18.3.0",
// "react-dom": "^18.3.0"
// }
// }
]
}
```

## See also

- [lockfile-lint init](../cli/lflint-init.md) command
- [lockfile-lint check](../cli/lflint-check.md) command
12 changes: 12 additions & 0 deletions websites/lfx.rushstack.io/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ const sidebars = {
// 'pages/scenarios/phantom_dependencies'
]
},
{
type: 'category',
label: 'Lockfile Lint (EXPERIMENTAL)',
collapsible: false,
items: ['pages/lint/lockfile-lint']
},
{
type: 'category',
label: 'Command line',
collapsible: false,
items: ['pages/cli/lfx', 'pages/cli/lflint-init', 'pages/cli/lflint-check']
},
{
type: 'category',
label: 'Support',
Expand Down