A Shellcheck Linter as a Jest runner
npm install jest-runner-shellcheck

This library is a jest-runner for the shellcheck library.
Install jest_(it needs Jest 21+)_ and jest-runner-shellcheck
``bash
yarn add --dev jest jest-runner-shellcheck
npm install --save-dev jest jest-runner-shellcheck
`
#### Standalone
In your package.json
`json`
{
"jest": {
"runner": "jest-runner-shellcheck",
"displayName": "lint:shell",
"moduleFileExtensions": ["sh", "bash"],
"testMatch": ["
}
}
Or in jest.config.js
`js`
module.exports = {
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["
};
Please update testMatch to match your project folder structure
#### Alongside other runners
It is recommended to use the projects configuration option to run multiple Jest runners simultaneously.
If you are using Jest <22.0.5, you can use multiple Jest configuration files and supply the paths to those files in the projects option. For example:
`js
// jest-test.config.js
module.exports = {
// your Jest test options
displayName: "test"
};
// jest-grapqhl-schema-linter.config.js
module.exports = {
// your jest-runner-shellcheck options
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["
};
`
In your package.json:
`json`
{
"jest": {
"projects": [
"
"
]
}
}
Or in jest.config.js:
`js`
module.exports = {
projects: [
"
"
]
};
If you are using Jest >=22.0.5, you can supply an array of project configuration objects instead. In your package.json:
`json`
{
"jest": {
"projects": [
{
"displayName": "test"
},
{
"runner": "jest-runner-shellcheck",
"displayName": "lint:shell",
"moduleFileExtensions": ["sh", "bash"],
"testMatch": ["
}
]
}
}
Or in jest.config.js:
`js`
module.exports = {
projects: [
{
displayName: "test"
},
{
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["
}
]
};
`bash`
yarn test
This project uses cosmiconfig, so you can provide config via:
* a jest-runner-shellcheck property in your package.jsonjest-runner-shellcheck.config.js
* a JS file.jest-runner-shellcheckrc
* a JSON file
In package.json
`json`
{
"jest-runner-shellcheck": {
"cliOptions": {
// Options here
}
}
}
or in jest-runner-shellcheck.config.js
`js`
module.exports = {
cliOptions: {
// Options here
}
};
The listed options are the ones provided by the shellcheck CLI.
| option | default | values | example |
| ------------------- | ------- | ------------ | ------------------------------------------------------------------ |
| checkSourced | false | false|true | "checkSourced": true |null
| color | | auto|always|never | "color": "auto" |null
| exclude | | | "exclude": "CODE1,CODE2.." |checkstyle
| format | | checkstyle|gcc|json|tty | "format": "json" |sh
| shell | | sh|bash|dash|ksh | "shell": "bash" |false
| externalSources | | false|true | "externalSources": "true"` |