Skip to content

Commit 0ec0b35

Browse files
committed
feat(lint-package-json): lint-package-json util
1 parent 14956cb commit 0ec0b35

11 files changed

Lines changed: 147 additions & 71 deletions

File tree

.github/workflows/checks.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,24 @@ jobs:
1515
uses: actions/checkout@v2
1616
- name: Check editorconfig
1717
uses: editorconfig-checker/action-editorconfig-checker@v1
18+
package-json:
19+
runs-on: ubuntu-latest
20+
name: Checking package.json files
21+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
22+
steps:
23+
- name: Checkout the repository
24+
uses: actions/checkout@v2
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v2.0.1
27+
with:
28+
version: 6
29+
- name: Install Node.js
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: 16
33+
cache: 'pnpm'
34+
- name: Install dependencies
35+
run: pnpm install
36+
- name: Check package.json files
37+
if: success()
38+
run: pnpm lint:package-json

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Scripts and configs for TrigenSoftware's projects.
2727
| [`@trigen/babel-preset`](packages/babel-preset#readme) | [![NPM version][babel-preset-npm]][babel-preset-npm-url] | [![Dependencies status][babel-preset-deps]][babel-preset-deps-url] |
2828
| [`@trigen/browserslist-config`](packages/browserslist-config#readme) | [![NPM version][browserslist-config-npm]][browserslist-config-npm-url] | |
2929
| [`@trigen/eslint-config`](packages/eslint-config#readme) | [![NPM version][eslint-config-npm]][eslint-config-npm-url] | [![Dependencies status][eslint-config-deps]][eslint-config-deps-url] |
30+
| [`@trigen/lint-package-json`](packages/lint-package-json#readme) | [![NPM version][lint-package-json-npm]][lint-package-json-npm-url] | [![Dependencies status][lint-package-json-deps]][lint-package-json-deps-url] |
3031
| [`@trigen/npm-package-json-lint-config`](packages/npm-package-json-lint-config#readme) | [![NPM version][npm-package-json-lint-config-npm]][npm-package-json-lint-config-npm-url] | [![Dependencies status][npm-package-json-lint-config-deps]][npm-package-json-lint-config-deps-url] |
3132

3233
<!-- babel-preset -->
@@ -50,6 +51,14 @@ Scripts and configs for TrigenSoftware's projects.
5051
[eslint-config-deps]: https://img.shields.io/librariesio/release/npm/@trigen/eslint-config
5152
[eslint-config-deps-url]: https://libraries.io/npm/@trigen%2Feslint-config/tree
5253

54+
<!-- lint-package-json -->
55+
56+
[lint-package-json-npm]: https://img.shields.io/npm/v/%40trigen/lint-package-json.svg
57+
[lint-package-json-npm-url]: https://www.npmjs.com/package/@trigen/lint-package-json
58+
59+
[lint-package-json-deps]: https://img.shields.io/librariesio/release/npm/@trigen/lint-package-json
60+
[lint-package-json-deps-url]: https://libraries.io/npm/@trigen%2Fnpm-package-json-lint-config/tree
61+
5362
<!-- npm-package-json-lint-config -->
5463

5564
[npm-package-json-lint-config-npm]: https://img.shields.io/npm/v/%40trigen/npm-package-json-lint-config.svg

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"node": ">=14"
1818
},
1919
"scripts": {
20-
"lint:package-json": "npmPkgJsonLint .",
20+
"lint:package-json": "lint-package-json --monorepo",
2121
"lint": "eslint 'packages/**/*.{js,jsx,ts,tsx}'",
2222
"jest": "NODE_OPTIONS=--experimental-vm-modules jest -c jest.config.json",
2323
"test": "run -p lint jest",
@@ -37,7 +37,7 @@
3737
"@swc/jest": "^0.2.14",
3838
"@trigen/browserslist-config": "workspace:*",
3939
"@trigen/eslint-config": "workspace:*",
40-
"@trigen/npm-package-json-lint-config": "workspace:*",
40+
"@trigen/lint-package-json": "workspace:*",
4141
"@trigen/scripts": "workspace:*",
4242
"@types/node": "^17.0.8",
4343
"clean-publish": "^4.0.0",

packages/eslint-config/src/rules/getExtensionRules.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable security/detect-object-injection */
21
const commonRules = require('./common').rules
32
const es6Rules = require('./es6').rules
43

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@trigen/eslint-config/esm"
4+
]
5+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# @trigen/lint-package-json
2+
3+
[![NPM version][npm]][npm-url]
4+
[![Node version][node]][node-url]
5+
[![Dependencies status][deps]][deps-url]
6+
[![Build status][build]][build-url]
7+
8+
[npm]: https://img.shields.io/npm/v/%40trigen/lint-package-json.svg
9+
[npm-url]: https://npmjs.com/package/@trigen/lint-package-json
10+
11+
[node]: https://img.shields.io/node/v/%40trigen/lint-package-json.svg
12+
[node-url]: https://nodejs.org
13+
14+
[deps]: https://img.shields.io/librariesio/release/npm/@trigen/lint-package-json
15+
[deps-url]: https://libraries.io/npm/@trigen%2Feslint-config/tree
16+
17+
[build]: https://img.shields.io/github/workflow/status/TrigenSoftware/scripts/CI.svg
18+
[build-url]: https://github.com/TrigenSoftware/scripts/actions
19+
20+
Shortcut to run npm-package-json-lint with @trigen/npm-package-json-lint-config.
21+
22+
## Install
23+
24+
```bash
25+
pnpm add -D @trigen/lint-package-json
26+
# or
27+
yarn add -D @trigen/lint-package-json
28+
# or
29+
npm i -D @trigen/lint-package-json
30+
```
31+
32+
## Usage
33+
34+
```bash
35+
pnpm --package=@trigen/lint-package-json dlx lint-package-json
36+
# or
37+
pnpm --package=@trigen/lint-package-json dlx lint-package-json --monorepo
38+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@trigen/lint-package-json",
3+
"type": "module",
4+
"version": "8.0.0-alpha.4",
5+
"description": "Shortcut to run npm-package-json-lint with @trigen/npm-package-json-lint-config.",
6+
"author": "dangreen",
7+
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/TrigenSoftware/scripts.git",
11+
"directory": "packages/lint-package-json"
12+
},
13+
"bugs": {
14+
"url": "https://github.com/TrigenSoftware/scripts/issues"
15+
},
16+
"keywords": [
17+
"npm-package-json-lint",
18+
"dlx"
19+
],
20+
"engines": {
21+
"node": ">=14"
22+
},
23+
"bin": {
24+
"lint-package-json": "./src/index.js"
25+
},
26+
"publishConfig": {
27+
"access": "public",
28+
"directory": "package"
29+
},
30+
"scripts": {
31+
"prepublishOnly": "del ./package && clean-publish",
32+
"postpublish": "del ./package"
33+
},
34+
"dependencies": {
35+
"@trigen/npm-package-json-lint-config": "8.0.0-alpha.3",
36+
"npm-package-json-lint": "^5.4.2"
37+
},
38+
"readme": ""
39+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
import NpmPackageJsonLint from 'npm-package-json-lint/src/NpmPackageJsonLint.js'
3+
import Reporter from 'npm-package-json-lint/src/Reporter.js'
4+
5+
const monorepo = process.argv.includes('--monorepo')
6+
const config = {
7+
extends: monorepo
8+
? ['@trigen/npm-package-json-lint-config', '@trigen/npm-package-json-lint-config/monorepo']
9+
: '@trigen/npm-package-json-lint-config'
10+
}
11+
const npmPackageJsonLint = new NpmPackageJsonLint({
12+
cwd: process.cwd(),
13+
config,
14+
patterns: ['.']
15+
})
16+
const linterOutput = npmPackageJsonLint.lint()
17+
18+
Reporter.write(linterOutput)
19+
20+
if (linterOutput.errorCount > 0) {
21+
process.exit(1)
22+
}

packages/npm-package-json-lint-config/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: 'npm-package-json-lint-config-default',
2+
extends: require.resolve('npm-package-json-lint-config-default'),
33
rules: {
44
'require-author': 'error',
55
'require-bugs': 'error',

packages/scripts/.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": [
33
"@trigen/eslint-config/esm",
4-
"@trigen/eslint-config/typescript",
54
"@trigen/eslint-config/jest"
65
]
76
}

0 commit comments

Comments
 (0)