diff --git a/.github/scripts/run_ci.sh b/.github/scripts/run_ci.sh index 55c8b6489..e1e09fd1f 100755 --- a/.github/scripts/run_ci.sh +++ b/.github/scripts/run_ci.sh @@ -107,6 +107,12 @@ if [ "$IS_PULL_REQUEST" == "1" ] || [ "$IS_DEV_BRANCH" = "1" ]; then if [ $testResult -ne 0 ]; then exit $testResult fi + + yarn run packageJsonLint + testResult=$? + if [ $testResult -ne 0 ]; then + exit $testResult + fi fi # ============================================================================= diff --git a/.npmpackagejsonlintignore b/.npmpackagejsonlintignore new file mode 100644 index 000000000..9950560bf --- /dev/null +++ b/.npmpackagejsonlintignore @@ -0,0 +1,2 @@ +packages/app-clipper/popup/ +packages/app-cli/tests/support/plugins/ \ No newline at end of file diff --git a/.npmpackagejsonlintrc.json b/.npmpackagejsonlintrc.json new file mode 100644 index 000000000..831d68fc4 --- /dev/null +++ b/.npmpackagejsonlintrc.json @@ -0,0 +1,22 @@ +{ + "rules": { + "prefer-absolute-version-dependencies": ["error", + { + "exceptions": [ + "@joplin/lib", + "@joplin/renderer", + "@joplin/pdf-viewer", + "@joplin/fork-htmlparser2", + "@joplin/fork-sax", + "@joplin/fork-uslug", + "@joplin/htmlpack", + "@joplin/turndown", + "@joplin/turndown-plugin-gfm", + "@joplin/tools", + "@joplin/react-native-saf-x" + ] + } + ] + } +} + \ No newline at end of file diff --git a/lint-staged.config.js b/lint-staged.config.js index 471e987b9..477b0b8bf 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -13,7 +13,5 @@ module.exports = { '*.{js,jsx,ts,tsx}': [ 'yarn run linter-precommit', 'yarn run checkLibPaths', - // 'yarn run spellcheck', - // 'git add', ], }; diff --git a/package.json b/package.json index 8dd1edad1..b32b26fea 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "linter-precommit": "eslint --resolve-plugins-relative-to . --fix --ext .js --ext .jsx --ext .ts --ext .tsx", "linter": "eslint --resolve-plugins-relative-to . --fix --quiet --ext .js --ext .jsx --ext .ts --ext .tsx", "linter-interactive": "eslint-interactive --resolve-plugins-relative-to . --fix --quiet --ext .js --ext .jsx --ext .ts --ext .tsx", + "packageJsonLint": "npmPkgJsonLint --configFile .npmpackagejsonlintrc.json --quiet .", "postinstall": "gulp build", "publishAll": "git pull && yarn run buildParallel && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll", "releaseAndroid": "PATH=\"/usr/local/opt/openjdk@11/bin:$PATH\" node packages/tools/release-android.js", @@ -59,7 +60,7 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "lint-staged && yarn run packageJsonLint" } }, "devDependencies": { @@ -79,6 +80,7 @@ "lerna": "3.22.1", "lint-staged": "13.1.0", "madge": "5.0.1", + "npm-package-json-lint": "6.4.0", "typedoc": "0.17.8", "typescript": "4.9.4" }, diff --git a/yarn.lock b/yarn.lock index 8f60d909e..84da908a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8149,6 +8149,15 @@ __metadata: languageName: node linkType: hard +"ajv-errors@npm:^1.0.1": + version: 1.0.1 + resolution: "ajv-errors@npm:1.0.1" + peerDependencies: + ajv: ">=5.0.0" + checksum: 2c9fc02cf58f9aae5bace61ebd1b162e1ea372ae9db5999243ba5e32a9a78c0d635d29ae085f652c61c941a43af0b2b1acdb255e29d44dc43a6e021085716d8c + languageName: node + linkType: hard + "ajv-keywords@npm:^3.4.1, ajv-keywords@npm:^3.5.2": version: 3.5.2 resolution: "ajv-keywords@npm:3.5.2" @@ -8158,7 +8167,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.10.0, ajv@npm:^6.12.0, ajv@npm:^6.12.3, ajv@npm:^6.12.4, ajv@npm:^6.12.5": +"ajv@npm:^6.10.0, ajv@npm:^6.12.0, ajv@npm:^6.12.3, ajv@npm:^6.12.4, ajv@npm:^6.12.5, ajv@npm:^6.12.6": version: 6.12.6 resolution: "ajv@npm:6.12.6" dependencies: @@ -10324,7 +10333,7 @@ __metadata: languageName: node linkType: hard -"builtins@npm:^5.0.1": +"builtins@npm:^5.0.0, builtins@npm:^5.0.1": version: 5.0.1 resolution: "builtins@npm:5.0.1" dependencies: @@ -12031,6 +12040,18 @@ __metadata: languageName: node linkType: hard +"cosmiconfig@npm:^8.0.0": + version: 8.0.0 + resolution: "cosmiconfig@npm:8.0.0" + dependencies: + import-fresh: ^3.2.1 + js-yaml: ^4.1.0 + parse-json: ^5.0.0 + path-type: ^4.0.0 + checksum: ff4cdf89ac1ae52e7520816622c21a9e04380d04b82d653f5139ec581aa4f7f29e096d46770bc76c4a63c225367e88a1dfa233ea791669a35101f5f9b972c7d1 + languageName: node + linkType: hard + "countable@npm:3.0.1": version: 3.0.1 resolution: "countable@npm:3.0.1" @@ -18629,6 +18650,13 @@ __metadata: languageName: node linkType: hard +"irregular-plurals@npm:^3.2.0": + version: 3.3.0 + resolution: "irregular-plurals@npm:3.3.0" + checksum: 1282d8adfb00a9718655ce21e5b096d4b31d2115c817a30e1e3254648ae4ac0f84d706cd0cad2a93c64f4bb5c5572ea8f63fcc9766f005a5362031c56d9e77b5 + languageName: node + linkType: hard + "is-absolute@npm:^1.0.0": version: 1.0.0 resolution: "is-absolute@npm:1.0.0" @@ -19124,6 +19152,13 @@ __metadata: languageName: node linkType: hard +"is-plain-obj@npm:^3.0.0": + version: 3.0.0 + resolution: "is-plain-obj@npm:3.0.0" + checksum: a6ebdf8e12ab73f33530641972a72a4b8aed6df04f762070d823808303e4f76d87d5ea5bd76f96a7bbe83d93f04ac7764429c29413bd9049853a69cb630fb21c + languageName: node + linkType: hard + "is-plain-object@npm:^2.0.1, is-plain-object@npm:^2.0.3, is-plain-object@npm:^2.0.4": version: 2.0.4 resolution: "is-plain-object@npm:2.0.4" @@ -20687,6 +20722,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.2.0": + version: 3.2.0 + resolution: "jsonc-parser@npm:3.2.0" + checksum: 946dd9a5f326b745aa326d48a7257e3f4a4b62c5e98ec8e49fa2bdd8d96cef7e6febf1399f5c7016114fd1f68a1c62c6138826d5d90bc650448e3cf0951c53c7 + languageName: node + linkType: hard + "jsonfile@npm:^2.1.0": version: 2.4.0 resolution: "jsonfile@npm:2.4.0" @@ -22136,6 +22178,26 @@ __metadata: languageName: node linkType: hard +"meow@npm:^9.0.0": + version: 9.0.0 + resolution: "meow@npm:9.0.0" + dependencies: + "@types/minimist": ^1.2.0 + camelcase-keys: ^6.2.2 + decamelize: ^1.2.0 + decamelize-keys: ^1.1.0 + hard-rejection: ^2.1.0 + minimist-options: 4.1.0 + normalize-package-data: ^3.0.0 + read-pkg-up: ^7.0.1 + redent: ^3.0.0 + trim-newlines: ^3.0.0 + type-fest: ^0.18.0 + yargs-parser: ^20.2.3 + checksum: 99799c47247f4daeee178e3124f6ef6f84bde2ba3f37652865d5d8f8b8adcf9eedfc551dd043e2455cd8206545fd848e269c0c5ab6b594680a0ad4d3617c9639 + languageName: node + linkType: hard + "merge-descriptors@npm:^1.0.1": version: 1.0.1 resolution: "merge-descriptors@npm:1.0.1" @@ -23873,6 +23935,33 @@ __metadata: languageName: node linkType: hard +"npm-package-json-lint@npm:^6.4.0": + version: 6.4.0 + resolution: "npm-package-json-lint@npm:6.4.0" + dependencies: + ajv: ^6.12.6 + ajv-errors: ^1.0.1 + chalk: ^4.1.2 + cosmiconfig: ^8.0.0 + debug: ^4.3.4 + globby: ^11.1.0 + ignore: ^5.2.0 + is-plain-obj: ^3.0.0 + jsonc-parser: ^3.2.0 + log-symbols: ^4.1.0 + meow: ^9.0.0 + plur: ^4.0.0 + semver: ^7.3.8 + slash: ^3.0.0 + strip-json-comments: ^3.1.1 + type-fest: ^3.2.0 + validate-npm-package-name: ^5.0.0 + bin: + npmPkgJsonLint: dist/cli.js + checksum: 75cca8bfffd40cd848778f27cd2800515137a8747098d86c3cfc0f5c43073daeb4baf9be4771f06ef47659ec7b77ec5afab6024530329a9eafea2b0f3e102f55 + languageName: node + linkType: hard + "npm-packlist@npm:^1.4.4": version: 1.4.8 resolution: "npm-packlist@npm:1.4.8" @@ -25419,6 +25508,15 @@ __metadata: languageName: node linkType: hard +"plur@npm:^4.0.0": + version: 4.0.0 + resolution: "plur@npm:4.0.0" + dependencies: + irregular-plurals: ^3.2.0 + checksum: fea2e903efca67cc5c7a8952fca3db46ae8d9e9353373b406714977e601a5d3b628bcb043c3ad2126c6ff0e73d8020bf43af30a72dd087eff1ec240eb13b90e1 + languageName: node + linkType: hard + "pluralize@npm:^8.0.0": version: 8.0.0 resolution: "pluralize@npm:8.0.0" @@ -28032,6 +28130,7 @@ __metadata: madge: 5.0.1 node-gyp: 9.3.1 nodemon: 2.0.20 + npm-package-json-lint: ^6.4.0 typedoc: 0.17.8 typescript: 4.9.4 languageName: unknown @@ -31332,6 +31431,13 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^3.2.0": + version: 3.5.0 + resolution: "type-fest@npm:3.5.0" + checksum: 9b82958ded0aedeb38fe6b172645a319522d11904b58e422dbab9ba40f85d48e749ff8fb7047cd72f4a2923c63927b741e2efc97ce7b0662b7e042923510132f + languageName: node + linkType: hard + "type-is@npm:^1.6.16, type-is@npm:^1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" @@ -32199,6 +32305,15 @@ __metadata: languageName: node linkType: hard +"validate-npm-package-name@npm:^5.0.0": + version: 5.0.0 + resolution: "validate-npm-package-name@npm:5.0.0" + dependencies: + builtins: ^5.0.0 + checksum: 5342a994986199b3c28e53a8452a14b2bb5085727691ea7aa0d284a6606b127c371e0925ae99b3f1ef7cc7d2c9de75f52eb61a3d1cc45e39bca1e3a9444cbb4e + languageName: node + linkType: hard + "value-or-function@npm:^3.0.0": version: 3.0.0 resolution: "value-or-function@npm:3.0.0"