Skip to content

Commit

Permalink
Include the root package.json file in the linting
Browse files Browse the repository at this point in the history
This commit also moves the npm-package-json-lint config to the standalone file.
  • Loading branch information
gziolo committed Oct 22, 2019
1 parent 64c24d1 commit d97282d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
39 changes: 39 additions & 0 deletions .npmpackagejsonlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"extends": "@wordpress/npm-package-json-lint-config",
"rules": {
"description-format": [
"error",
{
"requireCapitalFirstLetter": true,
"requireEndingPeriod": true
}
],
"prefer-no-devDependencies": "error",
"require-publishConfig": "error",
"require-repository-directory": "error",
"valid-values-author": [
"error",
[
"The WordPress Contributors"
]
],
"valid-values-publishConfig": [
"error",
[
{
"access": "public"
}
]
]
},
"overrides": [
{
"patterns": [ "./package.json" ],
"rules": {
"require-publishConfig": "off",
"require-repository-directory": "off",
"prefer-no-devDependencies": "off"
}
}
]
}
31 changes: 1 addition & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,6 @@
"webpack": "4.41.0",
"worker-farm": "1.7.0"
},
"npmpackagejsonlint": {
"extends": "@wordpress/npm-package-json-lint-config",
"rules": {
"description-format": [
"error",
{
"requireCapitalFirstLetter": true,
"requireEndingPeriod": true
}
],
"prefer-no-devDependencies": "error",
"require-publishConfig": "error",
"require-repository-directory": "error",
"valid-values-author": [
"error",
[
"The WordPress Contributors"
]
],
"valid-values-publishConfig": [
"error",
[
{
"access": "public"
}
]
]
}
},
"scripts": {
"prebuild": "npm run check-engines",
"clean:packages": "rimraf ./packages/*/build ./packages/*/build-module ./packages/*/build-style ./packages/*/node_modules",
Expand All @@ -207,7 +178,7 @@
"lint-js": "wp-scripts lint-js",
"lint-js:fix": "npm run lint-js -- --fix",
"lint-php": "wp-scripts env lint-php",
"lint-pkg-json": "wp-scripts lint-pkg-json 'packages/*/package.json'",
"lint-pkg-json": "wp-scripts lint-pkg-json . 'packages/*/package.json'",
"lint-css": "wp-scripts lint-style '**/*.scss'",
"lint-css:fix": "npm run lint-css -- --fix",
"lint-types": "tsc",
Expand Down
4 changes: 3 additions & 1 deletion packages/scripts/scripts/lint-pkg-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const hasLintConfig = hasArgInCLI( '-c' ) ||
hasArgInCLI( '--configFile' ) ||
hasProjectFile( '.npmpackagejsonlintrc.json' ) ||
hasProjectFile( 'npmpackagejsonlint.config.js' ) ||
hasPackageProp( 'npmpackagejsonlint' );
hasPackageProp( 'npmpackagejsonlint' ) ||
// npm-package-json-lint v3.x used a different prop name.
hasPackageProp( 'npmPackageJsonLintConfig' );

const defaultConfigArgs = ! hasLintConfig ?
[ '--configFile', fromConfigRoot( 'npmpackagejsonlint.json' ) ] :
Expand Down

0 comments on commit d97282d

Please sign in to comment.