Giter Site home page Giter Site logo

typescript-tslint-plugin's Introduction

TypeScript TSLint Language Service Plugin

Build Status

❗IMPORTANT: TSLint has been deprecated in favor of ESLint and this plug-in has also been deprecated in favor of eslint.

Please look into migrating your projects to ESLint.

TypeScript language service plugin for TSLint.

To use the plugin:

  • Install TSLint 5+ in your workspace or globally (if you are using a local TSLint, see workspace library execution)

  • Install the plugin with npm install typescript-tslint-plugin

  • Enable the plugin in your tsconfig.json file:

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

See editor 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 a tsconfig.

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

  • Set a TS_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 the tslint.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 is false.
  • ignoreDefinitionFiles - Control if TypeScript definition files should be ignored. Default is true
  • alwaysShowRuleFailuresAsWarnings - Always show rule failures as warnings, ignoring the severity configuration in the tslint.json configuration. Default is true.
  • 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, or pnpm. This is currently only used for error message instructions about how to install tslint. Default is npm.

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 the no-unused-variable rule (palantir/tslint#2469), this rule will be disabled by the plugin. You can use the typescript compiler options noUnusedLocals and noUnusedParameters 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 the vscode-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 the TypeScript 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 a plugins section to your tsconfig.json or jsconfig.json

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

Finally, run the Select 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 versions in the VS Code documentation.

Usage with VS Code

The most important differences between the vscode-tslint extension and typescript-tslint-plugin are:

  • The plugin shares the program representation with TypeScript. This is more efficient than the vscode-tslint extension which needs to reanalyze the document.
  • Since vscode-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 additional features, please file issue requests for the features you are missing.

With Atom

This plugin works with the Atom TypeScript plugin.

First install the plugin and a copy of TypeScript in your workspace:

npm install --save-dev typescript-tslint-plugin typescript

Then add a plugins section to your tsconfig.json or jsconfig.json and restart Atom.

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

Usage with atom

With Sublime

This plugin works with the Sublime 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 by setting the typescript_tsdk setting in Sublime:

{
  "typescript_tsdk": "/Users/me/my-amazing-project/node_modules/typescript/lib"
}

Finally add a plugins section to your tsconfig.json or jsconfig.json and restart Sublime.

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

Usage with Sublime

With Visual Studio

This plugin works Visual Studio 2017 using the TypeScript 2.5+ SDK.

First install the plugin in your project:

npm install --save-dev typescript-tslint-plugin

Then add a plugins section to your tsconfig.json.

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

Then reload your project to make sure the plugin has been loaded properly. Note that jsconfig.json projects are currently not supported in Visual Studio.

With vim and neovim

Use coc-tslint-plugin as extension of coc.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 need Git and Node.js.

First, fork the typescript-tslint-plugin repo and clone your fork:

git clone https://github.com/YOUR_GITHUB_ACCOUNT_NAME/typescript-tslint-plugin.git
cd typescript-tslint-plugin

Then install dev dependencies:

npm install

The plugin is written in TypeScript. The source code is in the src/ directory with the compiled JavaScript output to the lib/ directory. Kick off a build using the compile script:

npm run compile

Please also see our Code of Conduct.

VS Code

To test the newly compiled program, open the test-workspace folder in VS Code and use the TypeScript version picker to switch 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-workspace folder of the tslint-language service.

To setup the stable version for debugging, you need to set the environment variable TSS_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 dev folder
  • code .

To debug the plugin press F5. The dev workspace has a launch configuration that attaches through port 5859 to the language server.

Credits

This project was forked from https://github.com/angelozerr/tslint-language-service which itself is based on https://github.com/Microsoft/vscode-tslint/

typescript-tslint-plugin's People

Contributors

aleclarson avatar angelozerr avatar bgever avatar chemzqm avatar dependabot[bot] avatar egamma avatar exe-boss avatar istar-eldritch avatar kondi avatar krzkaczor avatar luxcium avatar mjbvz avatar nickjs avatar nicolashenry avatar oliverjash avatar reduckted avatar rsheasby avatar simark avatar smasala avatar spion avatar vemoo avatar zazzlealex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-tslint-plugin's Issues

Default alwaysShowRuleFailuresAsWarnings to true

This extension could be the occasion to fix an important issue with TSLint.

In previous versions of TSLint, problems were reported as warnings by default. This was changed and now TSLint reports problems as errors by default.

I understand the scenarios where it is useful. For example, before publishing, if you run a command like npm run lint, you want it to fail if there are problems.

But inside the editor, showing syntax errors in the same way as lint problems is an awful UX for developers. To be clear, it's not just a personal opinion: as an Angular and JavaScript trainer, I've seen hundred of developers, and every single one is confused by this behavior. Also, Vue.js CLI is changing alwaysShowRuleFailuresAsWarnings to true, surely because otherwise developers are too much troubled.

As this extension is precisely for the editor, and for the editor only, I think it should default alwaysShowRuleFailuresAsWarnings to true. It would allow a good UX inside the editor, while having no consequences for CLI commands implying linting that await errors.

Duplicate "Fix all 'rule name'" quick fixes

Repo

  1. Open the file:
let t: Array<string> = new Array<string>();
let x: Array<string> = new Array<string>();
  1. Select entire document and request quick fixes

Bug
Two quick fixes for fix all 'array-type' shown:

screen shot 2019-01-21 at 3 58 43 pm

Somewhat related to #47

Does not work with config as javascript file (instead of json)

I need to define my tslint.json as javascript file. But when I specify the path to my tslint.js file the configuration is not picked up by this extension.

My js config file works when I run tslint manually like so: tslint --config ./tslint.js --project .

Option to lint entire workspace and/or to prevent running apps with tslint errors

I just switched from create-react-app-typescript (which is now deprecated) to CRA 2.1.1 with TypeScript support. There are two gaps I'm trying to address.

I followed the VSCode setup instructions for create-react-app-typescript and it's working great to find lint errors in files that I'm currently editing. But I can't figure out how to lint my entire project, including files that aren't currently open in VSCode, whenever I load my workspace or change a file that might impact other files. Is there a way to do this by default?

The second thing I'm missing from other non-CRA projects is the ability to block npm start if there are lint errors. This comment from @WorldMaker pointed to typescript-tslint-plugin as the missing tslint support in CRA 2.x. Can typescript-tslint-plugin force CRA 2.x's npm start to report lint errors, just like it will for "compiler" errors that are caught by Babel?

plugin seem don't work through package installed

I clone the repository to open it work prefect in VS Code. capture 1
But editor doesn't report everything in a demo. capture 2

the tslint.json copy from the repository and tsconfig.json content:

{
  "compilerOptions": {
    "outDir": "build",
    "module": "es6",
    "target": "es5",
    "sourceMap": true
  }
}

some version:

  • tslint 5.12.1
  • typescript 3.3.1
  • vscode-typescript-tslint-plugin 1.0.0

alwaysShowRuleFailuresAsWarnings doesn't change severity

I'm trying to migrate to this plugin from deprecated vscode-tslint. My configuration is

{
  "extends": "./tsconfig.base",

  "plugins": [{
    "name": "typescript-tslint-plugin",
    "alwaysShowRuleFailuresAsWarnings": false
  }]
}

But alwaysShowRuleFailuresAsWarnings has no effect and errors are always displaying as warnings. vscode-tslint works fine.

VSCode v1.30.0
TypeScript v3.1.6 (workspace) and v3.2.2 (vscode)

Support auto-fix on save and/or quick fix for problems that can be --fix ed

This is a feature of the old tslint vscode plugin but not of the service-based one. Previously autofixable rules have to either be autofixed externally or completely manually.

The "Quick fix" menu also shows "no code action available" even on lint warnings that there are autofixers; for example, the ordered-imports rule or the semi rule.

Can't get VS2017 to show errors in editor

Hi there -

I'm trying to set this up. I have followed the instructions listed in the readme, but I'm not seeing anything show up in VS2017's editor.

Here is my tsconfig.json:

{
	"compileOnSave": true,
	"compilerOptions": {
		"rootDir": "./",
		"preserveSymlinks": true,
		"baseUrl": "src",
		"allowSyntheticDefaultImports": true,

		"paths": {
			"*": [
				"./Client/node_modules/*",
				"./Client/node_modules/@types/*"
			],
			"@ApiIntermediary": [ "Global/Platform/ApiIntermediary" ],
			"@Utilities": [ "Utilities/index" ],
			"@Global/*": [ "Global/*" ],
			"@Components/*": [ "UI/Components/*" ],
			"@Areas/*": [ "UI/Areas/*" ],
			"@Boot/*": [ "UI/Boot/*" ],
			"@Styles/*": [ "Styles/*" ],
			"@UIKit/*": [ "UI/Components/UIKit/*" ]
		},

		"module": "esnext",
		"moduleResolution": "node",
		"target": "es6",
		"lib": [
			"es6",
			"es2015",
			"dom"
		],
		"jsx": "react",
		"sourceMap": true,
		"strict": false,
		"types": [
			"webpack-env"
		],
		"typeRoots": [
			"./Client/node_modules/@types"
		],
		"plugins": [
			{
				"name": "tslint-language-service",
				"configFile": "tslint.json",
				"suppressWhileTypeErrorsPresent": false,
			}
		]
	},
	"exclude": [
		"bin"
	]
}

My tslint.json file is a sibling to the tsconfig.json file. I have attached the tslint.json.

I have also installed typescript-tslint-plugin as well as tslint. I've verified that linting works at build time with webpack, but I'm having trouble getting VS2017 to show any kind of errors or warnings in the editor.

I'm happy to provide any other information!

VS2017 (15.9.6)
Project is set to use TS3.1 in the project properties

Duplicated quick fix actions

Testing: microsoft/vscode#62092

image

This the quick fix menu shown in vscode-tslint
image

I remember that I had this issue in vscode-tslint, the issue is that the quick fixes where added twice in the code.

Test case

test.ts

console.log("foo")


console.log("bar")


console.log("baz")

tslint.json

{
  // "linterOptions": { "exclude": [ "./**/arrow-parens.ts" ]},
    "rules": {
        "no-consecutive-blank-lines": true,
        "array-type": [
            true,
            "array-simple"
        ],
        "arrow-parens": true,
        "no-var-keyword": true,
        "no-unused-variable": [
            true,
            {
                "ignore-pattern": "^_"
            }
        ],
        "ordered-imports": [
            true,
            {
                "import-sources-order": "lowercase-last",
                "named-imports-order": "lowercase-first"
            }
        ],
        "trailing-comma": [
            true,
            {
                "multiline": "always",
                "singleline": "never"
            }
        ],
        "class-name": true,
        "comment-format": [
            true,
            "check-space"
        ],
        "indent": [
            true,
            "spaces"
        ],
        "no-eval": true,
        "no-internal-module": true,
        "no-trailing-whitespace": true,
        "no-unsafe-finally": true,
        "one-line": [
            true,
            "check-open-brace",
            "check-whitespace"
        ],
        "quotemark": [
            true,
            "double"
        ],
        "semicolon": [
            true,
            "always"
        ],
        "triple-equals": [
            true,
            "allow-null-check"
        ],
        "typedef-whitespace": [
            true,
            {
                "call-signature": "nospace",
                "index-signature": "nospace",
                "parameter": "nospace",
                "property-declaration": "nospace",
                "variable-declaration": "nospace"
            }
        ],
        "variable-name": [
            true,
            "ban-keywords"
        ],
        "whitespace": [
            true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-separator",
            "check-type"
        ]
    },
    "jsRules": {
        "triple-equals": [
            true,
            "allow-null-check"
        ]
    },
    "defaultSeverity": "warning"
}

No tslint info show on status bar

I have install typescript-tslint-plugin, add config to tsconfig.json, and set local typescript version for Sublime text 3. But can't find the tslint icon or lint info on status bar.

And run lint command it shows no lint results. as the same time, I find the build-in typescript compiler checker works as well.

So it look like typescript-tslint-plugin dose not work. I have seared but have any idea. Thinks any help.

Disables "editor.showUnused" in VSCode

Description

When using this in VSCode (as per the instructions in the README), "editor.showUnused": true no longer dims unused imports.

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true,
        "lib": [
            "es6",
            "dom",
            "es2015.iterable"
        ],
        "baseUrl": ".",
        "paths": {
            "*": [
                "./node_modules/*"
            ],
            "~/*": [
                "app/*"
            ]
        }
    },
    "exclude": [
        "node_modules",
        "platforms",
        "typings",
        "**/*.aot.ts",
        "additional-models"
    ],
    "plugins": [
        { "name": "typescript-tslint-plugin" }
    ]
}

