-
Notifications
You must be signed in to change notification settings - Fork 28
Add @wordpress/npm-package-json-lint-config
package
#119
Changes from all commits
418454c
a32b5e2
0f69270
3d305a8
c1fcbe2
963eae1
878c20b
75e27e4
ecfe8a6
449dee8
438f41d
e497ec6
8b8e73e
63f6b74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# `@wordpress/npm-package-json-lint-config` | ||
|
||
> WordPress [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) shareable config | ||
|
||
## Installation | ||
|
||
Install the module | ||
|
||
```shell | ||
$ npm install @wordpress/npm-package-json-lint-config | ||
``` | ||
|
||
## Usage | ||
|
||
Add this to your `package.json` file: | ||
|
||
```json | ||
"npmPackageJsonLintConfig": { | ||
"extends": "@wordpress/npm-package-json-lint-config", | ||
}, | ||
``` | ||
|
||
Or to a `.npmpackagejsonlintrc.json` file in the root of your repo: | ||
```json | ||
{ | ||
"extends": "@wordpress/npm-package-json-lint-config", | ||
} | ||
|
||
``` | ||
|
||
To add, modify, or override any [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint/wiki) rules add this to your `package.json` file: | ||
|
||
```json | ||
"npmPackageJsonLintConfig": { | ||
"extends": "@wordpress/npm-package-json-lint-config", | ||
"rules": { | ||
"valid-values-author": [ | ||
"error", | ||
[ | ||
"WordPress" | ||
] | ||
] | ||
} | ||
}, | ||
``` | ||
|
||
Or to a `.npmpackagejsonlintrc.json` file in the root of your repo: | ||
|
||
```json | ||
{ | ||
"extends": "@wordpress/npm-package-json-lint-config", | ||
"rules": { | ||
"require-publishConfig": "error", | ||
"valid-values-author": [ | ||
"error", | ||
[ | ||
"WordPress" | ||
] | ||
] | ||
} | ||
} | ||
|
||
``` | ||
|
||
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
'use strict'; | ||
|
||
const defaultConfig = { | ||
rules: { | ||
'bin-type': 'error', | ||
'bundledDependencies-type': 'error', | ||
'config-type': 'error', | ||
'cpu-type': 'error', | ||
'dependencies-type': 'error', | ||
'description-type': 'error', | ||
'devDependencies-type': 'error', | ||
'directories-type': 'error', | ||
'engines-type': 'error', | ||
'files-type': 'error', | ||
'homepage-type': 'error', | ||
'keywords-type': 'error', | ||
'license-type': 'error', | ||
'main-type': 'error', | ||
'man-type': 'error', | ||
'name-format': 'error', | ||
'name-type': 'error', | ||
'no-restricted-dependencies': 'off', | ||
'no-restricted-devDependencies': 'off', | ||
'no-restricted-pre-release-dependencies': 'off', | ||
'no-restricted-pre-release-devDependencies': 'off', | ||
'optionalDependencies-type': 'error', | ||
'os-type': 'error', | ||
'peerDependencies-type': 'error', | ||
'prefer-absolute-version-dependencies': 'off', | ||
'prefer-absolute-version-devDependencies': 'off', | ||
'prefer-alphabetical-bundledDependencies': 'error', | ||
'prefer-alphabetical-dependencies': 'error', | ||
'prefer-alphabetical-devDependencies': 'error', | ||
'prefer-alphabetical-optionalDependencies': 'error', | ||
'prefer-alphabetical-peerDependencies': 'error', | ||
'prefer-caret-version-dependencies': 'off', | ||
'prefer-caret-version-devDependencies': 'off', | ||
'prefer-no-engineStrict': 'off', | ||
'prefer-no-version-zero-dependencies': 'off', | ||
'prefer-no-version-zero-devDependencies': 'off', | ||
'prefer-property-order': [ | ||
'error', | ||
[ | ||
'name', | ||
'version', | ||
'description', | ||
'author', | ||
'license', | ||
'keywords', | ||
'homepage', | ||
'repository', | ||
'bugs', | ||
'engines', | ||
'directories', | ||
'files', | ||
'main', | ||
'module', | ||
'bin', | ||
'dependencies', | ||
'devDependencies', | ||
'peerDependencies', | ||
'publishConfig', | ||
'scripts', | ||
], | ||
], | ||
'prefer-tilde-version-dependencies': 'off', | ||
'prefer-tilde-version-devDependencies': 'off', | ||
'preferGlobal-type': 'error', | ||
'private-type': 'error', | ||
'repository-type': 'error', | ||
'require-author': 'error', | ||
'require-bin': 'off', | ||
'require-bugs': 'error', | ||
'require-bundledDependencies': 'off', | ||
'require-config': 'off', | ||
'require-contributors': 'off', | ||
'require-cpu': 'off', | ||
'require-dependencies': 'off', | ||
'require-description': 'error', | ||
'require-devDependencies': 'off', | ||
'require-directories': 'off', | ||
'require-engines': 'off', | ||
'require-files': 'off', | ||
'require-homepage': 'error', | ||
'require-keywords': 'error', | ||
'require-license': 'error', | ||
'require-main': 'off', | ||
'require-man': 'off', | ||
'require-module': 'off', | ||
'require-name': 'error', | ||
'require-optionalDependencies': 'off', | ||
'require-os': 'off', | ||
'require-peerDependencies': 'off', | ||
'require-preferGlobal': 'off', | ||
'require-private': 'off', | ||
'require-publishConfig': 'off', | ||
'require-repository': 'error', | ||
'require-scripts': 'off', | ||
'require-version': 'error', | ||
'scripts-type': 'error', | ||
'valid-values-author': 'off', | ||
'valid-values-license': [ 'error', [ | ||
'GPL-2.0-or-later', | ||
] ], | ||
'valid-values-private': 'off', | ||
'version-format': 'error', | ||
'version-type': 'error', | ||
}, | ||
}; | ||
|
||
module.exports = defaultConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@wordpress/npm-package-json-lint-config", | ||
"version": "0.1.0", | ||
"description": "WordPress npm-package-json-lint shareable config", | ||
"author": "WordPress", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
"wordpress", | ||
"npm-package-json-lint", | ||
"npm-package-json-lint-config" | ||
], | ||
"homepage": "https://github.com/WordPress/packages/tree/master/packages/npm-package-json-lint-config/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/WordPress/packages.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/WordPress/packages/issues" | ||
}, | ||
"main": "index.js", | ||
"devDependencies": { | ||
"is-plain-obj": "^1.1.0" | ||
}, | ||
"peerDependencies": { | ||
"npm-package-json-lint": ">= 3.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from root\" && exit 1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import isPlainObj from 'is-plain-obj'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Not sure if introduction of dependency here is strictly necessary. What is it we're testing? Would Alternatively, Lodash includes an Thinking in terms of being explicit with where dependencies add value to avoid excessive proliferation. |
||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import config from '../'; | ||
|
||
describe( 'npm-package-json-lint config tests', () => { | ||
it( 'should be an object', () => { | ||
expect( isPlainObj( config ) ).toBeTruthy(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} ); | ||
|
||
it( 'should be an object', () => { | ||
expect( isPlainObj( config.rules ) ).toBeTruthy(); | ||
} ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be defined as a
devDependencies
in the root if we're not using it in the root?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package are local, tests are global, so we just need pick one approach for those dependencies. I have a feeling that other packages define them in their own
package.json
file. Lerna will hoist, them so we don't need it in here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Seemed we should need it to be defined in either root or
npm-package-json-lint-config/package.json
, but not both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, one of them is enough.