Linting package.json using Node.js

Install dependencies

# Yarn
yarn add -D npm-package-json-lint npm-package-json-lint-config-default

# NPM
npm install -D npm-package-json-lint npm-package-json-lint-config-default

Configure npm-package-json-lint by adding it to your package.json

"npmpackagejsonlint": {
  "extends": "npm-package-json-lint-config-default"
}

Add script to your package.json

"lint:package": "npmPkgJsonLint ."

Check with Prettier

Install dependencies

# Yarn
yarn add -D prettier

# NPM
npm install -D prettier

Include Prettier check in your script

"lint:package": "prettier --check package.json && npmPkgJsonLint ."

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s