Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

TypeScript TSLint language service plugin

License

NotificationsYou must be signed in to change notification settings

microsoft/typescript-tslint-plugin

Repository files navigation

Build Status

❗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 withnpm install typescript-tslint-plugin

  • Enable the plugin in yourtsconfig.json file:

    {"compilerOptions": {"plugins": [      {"name":"typescript-tslint-plugin" }    ]  }}

Seeeditor support for more detailed setup instructions.

Workspace Library Execution

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 atsconfig.

    In VS Code for example, you can run theTSLint: Manage Workspace Library Execution command to enable using the TSLint for the current workspace or for all workspaces.

  • Set aTS_TSLINT_ENABLE_WORKSPACE_LIBRARY_EXECUTION=1 environment variable and make sure the TypeScript server is run in an environment where this variable is set to true.

Configuration options

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.js files, default isfalse.
  • ignoreDefinitionFiles - Control if TypeScript definition files should be ignored. Default istrue
  • alwaysShowRuleFailuresAsWarnings - 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.

Editor Support

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.

With VS Code

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.

Usage with VS Code

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 thevscode-tslint extension which needsto reanalyze the document.
  • Sincevscode-tslint lints one file a time only, it cannot support tslint rules that require the type checker. The plugin doesn't have this limitation.
  • vscode-tslint provides additionalfeatures, please file issue requests for the features you are missing.

With Atom

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"      }    ]  }}

Usage with atom

With Sublime

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"      }    ]  }}

Usage with Sublime

With Visual Studio

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.

With vim and neovim

Usecoc-tslint-plugin as extension ofcoc.nvim.

Run command in your vim after coc.nvim installed:

:CocInstall coc-tsserver coc-tslint-plugin

Run command:CocConfig to open configuration file.

Contributing

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-plugin

Then 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.

VS Code

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 thetest-workspace folder 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 thedev folder
  • code .

To debug the plugin pressF5. Thedev workspace has a launch configuration that attaches through port 5859 to the language server.

Credits

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

Stars

Watchers

Forks

Packages

No packages published

Contributors22


[8]ページ先頭

©2009-2025 Movatter.jp