tslint.json

{
  "extends": "tslint:recommended" 
}

Example code

import { Component, OnInit } from "@angular/core";

@Component({
    template: "<div></div>",
})
export class MyComponent {
    // no body.
}

Result:

screen shot 2018-10-31 at 3 19 05 pm

Expected:

Notice that the OnInit import (which is unused) is now appropriately dimmed.
screen shot 2018-10-31 at 3 19 33 pm

Todo

typescript-tslint-plugin (node-module)

  • Publish repository @mjbvz
  • Publish npm module @mjbvz
  • Surface TSLint warnings to user (first line of file?) @mjbvz

tslint-language-service (node module) - old plugin implementation

vscode-typescript-tstlint-plugin (extension)

https://github.com/Microsoft/vscode-typescript-tslint-plugin

  • Create separate repo for vscode extension: vscode-tslint-ts-plugin: @mjbvz
  • Help users migrate from using vscode tslint settings to using settings in tsconfig.json @mjbvz
  • Add schema and problem matcher contributions @mjbvz
  • Add "open tslint file" command @mjbvz
  • Command to create a tslint.json @mjbvz
  • Publish extension to the market place @mjbvz
  • Fix on save: @mjbvz Explore

vscode-tslint (extension)

  • Migration guidance from old tslint extension to new one: @egamma October, depends on having new repos setup first

