microsoft / vscode-typescript-tslint-plugin

VS Code extension that provides TSLint support using the typescript-tslint-plugin
https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin
MIT License
189 stars 34 forks source link

Dokumentation - How to use workspace version #54

Closed probert94 closed 5 years ago

probert94 commented 5 years ago

In an Angular-Project, I am trying to replace the TSLint plugin with this plugin.
I am using VS Code Insiders (1.32.0-insider) and I am trying to configure the plugin to use the workspace version of typescript, which is currently 3.2.4. As the documentation says, that I only need to manually configure the TS Server, if I am using a workspace version in VS Code <= 1.30, all I did was disable the TSLint-Plugin and enable this one.
However, I don't get any Lint-Warnings. As soon as I activate VS Code's typescript version, it works as expected.

So I tryed to install "typescript-tslint-plugin" locally using npm install --save-dev typescript-tslint-plugin and I even add the plugin-section to my tsconfig.json but it still did not work. Installing it gloablly, using npm install -g typescript-tslint-plugin did not help either.

Here is the tsserver.log output, without configuring tsconfig.json:

Info 0 [9:27:11.889] Starting TS Server Info 1 [9:27:11.893] Version: 3.2.4 Info 2 [9:27:11.893] Arguments: C:\Users\User\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe c:\Angular\my-app\node_modules\typescript\lib\tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName C:\Users\User\AppData\Local\Temp\vscode-typescript\tscancellation-89a9a45610b753d692c3.tmp* --logVerbosity verbose --logFile c:\Users\User\AppData\Roaming\Code - Insiders\logs\20190211T091343\exthost1\vscode.typescript-language-features\tsserver-log-cu6C3p\tsserver.log --globalPlugins typescript-tslint-plugin --pluginProbeLocations C:\Users\User.vscode-insiders\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.0.0 --npmLocation "C:\Apps\NodeJS\npm.cmd" --locale en --noGetErrOnBackgroundUpdate Info 3 [9:27:11.895] Platform: win32 NodeVersion: 10 CaseSensitive: false

Am I missing something?

mjbvz commented 5 years ago

Can you please share more from the logs. There should be a section near the top where it tries to load the plugin and that could be failing

probert94 commented 5 years ago

I just had a look at the log but the plugin seems to load successfully:

Info 36 [16:50:46.59] Loading global plugin typescript-tslint-plugin Info 37 [16:50:46.59] Enabling plugin typescript-tslint-plugin from candidate paths: c:/Angular/my-app/node_modules/typescript/lib/tsserver.js/../../..,C:\Users\User.vscode-insiders\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.0.0 Info 38 [16:50:46.60] Loading typescript-tslint-plugin from c:/Angular/my-app/node_modules/typescript/lib/tsserver.js/../../.. (resolved to c:/Angular/my-app/web/portal/node_modules/node_modules) Info 39 [16:50:46.149] [typescript-tslint-plugin] "Create" Info 40 [16:50:46.149] [typescript-tslint-plugin] "ConfigurationManager: Found configured project: c:/Angular/my-app/tsconfig.json" Info 41 [16:50:46.149] [typescript-tslint-plugin] "loaded" Info 42 [16:50:46.150] Plugin validation succeded

However, I noticed the following at the end of the log:

Info 7844 [16:51:41.77] [typescript-tslint-plugin] "Computing tslint semantic diagnostics for 'c:/Angular/my-app/apps/my-app/src/app/model/Client.ts'" Info 7845 [16:51:41.77] [typescript-tslint-plugin] "start validateTextDocument" Info 7846 [16:51:41.77] [typescript-tslint-plugin] "validateTextDocument: about to load tslint library" Info 7847 [16:51:41.77] [typescript-tslint-plugin] "validateTextDocument: loaded tslint library" Info 7848 [16:51:41.77] [typescript-tslint-plugin] "About to validate c:/Angular/my-app/apps/my-app/src/app/model/Client.ts'" Info 7849 [16:51:41.77] [typescript-tslint-plugin] "start doValidate c:/Angular/my-app/apps/my-app/src/app/model/Client.ts'" Info 7850 [16:51:41.77] [typescript-tslint-plugin] "Changed directory to c:/Angular/my-app" Info 7851 [16:51:41.77] [typescript-tslint-plugin] "validateTextDocument: about to getConfiguration" Info 7852 [16:51:41.77] [typescript-tslint-plugin] "getConfiguration forc:/Angular/my-app/apps/my-app/src/app/model/Client.ts'" Info 7853 [16:51:41.77] [typescript-tslint-plugin] "validateTextDocument: configuration fetched" Info 7854 [16:51:41.77] [typescript-tslint-plugin] "Linting: start linting" Info 7855 [16:51:41.79] [typescript-tslint-plugin] "tslint error ENOENT: no such file or directory, open 'c:\Angular\my-app\node_modules\typescript\lib/angular.json'"

I then enabled the VS Code-Version of the log, to be able to compare them and there, this tslint error ENOENT is missing.

I just installed the lastest typescript-tslint-plugin version (0.3.1) using npm install --save-dev typescript-tslint-plugin and I am using Typescript 3.2.4

rodbecc commented 5 years ago

Are you using Nx Workspace? Can you share your tslint.json rulesDirectory property? We have the same issue. Seems like a linting rule from @nrwl/schematics depends on angular.json and can't find it when using workspace version of Typescript. There is an issue on their repo.

probert94 commented 5 years ago

@rodbecc I am using Nx Workspace and my rulesDirectory looks like this:

    "rulesDirectory": [
        "node_modules/codelyzer",
        "node_modules/@nrwl/schematics/src/tslint"
    ],

Thanks for pointing me to the issue in Nx!

probert94 commented 5 years ago

I tryed to remove the rulesDirectory for @nrwl/nx and the plugin works fine now. So this issue can be closed, since it is not an issue with the plugin, but with @nrwl/nx.