Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
| [require-name](docs/rules/require-name.md) | Requires the `name` property to be present. | ✔️ ✅ 📦 | | | |
| [require-optionalDependencies](docs/rules/require-optionalDependencies.md) | Requires the `optionalDependencies` property to be present. | | | | |
| [require-peerDependencies](docs/rules/require-peerDependencies.md) | Requires the `peerDependencies` property to be present. | | | | |
| [require-repository](docs/rules/require-repository.md) | Requires the `repository` property to be present. | 📦 | | | |
| [require-sideEffects](docs/rules/require-sideEffects.md) | Requires the `sideEffects` property to be present. | 📦 | | | |
| [require-type](docs/rules/require-type.md) | Requires the `type` property to be present. | ✔️ ✅ 📦 | | | |
| [require-types](docs/rules/require-types.md) | Requires the `types` property to be present. | | | | |
Expand Down
97 changes: 97 additions & 0 deletions docs/rules/require-repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# require-repository

💼 This rule is enabled in the 📦 `recommended-publishable` config.

<!-- end auto-generated rule header -->

This rule checks for the existence of the `"repository"` property in a package.json, and reports a violation if it doesn't exist.

Example of **incorrect** code for this rule:

```json
{
"name": "thee-silver-mt-zion",
"version": "13.0.0"
}
```

Examples of **correct** code for this rule:

```json
{
"name": "thee-silver-mt-zion",
"version": "13.0.0",
"repository": "github:owner/project"
}
```

```json
{
"name": "thee-silver-mt-zion",
"version": "13.0.0",
"repository": {
"type": "git",
"url": "https://github.com/owner/project"
}
}
```

## Options

<!-- begin auto-generated rule options list -->

| Name | Description | Type | Default |
| :-------------- | :------------------------------------------------------------------------------------------ | :------ | :------ |
| `ignorePrivate` | Determines if this rule should be enforced when the package's `private` property is `true`. | Boolean | `false` |

<!-- end auto-generated rule options list -->

You can set the `ignorePrivate` option to `true` to ignore package.json files with `"private": true` (default: `false`).

```json
{
"package-json/require-repository": [
"error",
{
"ignorePrivate": false
}
]
}
```

Example of **incorrect** code for this rule with the `{ "ignorePrivate": false }` option:

```json
{
"private": true
}
```

Example of **correct** code for this rule with the `{ "ignorePrivate": false }` option:

```json
{
"private": true,
"repository": "github:owner/project"
}
```

Example of **incorrect** code for this rule with the `{ "ignorePrivate": true }` option:

```json
{
"private": false
}
```

```json
{}
```

Example of **correct** code for this rule with the `{ "ignorePrivate": true }` option:

```json
{
"private": true
}
```
1 change: 1 addition & 0 deletions src/rules/require-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const properties: [name: string, options?: CreateRequirePropertyRuleOptions][] =
["name", { ignorePrivateDefault: true, isRecommended: true }],
["optionalDependencies"],
["peerDependencies"],
["repository", { category: "Publishable" }],
["sideEffects", { category: "Publishable" }],
["type", { isRecommended: true }],
["types"],
Expand Down
Loading