vscode-ts-tslint (extension)

  • Add deprecation message @egamma October, depends on having new repos setup first
  • Unpublish from market place @egamma

Not for October

  • Fix all should handle overlapping fixes issue
  • Task provider to run tslint in a folder

a tslint.json placed in a directory above tsconfig.json is not applied

Say there is a monorepo structure such as this one

- tslint.json
- node_modules/...
- packages/a/tsconfig.json
- packages/a/src/...

then tslint.json is not automatically found and applied (it is with the "old" tslint plugin)

if a tslint.json is placed in packages/a/tslint.json that just extends the root one then it will work

JS files are not linted

Testing: microsoft/vscode#62092

Please see the screenshot below. In the tslint.json there is a jsRule that is validated but there is no diagnostic error
image

tslint.json

{
    "jsRules": {
        "triple-equals": [
            true,
            "allow-null-check"
        ]
    },
    "defaultSeverity": "warning"
}

test.js

// test a jsRule trippe equals
   let a = 2;

    if (a == 2) {
 
    }

Add an "Editor Support" section for Vim with ALE

I've been supporting a variety of tsserver features directly and very well for a long time with ALE. I'm opening this issue mostly to leave a note for myself to create a pull request to describe how to set up this plugin in ALE. All you have to essentially do is install ALE and set up tsconfig.json. The rest should just work.

