├── .python-version ├── messages.json ├── .travis.yml ├── messages ├── install.txt └── 1.6.0.txt ├── linter.py ├── LICENSE └── README.md /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt", 3 | "1.6.0": "messages/1.6.0.txt" 4 | } 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | install: 5 | - pip install flake8 6 | script: 7 | - flake8 *.py --max-line-length=120 8 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-tslint 2 | ------------------------------- 3 | This linter plugin for SublimeLinter provides an interface to tslint. 4 | 5 | Please read the installation instructions at: 6 | 7 | https://github.com/SublimeLinter/SublimeLinter-tslint 8 | -------------------------------------------------------------------------------- /messages/1.6.0.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-tslint 1.6.0 2 | ------------------------------- 3 | 4 | Removed the "config" and "project" settings. 5 | In stead, they can be set using the "args" setting: 6 | 7 | "tslint": { 8 | "args": ["--project", "${folder}"] 9 | } 10 | 11 | Note, that you need to set the --project arg if you want to enable 12 | project based linting. This also enables rules that require the type checker. 13 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | from SublimeLinter.lint import NodeLinter 4 | 5 | logger = logging.getLogger('SublimeLinter.plugin.tslint') 6 | 7 | 8 | class Tslint(NodeLinter): 9 | cmd = 'tslint --format verbose ${file}' 10 | regex = ( 11 | r'^(?:' 12 | r'(ERROR:\s+\((?P.*)\))|' 13 | r'(WARNING:\s+\((?P.*)\))' 14 | r')?' 15 | r'\s+(?P.+?)' 16 | r'\[(?P\d+), (?P\d+)\]: ' 17 | r'(?P.+)' 18 | ) 19 | tempfile_suffix = '-' 20 | defaults = { 21 | 'selector': 'source.ts, source.tsx' 22 | } 23 | 24 | def on_stderr(self, stderr): 25 | # suppress warnings like "rule requires type information" 26 | 27 | stderr = re.sub( 28 | 'Warning: .+\n', '', stderr) 29 | 30 | if stderr: 31 | self.notify_failure() 32 | logger.error(stderr) 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SublimeLinter-tslint 2 | ================================ 3 | 4 | [![Build Status](https://travis-ci.org/SublimeLinter/SublimeLinter-tslint.svg?branch=master)](https://travis-ci.org/SublimeLinter/SublimeLinter-tslint) 5 | 6 | This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) provides an interface to [tslint](https://github.com/palantir/tslint). 7 | It will be used with files that have the "typescript" syntax. 8 | 9 | **Note that `tslint` is deprecated and you should migrate to `eslint`.** This plugin here is to support the legacy. 10 | 11 | 12 | ## Installation 13 | 14 | SublimeLinter must be installed in order to use this plugin. 15 | 16 | Please use [Package Control](https://packagecontrol.io) to install the linter plugin. 17 | 18 | Before installing this plugin, ensure that `tslint` (2.4.0 or later) is installed on your system. 19 | To install `tslint`, do the following: 20 | 21 | 1. Install [Node.js](http://nodejs.org) (and [npm](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) on Linux). 22 | 23 | 1. Install `tslint` by typing the following in a terminal: 24 | ``` 25 | npm install -g tslint 26 | ``` 27 | 28 | 1. If you are using `nvm` and `zsh`, ensure that the line to load `nvm` is in `.zshenv` and not `.zshrc`. 29 | 30 | 31 | ## Settings 32 | 33 | - SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html 34 | - Linter settings: http://sublimelinter.com/en/latest/linter_settings.html 35 | 36 | ### TSLint Config 37 | 38 | You can configure `tslint` options in the way you would from the command line, with `tslint.json` files. 39 | For more information, see the [tslint docs](https://github.com/palantir/tslint). 40 | The linter plugin does this by searching for a `tslint.json` file itself, just as `tslint` does from the command line. 41 | 42 | You may provide a custom config file by setting the linter’s `"args"` setting to `["--config", "/path/to/file"]`. 43 | On Windows, be sure to double the backslashes in the path, for example `["--config", "C:\\Users\\Aparajita\\tslint.json"]`. 44 | 45 | Also, remember to set your project `tsconfig.json` accordingly, so that it includes paths used by SublimeLinter *working copies*. For example: 46 | 47 | ```json 48 | "include": [ 49 | "/var/folders/**/*.tsx", 50 | "/var/folders/**/*.ts", 51 | "./src/**/*.tsx", 52 | "./src/**/*.ts" 53 | ] 54 | ``` 55 | 56 | ### Using Projects 57 | 58 | To enable linting using projects, set the `--project` argument. 59 | E.g. like so to look for the `tsconfig.json` file in the folder you opened in Sublime Text: 60 | 61 | ```json 62 | "tslint": { 63 | "args": ["--project", "${folder}"] 64 | } 65 | ``` 66 | --------------------------------------------------------------------------------