diff --git a/.eslintignore b/.eslintignore index ce0ef0026..c408bd934 100644 --- a/.eslintignore +++ b/.eslintignore @@ -923,6 +923,7 @@ packages/tools/generate-images.js packages/tools/git-changelog.test.js packages/tools/git-changelog.js packages/tools/licenseChecker.js +packages/tools/packageJsonLint.js packages/tools/release-android.js packages/tools/release-cli.js packages/tools/release-electron.js diff --git a/.gitignore b/.gitignore index 20bb83916..2089efff3 100644 --- a/.gitignore +++ b/.gitignore @@ -909,6 +909,7 @@ packages/tools/generate-images.js packages/tools/git-changelog.test.js packages/tools/git-changelog.js packages/tools/licenseChecker.js +packages/tools/packageJsonLint.js packages/tools/release-android.js packages/tools/release-cli.js packages/tools/release-electron.js diff --git a/lint-staged.config.js b/lint-staged.config.js index ffba84cdd..54a9f2878 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -11,8 +11,9 @@ module.exports = { // // '**/*.ts?(x)': () => 'npm run tsc', '*.{js,jsx,ts,tsx}': [ - 'yarn run linter-precommit', + 'yarn run checkIgnoredFiles', 'yarn run checkLibPaths', - 'node packages/tools/checkIgnoredFiles.js', + 'yarn run packageJsonLint', + 'yarn run linter-precommit', ], }; diff --git a/package.json b/package.json index 6823a2f45..2306b41ea 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "buildWebsiteTranslations": "node packages/tools/website/buildTranslations.js", "buildWebsite": "node ./packages/tools/website/build.js && yarn run buildPluginDoc && yarn run buildSettingJsonSchema", "checkLibPaths": "node ./packages/tools/checkLibPaths.js", + "checkIgnoredFiles": "node ./packages/tools/checkIgnoredFiles.js", "circularDependencyCheck": "madge --warning --circular --extensions js ./", "clean": "npm run clean --workspaces --if-present && node packages/tools/clean && yarn cache clean", "dependencyTree": "madge", @@ -33,7 +34,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 .", + "packageJsonLint": "node ./packages/tools/packageJsonLint.js", "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", @@ -60,7 +61,7 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged && yarn run packageJsonLint" + "pre-commit": "lint-staged" } }, "devDependencies": { diff --git a/packages/tools/packageJsonLint.ts b/packages/tools/packageJsonLint.ts new file mode 100644 index 000000000..fb796399d --- /dev/null +++ b/packages/tools/packageJsonLint.ts @@ -0,0 +1,13 @@ +import { execCommand, getRootDir } from '@joplin/utils'; +import { chdir } from 'process'; + +const main = async () => { + const rootDir = await getRootDir(); + chdir(rootDir); + await execCommand('yarn run npmPkgJsonLint --configFile .npmpackagejsonlintrc.json --quiet .'); +}; + +main().catch((error) => { + console.error(error); + process.exit(1); +});