For ALE, I strongly recommend using this plugin instead of running tslint on files directly.

TypeScript 2.4 - 2.8 support

Documentation states that this plugin requires TypeScript 2.4 or later. However, in the code there is a language services version hardcoded (link), which is valid only for TypeScript 2.9+. It seems like either documentation should be updated to reflect this or version restriction downgraded (I made a quick test with TS 2.6 which has 0.7 version of language services and everything seems to be working).

tslint is telling me to use spaces in my js files

I don't know if this is related to this plugin, but I just switched to it from the other one. After creating a JS file, I get a tslint error on every line telling me to indent with spaces:

screen shot 2018-11-13 at 9 54 44 am

My tslint.json looks like this:

{
	"extends": [
		"tslint:recommended"
	],
	"linterOptions": {
		"exclude": [
			"src/analysis/analysis_server_types.ts",
			"src/analysis/analyzer_gen.ts"
		]
	},
	"rulesDirectory": "lints/",
	"rules": {
		"disallow-fspath": true,
		"disallow-vscode-in-debuggers": true,
		"indent": {
			"options": "tabs"
		},
		"curly": false,
		"no-console": false,
		"max-classes-per-file": false,
		"interface-name": false,
		"member-ordering": false,
		"no-empty": {
			"options": "allow-empty-catch"
		},
		"space-before-function-paren": false,
	}
}

