-
Notifications
You must be signed in to change notification settings - Fork 1
Use as a JavaScript module
Moritz Jacobs edited this page Feb 25, 2020
·
1 revision
You can install scriptlint as a dependency and call it as a function like this:
const scriptlint = require("scriptlint");
const scriptlintIssues = scriptlint({
strict: true,
packageFile: "/Users/foobar/project-dir"
});
… OR you pass in a script object directly …
const scriptlint = require("scriptlint");
const scriptlintIssues = scriptlint({
fix: true,
strict: true,
packageScripts: {
foo: "bar",
test: "jest"
}
});
BUT NOT BOTH!
The function returns an object with found issues and the (potentially fixed if fix: true
) scripts object in question:
{
"issues": [
{
"message": "must contain a \"start\" script (mandatory-start)",
"type": "warning",
"affected": false
},
{
"message": "must contain a \"dev\" script (mandatory-dev)",
"type": "warning",
"affected": false
}
],
"scripts": {
"other:foo": "bar",
"test": "jest"
}
}
Note: local user config (in .scriptlintrc
or similar) is ignored in the module, you have to configure the module directly!
- Motivation
- The scriptlint "standard" tl;dr
-
The scriptlint "standard"
- Rules enforceable via the scriptlint CLI
- Best practices
- The scriptlint CLI
- Contributing to scriptlint