Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emmenko/jest-runner-shellcheck
A Shellcheck Linter as a Jest runner
https://github.com/emmenko/jest-runner-shellcheck
Last synced: 3 months ago
JSON representation
A Shellcheck Linter as a Jest runner
- Host: GitHub
- URL: https://github.com/emmenko/jest-runner-shellcheck
- Owner: emmenko
- License: mit
- Created: 2018-06-08T16:29:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-08T19:44:26.000Z (over 6 years ago)
- Last Synced: 2024-10-13T14:29:33.385Z (4 months ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/emmenko/jest-runner-shellcheck.svg?branch=master)](https://travis-ci.org/emmenko/jest-runner-shellcheck)
[![npm version](https://badge.fury.io/js/jest-runner-shellcheck.svg)](https://badge.fury.io/js/jest-runner-shellcheck)## Usage
This library is a [jest-runner](https://facebook.github.io/jest/docs/en/configuration.html#runner-string) for the [`shellcheck`](https://github.com/koalaman/shellcheck) library.
### Install
Install `jest`_(it needs Jest 21+)_ and `jest-runner-shellcheck`
```bash
yarn add --dev jest jest-runner-shellcheck# or with NPM
npm install --save-dev jest jest-runner-shellcheck
```### Add it to your Jest config
#### Standalone
In your `package.json`
```json
{
"jest": {
"runner": "jest-runner-shellcheck",
"displayName": "lint:shell",
"moduleFileExtensions": ["sh", "bash"],
"testMatch": ["/src/**/*.sh"]
}
}
```Or in `jest.config.js`
```js
module.exports = {
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["/src/**/*.sh"]
};
```Please update `testMatch` to match your project folder structure
#### Alongside other runners
It is recommended to use the [`projects`](https://facebook.github.io/jest/docs/en/configuration.html#projects-array-string-projectconfig) 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-shellcheck.config.js
module.exports = {
// your jest-runner-shellcheck options
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["/src/**/*.sh"]
};
```In your `package.json`:
```json
{
"jest": {
"projects": [
"/jest-test.config.js",
"/jest-shellcheck.config.js"
]
}
}
```Or in `jest.config.js`:
```js
module.exports = {
projects: [
"/jest-test.config.js",
"/jest-shellcheck.config.js"
]
};
```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": ["/src/**/*.sh"]
}
]
}
}
```Or in `jest.config.js`:
```js
module.exports = {
projects: [
{
displayName: "test"
},
{
runner: "jest-runner-shellcheck",
displayName: "shell lint",
moduleFileExtensions: ["sh", "bash"],
testMatch: ["/src/**/*.sh"]
}
]
};
```### Run Jest
```bash
yarn test
```## Options
This project uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig), so you can provide config via:
- a `jest-runner-shellcheck` property in your `package.json`
- a `jest-runner-shellcheck.config.js` JS file
- a `.jest-runner-shellcheckrc` JSON fileIn `package.json`
```json
{
"jest-runner-shellcheck": {
"cliOptions": {
// Options here
}
}
}
```or in `jest-runner-shellcheck.config.js`
```js
module.exports = {
cliOptions: {
// Options here
}
};
```### cliOptions
The listed options are the ones provided by the `shellcheck` CLI.
| option | default | values | example |
| --------------- | ------------ | ------------------------- | ---------------------------- |
| checkSourced | `false` | `false|true` | `"checkSourced": true` |
| color | `null` | `auto|always|never` | `"color": "auto"` |
| exclude | `null` | | `"exclude": "CODE1,CODE2.."` |
| format | `checkstyle` | `checkstyle|gcc|json|tty` | `"format": "json"` |
| shell | `sh` | `sh|bash|dash|ksh` | `"shell": "bash"` |
| externalSources | `false` | `false|true` | `"externalSources": "true"` |