I'm not sure:

  1. Why .js files are being linted by tslint
  2. Why it's telling me it expects spaces when the config says tabs

Allow usage of external tslint npm module

Add a setting like "tslint.nodePath" to point to a tslint binary. This is especially helpful in scenarios where you want to make sure the lint errors you see in vscode match what you would get running it from the command line.

"node.getSourceFile is not a function" error in Visual Studio Code

I get this error in Typescript output console in Visual Studio Code when I click on a variable name once I add the plugin in tsconfig.json :

[Error  - 3:15:10 PM] 'occurrences' request failed with error.
Error processing request. node.getSourceFile is not a function
TypeError: node.getSourceFile is not a function
    at toHighlightSpan (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:96814:35)
    at Array.map (<anonymous>)
    at getSemanticDocumentHighlights (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:95528:59)
    at Object.getDocumentHighlights (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:95513:20)
    at getDocumentHighlights (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:114913:42)
    at Object.getOccurrencesAtPosition (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:114899:31)
    at Object.proxy.(anonymous function) [as getOccurrencesAtPosition] (l:\git\mobile\src\node_modules\typescript-tslint-plugin\out\index.js:67:33)
    at IOSession.Session.getOccurrences (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:122233:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:121766:61)
    at l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:123086:88
    at IOSession.Session.executeWithRequestId (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:123077:28)
    at IOSession.Session.executeCommand (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:123086:33)
    at IOSession.Session.onMessage (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:123106:35)
    at Interface.<anonymous> (l:\git\mobile\src\node_modules\typescript\lib\tsserver.js:124369:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

Note that matching occurrences are not highlighted anymore when the error occurs.

I added this in tsconfig.json / compilerOptions :

"plugins": [
      {
        "name": "typescript-tslint-plugin",
        "suppressWhileTypeErrorsPresent": true
      }
    ]

I am using Typescript 3.1.3 (Workspace Version) with Visual Studio Code 1.28.2.

Exclude doesn't work

I am getting the following warning in VSCode for some typescript-generated javascript:

{
  "resource": ".../packages/cli/lib",
  "owner": "typescript",
  "code": "1",
  "severity": 4,
  "message": "variable name must be in lowerCamelCase, PascalCase or UPPER_CASE (variable-name)",
  "source": "tslint",
  "startLineNumber": 25,
  "startColumn": 7,
  "endLineNumber": 25,
  "endColumn": 15
}

I have "packages/*/lib" in my tslint configuration file's exclude option (its a lerna project), but the only way I can get the warning to disappear is by disabling javascript validation altogether.

TsLint won't work properly if TS Language Server has different TypeScript version

When Language Server and TsLint use different versions of TypeScript (e.g. Visual Studio editor uses latest globally installed TypeScript version and TsLint uses locally installed version) a compiled typescript program with TS version from Language Server is passed to the TsLint. In such case, due to versions mismatch most of the TsLint rules won't work.

tslint-language-service package has an option to fix such situation (mockTypeScriptVersion), but it has several drawbacks like affecting other plugins and usage of server version instead of the local one.
It seems a better solution would be to add another option which would perform in an opposite way - program can be created using Linter.createProgram function and passed to the Linter.lint function. In this way the local TypeScript version will be used and version mismatch avoided.

Travis CI builds are missing Windows coverage

Travis supports Windows now! 🎉

Can the CI builds also run on Windows to catch Windows-specific bugs? It'd be very useful to help keep unit test bugs such as #11 from popping up sporadically.

JS files not being linted after update to 0.1.0

After updating the typescript-tslint-plugin package from 0.0.5 to 0.1.0 and adding "jsEnable": true to my tsconfig.json, .js files are not linted anymore.

VSCode 1.29.1
TypeScript TSLint Plugin 0.1.0
typescript 3.1.6 (locally installed for the project; VSCode uses this installation instead of built-in)
typescript-tslint-plugin 0.1.0

tsconfig.json snippet:

"plugins": [{
  "name": "typescript-tslint-plugin",
  "jsEnable": true
}]

Don't show TS Lint fixes on non-tslint errors

Repo

  1. Open the file:
const a = 1; a = 2;
  1. Place cursor over the error for a = 2

Bug
Quick fix for fixing all TSlint errors is returned

We should not return this quick fix for non-tslint errors

TypeScript service often gets stuck when the plugin is enabled

I don't yet know the cause or how to reproduce it; but when using the plugin in my work project, the typescript service may get stuck while typing after showing some lint errors and then never update again until it is restarted. It's not just the lint messages that get stuck, but the actual ts compiler service; unused variable hints, autocomplete, etc stop working, or rather, get stuck in a state where it's as if they're seeing an old snapshot of the file being edited.

{
  "name": "typescript-tslint-plugin",
  "jsEnable": true,
  "ignoreDefinitionFiles": false,
  "suppressWhileTypeErrorsPresent": true
}

Unit tests fail on Windows for backwards vs forward slashes difference

Another fun Windows exclusive bug :)

