- Notifications
You must be signed in to change notification settings - Fork42
TypeScript TSLint language service plugin
License
microsoft/typescript-tslint-plugin
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
❗IMPORTANT: TSLinthas been deprecated in favor of ESLint and this plug-in has also been deprecated in favor of eslint.
Please look intomigrating your projects to ESLint.
TypeScriptlanguage service plugin forTSLint.
To use the plugin:
Install TSLint 5+ in your workspace or globally (if you are using a local TSLint, seeworkspace library execution)
Install the plugin with
npm install typescript-tslint-pluginEnable the plugin in your
tsconfig.jsonfile:{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin" } ] }}
Seeeditor support for more detailed setup instructions.
By default this plugin will not load TSLint or custom rules from the workspace if you are using a global version of TypeScript. This is done for security reasons. The plugin always allows using the global version of TSLint.
To use enable using a local TSLint install and custom rules from the workspace, you must either:
Use a workspace version of TypeScript that is installed alongside TSLint.
Enable workspace library execution in your editor of choice. This must be done through an editor and cannot be configured in a
tsconfig.In VS Code for example, you can run the
TSLint: Manage Workspace Library Executioncommand to enable using the TSLint for the current workspace or for all workspaces.Set a
TS_TSLINT_ENABLE_WORKSPACE_LIBRARY_EXECUTION=1environment variable and make sure the TypeScript server is run in an environment where this variable is set to true.
Notice: This configuration settings allow you to configure the behavior of the typescript-tslint-plugin itself. To configure rules and tslint options you should use thetslint.json file.
configFile- The configuration file that tslint should use instead of the default tslint.json. A relative file path is resolved relative to the project root.jsEnable- Enable/disable tslint for.jsfiles, default isfalse.ignoreDefinitionFiles- Control if TypeScript definition files should be ignored. Default istruealwaysShowRuleFailuresAsWarnings- Always show rule failures as warnings, ignoring the severity configuration in the tslint.json configuration. Default istrue.suppressWhileTypeErrorsPresent- Suppress tslint errors from being reported while other errors are present.exclude- List of files to exclude from tslint.packageManager- Package manager used, either:npm,yarn, orpnpm. This is currently only used for error message instructions about how to install tslint. Default isnpm.
Here is a configuration sample:
{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin","alwaysShowRuleFailuresAsWarnings":false,"ignoreDefinitionFiles":true,"configFile":"../tslint.json","suppressWhileTypeErrorsPresent":false } ] }}Notice: due to an issue in the implementation of theno-unused-variable rule (palantir/tslint#2469), this rule will be disabled by the plugin. You can use the typescript compiler optionsnoUnusedLocals andnoUnusedParameters instead.
This plugin requires TypeScript 3.0 or later. It can provide intellisense in both JavaScript and TypeScript files within any editors that uses TypeScript to power their language features.
If you also have thevscode-tslint extension in VS Code installed, please disable it to avoid that files are linted twice.
The simplest way to use this plugin is to install theTypeScript TSLint Plugin VS Code extension. This extension enables the plugin when using VS Code's version of TypeScript.
If you are using a workspace version of TypeScript, you must manually install the plugin alongside the version of TypeScript in your workspace:
npm install --save-dev typescript-tslint-plugin typescript
Then add aplugins section to yourtsconfig.json orjsconfig.json
{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin" } ] }}Finally, run theSelect TypeScript version command in VS Code to switch to use the workspace version of TypeScript for VS Code's JavaScript and TypeScript language support. You can find more information about managing typescript versionsin the VS Code documentation.
The most important differences between thevscode-tslint extension andtypescript-tslint-plugin are:
- The plugin shares the program representation with TypeScript. This is more efficient than the
vscode-tslintextension which needsto reanalyze the document. - Since
vscode-tslintlints one file a time only, it cannot support tslint rules that require the type checker. The plugin doesn't have this limitation. vscode-tslintprovides additionalfeatures, please file issue requests for the features you are missing.
This plugin works with theAtom TypeScript plugin.
First install the plugin and a copy of TypeScript in your workspace:
npm install --save-dev typescript-tslint-plugin typescript
Then add aplugins section to yourtsconfig.json orjsconfig.json and restart Atom.
{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin" } ] }}This plugin works with theSublime TypeScript plugin.
First install the plugin and a copy of TypeScript in your workspace:
npm install --save-dev typescript-tslint-plugin typescript
And configure Sublime to use the workspace version of TypeScript bysetting thetypescript_tsdk setting in Sublime:
{"typescript_tsdk":"/Users/me/my-amazing-project/node_modules/typescript/lib"}Finally add aplugins section to yourtsconfig.json orjsconfig.json and restart Sublime.
{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin" } ] }}This plugin worksVisual Studio 2017 using the TypeScript 2.5+ SDK.
First install the plugin in your project:
npm install --save-dev typescript-tslint-plugin
Then add aplugins section to yourtsconfig.json.
{"compilerOptions": {"plugins": [ {"name":"typescript-tslint-plugin" } ] }}Then reload your project to make sure the plugin has been loaded properly. Note thatjsconfig.json projects are currently not supported in Visual Studio.
Usecoc-tslint-plugin as extension ofcoc.nvim.
Run command in your vim after coc.nvim installed:
:CocInstall coc-tsserver coc-tslint-pluginRun command:CocConfig to open configuration file.
To build the typescript-tslint-plugin, you'll needGit andNode.js.
First,fork the typescript-tslint-plugin repo and clone your fork:
git clone https://github.com/YOUR_GITHUB_ACCOUNT_NAME/typescript-tslint-plugin.gitcd typescript-tslint-pluginThen install dev dependencies:
npm install
The plugin is written inTypeScript. The source code is in thesrc/ directory with the compiled JavaScript output to thelib/ directory. Kick off a build using thecompile script:
npm run compile
Please also see ourCode of Conduct.
To test the newly compiled program, open thetest-workspace folder in VS Code and use the TypeScript version picker toswitch to the local version of TypeScript.
To debug you use two versions of VS Code, e.g., the stable and the insider version. The idea is that one of them is configured to support attaching a debugger to the Typescript language server:
- Use the insider version for development and open it on the typescript-tslint-plugin workspace.
- Use the stable version for debugging opened on the
test-workspacefolder of the tslint-language service.
To setup the stable version for debugging, you need to set the environment variableTSS_DEBUG to port 5859. In a command prompt/shell:
- make sure that the stable version isn't running already
set TSS_DEBUG=5859- cd to the
devfolder code .
To debug the plugin pressF5. Thedev workspace has a launch configuration that attaches through port 5859 to the language server.
This project was forked fromhttps://github.com/angelozerr/tslint-language-service which itself is based onhttps://github.com/Microsoft/vscode-tslint/
About
TypeScript TSLint language service plugin
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.


