Skip to content
TypeScript JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dependabot
.github/workflows
src
.gitignore
README.md
jest-preset.js
package-lock.json
package.json
tsconfig.json

README.md

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:

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 your package.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"]
You can’t perform that action at this time.