1) TSLintRunner
       runTsLint
         should return an error for test file:

      AssertionError: expected 'C:/Code/typescript-tslint-plugin/test-data/with-tslint/test.ts' to equal 'C:\\Code\\typescript-tslint-plugin\\test-data\\with-tslint\\test.ts'
      + expected - actual

      -C:/Code/typescript-tslint-plugin/test-data/with-tslint/test.ts
      +C:\Code\typescript-tslint-plugin\test-data\with-tslint\test.ts

      at Context.it.only (out\test\runner.test.js:29:58)

Disable rule is often not shown

I believe disabling a rule on a line by line basis should always be an option. Currently it is not. Most of the time the option to disable a rule is not available ...even when the quick fix option to disable all is available.

I was about to migrate from the old project at https://github.com/angelozerr/tslint-language-service and I am wondering if this PR can be included into this project: angelozerr/tslint-language-service#87 ?

I'm back to the old project for now where I have manually added this PR to my personal installation. But I just wanted to let you know because I just tried out this version and this is what was missing for me.

Or maybe I am missing something? Without the option to disable a rule, I must always look up the corresponding rule and type the comment to disable it by hand. Surely this is not intended? :)

Thank you.

Edit. example

const somevar = null as any;
const somevar2 = require(somevar);

This code shows 2 tslint errors (no-any and no-var-requires), but non of the disable rule quick fixes will show!

Visual Studio reports `defaultSeverity` as warning

