• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TypeScript linter
2Typescript linter ( further mentioned as 'linter' ) is a tool to check typescript sources and find language elements
3and constructions which are deprecated to use in a purpose to migrate sources to STS.
4The linter is currently under development.
5
6## Prerequisits
7
8### Visual Studio Code
9For development, it's recommended to use `VS Code`, as it has a full built-in support for TypeScript language.
10
11### NodeJS and NPM
12Install the latest stable version of `NodeJS` and `NPM`. It is recommended using a `Node version manager` to install Node and NPM ([nvm](https://github.com/nvm-sh/nvm) for Linux; [nvm-windows](https://github.com/coreybutler/nvm-windows) for windows - v1.1.9 is the most stable). You can also follow the [official guide](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
13
14## Building
15
16Run the following command to install all project dependencies and build the project:
17
18```bash
19npm install
20```
21
22Run the following command to only build project sources:
23
24```bash
25npm run build
26```
27
28## Running
29Run the following command from the same directory:
30```bash
31node dist/tslinter.js [options] [input files]
32```
33
34Note: Before linting a project, it is highly recommended to install all project dependencies (with `npm install` or any other methods -- depends on the concrete project).
35
36You can also use command files `tslinter.sh` or `tslinter.bat` with same arguments as for direct launch.
37
38Possible command options:
39
40`--deveco-plugin-mode` - this options defines special mode to launch from IDE and should NOT be used when running from command line.
41
42`--relax` - defines 'relax' mode in which only problematic TypeScript language elements that cannot be transpiled by TypeScript migrator are counted.
43
44`--project-folder <path>` - defines path to folder with TypeScript sources and subfolders which linter walks recurscevely. This option may be repeated in command line with different paths.
45
46`-p, --project <path>` - defines path to TS project configuration file (commonly known as tsconfig.json). If no input file is defined directly as command-line argument, then all source files from tsconfig.json will be processed by linter. Otherwise, linter will only process input files from command-line, that are included into project (i.e. files that belong to intersection of input files from command-line and tsconfig.json file).
47
48`-E, --TSC_Errors` - enables logging messages about compilation errors and unresolved symbols.
49
50`--warnings-as-errors` - linter detects two kinds of problems: warnings and errors. This parameter make treatment of warnings as errors.
51
52All other command line arguments are considered as paths to TypeScript files.
53
54To prevent command line buffer overflow, response file may be used. It is specified by adding `@` prefix to file name (e.g.: `tslinter.sh @response-file.txt` ). Response file should contain TypeScript source paths (one at each line). The response file argument should be the last command argument (any following argument will be ignored).
55
56## Running tests
57
58Run the following command:
59```bash
60npm test
61```
62