-
Notifications
You must be signed in to change notification settings - Fork 1
uses allowed namespace
This rule is fixable ✓
Using namespaced script names improves readability and makes the intent more obvious.
Namespace means, that scripts that belong together should be prefixed with a common name. We use :
as a namespace seperator, like this:
test:lint
test:unit:watch
test:unit:coverage
Such names can be arbitrarily long, but it is rare to see more than 3 levels.
Of course you can use hooks triggered by such scripts:
{
"build:css": "...",
"prebuild:css": "...",
}
scriptlint predefines a few namespaces, we call these categories:
To better signify, what purpose a script has, prefix it with one of these categories:
build
dev
format
lint
other
report
script
setup
start
test
So for example a script that runs unit tests should be called test:unit
.
Of course category names themselves can (sometimes must) be script names! For example build
or test
. In those cases they often serve as subscripts (use npm-run-all or similar!) – this is great practice!
You can also use more then one cateogry and/or subcategory. This is rare, but sometimes something like test:unit:watch:all
comes in handy.
Anything that doesn't fit in these categories can go in other
.
{
"test:unit": "jest",
"test:coverage": "jest --coverage",
"test:lint": "eslint ./src",
"format": "run-s format:eslint format:prettier",
"format:eslint": "eslint ./src --fix",
"format:prettier": "prettier --write src/*.js",
"build": "run-s build:clean build:ts",
"build:clean": "rimraf ./dist",
"build:ts": "tsc -p tsconfig.json",
"other:selfupdate": "updtr",
…
}
This rule's autofix will prepend every script without a category with other:
.
- Motivation
- The scriptlint "standard" tl;dr
-
The scriptlint "standard"
- Rules enforceable via the scriptlint CLI
- Best practices
- The scriptlint CLI
- Contributing to scriptlint