Bug Report

I am setting up TSLint support for Visual Studio 2017. I have included this plug-in in my tsconfig.json file and, while it takes a moment to run its analysis, I do get results in the Error Window. However, I set the defaultSeverity to error with the expectation that the TSLint results would show up as Errors in the Error Window. When I run TSLint through the CLI, the results are reported at Errors as I would expect. So I believe this is working.

Is this the right expectation for Visual Studio?
Perhaps I am missing something in the setup for Visual Studio?

  • tslint-microsoft-contrib version: 0.3.1
  • TSLint version: 5.11.0
  • TypeScript version: 2.9.2
  • Running TSLint via: Visual Studio

tslint.json` configuration:

{
  "defaultSeverity": "error",
  "extends": "tslint:recommended",
  "jsRules": {},
  "rules": {  },
  "rulesDirectory": []
}

Actual behavior

TSLint errors are displayed as Warnings in the Error Window

Expected behavior

TSLint errors are displayed as Errors in the Error Window

Failure to load global tslint

The current code fails to load a globally installed tslint.

The reason is that a failed lookup in resolveToTsLint does not throw an exception, but returns an empty path. As a consequence the look up is not retried with the global path.

I´ve fixed it in my version by also checking for an empty path returned from the resolve function.

See the PR #3.

(Interestingly this is one of the few areas we could not cover with unit tests 😃 )

rule jsx-boolean-value is ignored

Hi, I'm not sure if my issue is a bug or something that I am doing wrong. But my lint-rule is being ignored. I want to use the shorthand notation but the linter keeps throwing errors at me for it. I am coding react with typescript and got the settings as shown below.

Any idea how I can make it work?

tsconfig.json

{
  "compilerOptions": {
    "outDir": "build",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom", "es2016", "es2017"],
    "sourceMap": true,
    "allowJs": false,
    "jsx": "react",
    "inlineSources": false,
    "declaration": true,
    "moduleResolution": "node",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "plugins": [
      {
        "name": "typescript-tslint-plugin",
        "alwaysShowRuleFailuresAsWarnings": false,
        "ignoreDefinitionFiles": true,
        "configFile": "./tslint.json",
        "suppressWhileTypeErrorsPresent": false,
        "mockTypeScriptVersion": false
      }
    ]
  },
  "include": ["src"],
  "exclude": ["node_modules", "build", "dist", "example", "rollup.config.js"]
}

tslint.json

{
  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
  "linterOptions": {
      "exclude": [
        "config/**/*.js",
        "node_modules/**/*.ts"
      ]
    },
    "rules":  {
      "ordered-imports": [false, {
        "import-sources-order": "any",
        "named-imports-order": "case-insensitive",
        "grouped-imports": true
      }],
      "interface-name": [true, "never-prefix"],
      "jsx-no-lambda": false,
      "class-name": true,
      "member-access": false,
      "no-unused-expression": [true, "allow-fast-null-checks"],
      "no-var-requires": false,
      "trailing-comma": true,
      "triple-equals": true,
      "no-submodule-imports": false,
      "no-console": false,
      "tslint-no-circular-imports": false,
      "object-literal-shorthand": true,
      "forin": true,
      "arrow-return-shorthand": true,
      "jsx-boolean-value": "never",
      "object-literal-sort-keys": false
    }
  }

Diagnostic code shown in Problems view is unpleasant

Testing: microsoft/vscode#62092

See the screenshot below and notice:

  • each tslint diagnostic has the same diagnostic code 10000
  • each diagnostic includes the rule name

At some point it was discussed that error code are strings in the TS language service. If that would be the case then tslint could use the rule name as the diagnostic code

image

Same problem with diagnostic hover

image

References to `tslint-language-service `

There are several references to tslint-language-service in the code and documentation. I do understand the fork and refactoring ongoing, just that it would be nice to remove them to avoid further confusion.
Please go on in this project! It is really a great job.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.