Reputation: 14610
I recently started seeing, what seems like, TSLint errors. They look like this:
Not using the local TSLint version found for '/Users/myname/myproject/client/src/app/likes/likee/likee.component.ts'. To enable code execution from the current workspace you must enable workspace library execution.
I'm seeing them in my .ts files when I open them and it shows a yellow squiggly line on the first line of each .ts page.
I see on the TSLint site it says it's been deprecated.
What's the cause of these errors and why am I suddenly seeing them?
Should I uninstall the Visual Studio Code TSLint extension and install the ESLint extension?
Upvotes: 273
Views: 106039
Reputation: 903
Although the answer given by @Tuấn Nguyễn works, yet it is not advisable to do so.
As per Microsoft documentation, TSLint, this answer will replace the global TSLint configuration defined with the local one, which one can manipulate easily and it’s not recommended due to security reasons as well.
Screenshot:
Recommended Approach:
As per Microsoft documentation, Migrate from TSLint to ESLint, updated recently (2020-12-11), you should migrate from TSLint to ESLint.
This might be the reason that everyone is looking for the fix, as needful things were done by Microsoft recently. :)
Steps:
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
(Install ESLint and TSLint)npx tslint-to-eslint-config
(This will install a utility tool and make configuration easier. Post install, a new .eslintrc.js will be created. There will be changes to .vscode/settings.json as well.)"lint": "eslint -c .eslintrc.js --ext .ts <mySrcFolder>"
. (This will tell ESLint to look for TSLint)But, you should probably look once, over steps in link more vividly, in order to follow the steps correctly and accordingly.
Upvotes: 51
Reputation: 500
Press Ctrl + Shift + P in Windows or Linux or Command + Shift + P on Mac
Type TSLint: Manage workspace library execution
Choose Always enable workspace library execution
Or you can save workspace file => Save workspace as
Upvotes: 13
Reputation: 583
Press Ctrl + Shift + P to open the Command Palette.
In the input that pops up at the top of the Visual Studio Code, write
TSLint: Manage workspace library execution
From the menu that replaces the input, pick
Enable Workspace Library Execution
Upvotes: 44
Reputation: 459
Go to Command Palette by pressing Ctrl + Shift + P,
In the input that pops up at the top of Visual Studio Code, start typing
TSLint: Manage workspace library execution" and hit Enter.
From the menu that replaces the input, pick enable workspace library execution, and again hit Enter.
Upvotes: 35
Reputation: 2361
The second question: Yes, you should uninstall TSLint and migrate to ESLint since TSLint has been deprecated from Microsoft. This link might help you.
Upvotes: 2
Reputation: 39
Jump to the error. Hover over the lightbulb and you will see the option. Click it and you must be getting the prompt to allow it.
This is how I fixed it myself recently.
VS Code ESLint extension has a more detailed guide. There are multiple steps on how to do it (including the other answers here).
This probably is a security thing from Visual Studio Code to prevent bad things from happening in your code.
Upvotes: 0
Reputation: 558
I fixed the issue in this easy way:
Menu File → Save Workspace As...
By saving the workspace, Visual Studio Code detects some libraries and works better in files.
Upvotes: 13
Reputation: 3
npm i typescript -g
Upvotes: -4
Reputation: 4587
Like Tuấn Nguyễn described, you need to:
Go to the Command Palette by pressing Ctrl + Shift + P,
In the input that pops up at the top of the Visual Studio Code, start typing
TSLint: Manage workspace library execution"
and hit the Enter key.
From the menu that replaces the input, pick enable workspace library execution and again press the Enter key.
Upvotes: 472
Reputation: 858
You should go to the Command Palette in Visual Studio Code to search for TSLint: Manage workspace library execution. And enable workspace library execution.
Upvotes: 85