TS linter

Edit on GitHub

TS linter allows you to find and fix code style mistakes. It helps a team to follow the same standards and make code more readable.

To analyze and fixTS files, TSLint is used.

Installation

For details on how to install the TS linter for your project, see the TS linter integration file.

Using TS linter

To execute the TS linter, do the following:

  1. Install the Node modules:
npm ci
  1. Execute the TS linter in:
  • validation mode:
npm run yves:tslint
  • fix mode:
npm run yves:tslint:fix

TS linter config

The config for tslint resides in /tslint.json.

To redefine the path for the config, adjust /frontend/libs/tslint.js and use other rules for the TS linter.

The TS linter rules related to formatting aren’t included in tslint.json to avoid duplication with the Prittier rules.

CI checks and pre-commit hook

The TS linter is integrated into:

  • Pre-commit hooks. The function that executes TS linter before the commit resides in /.githook
- GitHook\Command\FileCommand\PreCommit\TsLintCommand
  • Travis. Command to run the TS linter is integrated into .travis.yml
- node ./frontend/libs/tslint --format stylish
Important

If you commit without the pre-commit hooks, you should run the TS linter manually to avoid issues with Travis.

Pre-commit hooks weren’t integrated into B2B and B2C Demo Shops, only in the Shop Suite.