jest-runner-tslint
v2.0.23
Published
TSLint runner for Jest
Downloads
902
Readme
jest-runner-tslint
Deprecated
Due to the deprecation of TSLint this package is as well in the process of being deprecation. Before this happens officially, this package is following a similar path of maintenance before final deprecation.
In the meantime, if you are currently using this package, please take the time to transition your project to ESLint, typescript-eslint, and jest-runner-eslint.
For more information on the industry-wide transition from TSLint to ESLint, please see the following:
- TSLint in 2019 on Medium
- palantir/tslint#4534: "Roadmap: TSLint -> ESLint"
- typescript-eslint: "What about TSLint?"
Usage
Install
Install tslint
, jest
(it needs Jest 21+), and jest-runner-tslint
yarn add --dev tslint jest jest-runner-tslint
# or with NPM
npm install --save-dev tslint jest jest-runner-tslint
Add it to your Jest config
Using Built-in Preset
This package includes a Jest preset which configures Jest to run TSLint on all files supported by TSLint. To use it set the following in your package.json
:
{
"jest": {
"preset": "jest-runner-tslint"
}
}
or jest.config.js
:
module.exports = {
preset: "jest-runner-tslint",
};
Manually
In your package.json
{
"jest": {
"moduleFileExtensions": ["ts", "tsx", "js", "jsx"],
"runner": "tslint",
"testMatch": ["**/*.ts", "**/*.tsx", "**/*.d.ts", "**/*.js", "**/*.jsx"]
}
}
Or in jest.config.js
module.exports = {
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
runner: "tslint",
testMatch: ["**/*.ts", "**/*.tsx", "**/*.d.ts", "**/*.js", "**/*.jsx"],
};
Run Jest
yarn jest
Options
This project uses cosmiconfig, so you can provide config via:
- a
jest-runner-tslint
property in yourpackage.json
- a
jest-runner-tslint.config.js
JS file - a
.jest-runner-tslintrc
JSON file
In package.json
{
"jest-runner-tslint": {
"cliOptions": {
// Options here
}
}
}
or in jest-runner-tslint.config.js
module.exports = {
cliOptions: {
// Options here
},
};
cliOptions
jest-runner-tslint maps a lot of ESLint CLI arguments to config options. For example --fix
is cliOptions.fix
| option | default | example |
| ------------------- | ----------- | ------------------------------------------------------------------------------------------- |
| fix | false
| "fix": true
|
| formatter | "stylish"
| "formatter": "tap"
|
| formattersDirectory | null
| "formattersDirectory": "node_modules/custom-tslint-formatters/formatters"
|
| rulesDirectory | null
| "rulesDirectory": "path/to/rules" or "rulesDirectory": ["path/to/rules", "path/to/other"]
|