Skip to content

Configuration

tannerbaum edited this page Feb 26, 2020 · 3 revisions

configure the CLI

The scriptlint CLI is configured by either

  • CLI command flags or
  • a config object that stems from
    • a scriptlint property in package.json
    • a .scriptlintrc file in JSON or YAML format
    • a .scriptlintrc.json file
    • a .scriptlintrc.yaml, .scriptlintrc.yml, or .scriptlintrc.js file
    • a scriptlint.config.js file exporting a JS object

With a combination of both the CLI command flags take precedence!

Default config

{
	"strict": false,
	"fix": false,
	"config": false,
	"json": false,
	"rules": {},
	"ignoreScripts": [],
	"customRules": []
}

strict

This defines what set of rules will be used. "strict": false means enabling the minimum ruleset, while "strict": true uses all of the rules available with their default values. See here for an in-depth explanation of each rule.

rules

Turn a rule on/off like this:

{
	"strict": true,
	"rules": {
		"uses-allowed-namespace": false
	}
}

json

Output the issues in a json format

[
  {
    "message": "Use of unix double ampersand (&&) in script 'test' is not allowed, consider using npm-run-all/run-s (no-unix-double-ampersand)",
    "type": "warning",
    "affected": "test"
  }
]

config

Print the config as json for debugging purposes.

fix

🚨 This alters the contents of your package.json, only use it in a version controlled environment!

Attempt to fix all found issues. Not every rule has a autofix function ready, but some do.

ignore scripts

{
	"strict": true,
	"ignoreScripts": ["my-funny-scriptname"]
}

Scripts in this list will be exempt from linting.

custom rules

See here.