How to disable Ecmascript 6 linting warnings in Visual Studio Code RC5? - visual-studio-code

I know that this is still a release candidate so it's possible that this functionality doesn't yet exist, but there is a setting for it in the Default Settings:
// Specifies which version of ECMA-Script is used.
"javascript.validate.target": "ES5"
I tried overwriting this in the User Settings by entering:
"javascript.validate.target": "ES6"
but this didn't work. Has anyone had any success with this?

ES6 is not yet supported by the JavaScript language service in VSCode.
You can vote for it, though!

Nowadays this is handled in jshint options, so you should set jshint.options.esversion to 6.

Related

Color theme totally messed up [duplicate]

This suddenly happened after I created a new file while working on a project. Almost all characters are simply white text (except for brackets, because I have bracket pair colorization enabled)
I already tried resetting my configurations, checked my configurations (both globally and in my workspace), and tried this extension that offers an alternative syntax highlighting (which worked, but I would prefer using the Visual Studio Code one).
I think this was caused by the extension called JavaScript and TypeScript Nightly. This was causing the syntax highlighting for .js and .ts files (.jsx and .tsx too). This was more of a bug with the latest version (currently 1.73.1).
You can disable the extension to enable the syntax highlighting.
This extension has now been updated and this issue is fixed.
What user Haneen said was correct, but instead of disabling it, you can install an old version that works just fine.
Click the cog on the bottom right → 'Install Another Version' → select an older version.
Cog at bottom right
Yes, this is exactly caused by the JavaScript and TypeScript Nightly extension.
You can disable or install another version (I recommend installing the prior version since the current version has a bug).
I am currently using the version which was released 2022-11-13.
The current version (v5.0.20221116) for JavaScript and TypeScript Nightly seems to be breaking the syntax highlighting. Downgrading to a previous version might resolve this issue.
This was resolved in v5.0.20221117 however.
Also, I deleted this JavaScript and TypeScript Nightly package, and now it works fine for me.
The module on the marketplace: JavaScript and TypeScript Nightly
I think this was caused by the extension called JavaScript and TypeScript Nightly. This was causing the syntax highlighting for .js and .ts files This was more of a bug with the latest version
As others mentioned, the two latest versions are causing issue for me, but 5.20221115 is working for me.
It was fixed with the latest update of JavaScript and TypeScript Nightly.

I want to use the Babel plug-in: optional-chaining, but the vscode console prompted me incorrectly. How can I solve this problem?

I created a new project with the create-react-app scaffold, and then I wanted to use the optional-chaining plug-in of babel. I installed the package according to the document and configured it, but vscode prompted grammatical errors. What can help me? please.
this is my package.json.
this is the problem:
If you are using CRA there is probably no way instead of ejecting project and applying Babel presets manually (according to https://github.com/facebook/create-react-app/issues/4604).
However, if you are decided to use eject there should be able to add plugin to babel config which is described here https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining. Probably applying stage-0 preset of Babel (https://babeljs.io/docs/en/babel-preset-stage-0) can also be a solution.
Edit: see also Null-safe property access (and conditional assignment) in ES6/2015
The error you are seeing is from Visual Studio Code's built-in JavaScript and/or TypeScript validator. In order to circumvent this, add this to your vscode settings.json file:
"javascript.validate.enable": false
Additionally you can disable the built-in TypeScript validator like this:
"typescript.validate.enable": false
Once those are disabled, eslint will take over and show you the proper errors when applicable.

Duplicate hints while typing expression in Visual Studio Code

Why do I have the same suggestions while typing expression?
Example:
I had exactly the same problem. After a week or so, it get really annoying.
basically, as the comments hint to, there are probably multiple linting or intelisense tools. In my case (for python) i had the pylance extension added.
When i disabled this, the problem went away, but features were missing. So i added it back...
For some reason (i dont know why), this fixed the problem !!!
I can only hypothesise that in some way the extension was corrupted. Nevertheless, it worked.
EDIT:
I can also confirm that unchecking this setting appears to work:
Jupyter: Pylance Handles Notebooks
My current system is Windows 11, with python 3.10.
Final edit (8 Dec 2022):
This is resolved here:
Please could you install VS Code 1.74 and the latest Jupyter, PyLance and Python extension and confirm this still exists.
Visual Studio Code provides an API so third-party extensions and built-in modules can contribute suggestions for auto-completion pop-ups. The system is currently designed so suggestions are merely appended—there's no duplicate detection or removal (perhaps because extensions can also take care of sorting suggestions and such algorithm would get on the way). That means that if you have more than one extension or module for a given language you can easily get duplicate entries.
Having several extensions for PHP is not necessarily a bad idea since they can address different needs (for instance, PHP DocBlocker just creates annotations, it doesn't provide auto-completion suggestions) but you have at least two extensions (PHP Intelephense and PHP Intellisense) that do exactly the same things. That's likely to hurt performance (all your workspace files will be scanned several times) and just adds noise.
I suggest you read the extension descriptions carefully to learn what they do exactly and then figure out which ones you need. Remember that extensions can be enabled/disabled in a per-workspace basis.
The following is just my own totally subjective opinion. Among the PHP extensions that provide code intelligence only two of them seem mature enough:
PHP Intelephense
PHP Intellisense
I've tried both. PHP Intelephense works best for me than PHP Intellisense so that's the one I've kept. I've also disabled php.suggest.basic following the installation instructions because basic suggestions didn't add any value to me (they were blind string matching):
Turn off the php.suggest.basic setting for best results.
... as well as taming builtin Emmet support, which was providing really dumb suggestions:
"emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly"
YMMV.
TLDR; Installing pre-release version of Jupyter solves (v2022.11...)
Ok, so after some more extensive experimentation I think I found what's causing this in my case. After looking at the processes I noticed that there were two Pylance processes running, and consistently this would only be a problem if I was working in a session with a jupyter notebook open or one that had been opened.
saun89 17740 37.3 0.3 1008004 199492 ? Sl 20:58 0:22 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:9178e897a2b78b36bfd167f79b36c3bdad2931d71b --node-ipc --clientProcessId=17651
saun89 18743 257 0.7 1304584 382288 ? Sl 20:59 0:20 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:8744a321767eed92821fd737be4dc7dcfb728284e5 --node-ipc --clientProcessId=17651
Pylance basically spins up a service for the workspace, and then spins up a separate service for the notebook.
Output from "Python Language Server" logs:
Disabling Jupyter removes the duplication, and after installing an earlier version of the extension (v2022.4) this appears to have fully resolved the issue. I'm going to go ahead and log the extension bug once I have something reproducible.
As of 11/30/22, Jupyter Extension Pre-Release version v2022.11.1003281132 is the latest version fixes this issue. Click the gear icon next to the extension and you should see "install another version..." Then you can select version v2022.11.1003281132.

VS Code with es6

I am getting the linting error in my code 'import' is only available in ES6 (use 'esversion: 6').
Everything es6 related is throwing an error. Not sure what I have to configure to get it to work.
Add a file named .jshintrc to your project and inside this file type this:
{
"esversion": 6
}
As you can see it here:
The full documentation of jshint options are found here: http://jshint.com/docs/options
Edit: I've added a way to enable es6 if you use ESLint instead of JSHint as well as updating the screenshots since VSCode has changed since my original answer.
JSHint Method:
If you are using JSHint, you can add the following to your settings:
"jshint.options":{
"esversion":6
}
ESLint Method:
If you are using ESLint, you can add the following to your settings:
"eslint.options": {
"env":{
"es6":true
},
"parserOptions": {
"ecmaVersion": 6 // or 7,8,9
}
}
ESLint Configuration Documentation
How to update the settings
Neither JSHint or ESLint are enabled in a fresh version of VS Code, so you'll need to install the extension(s) by going to extensions and then searching for your preferred linter.
In VS Code, head to settings
When the settings display you'll see the settings sections:
Note that there are two sections where you can customize your settings, User Settings and Workspace Settings
User Settings Is where you should apply any global settings you will want for any project you will ever work on.
Workspace Settings Is where you can make settings changes that should only be applied to your current project.
In my case, since I know that only some of my projects can use ES6, I need to have the error hinting to warn me if I'm using ES6 my non-ES6 projects...so I set this only to my Workspace Settings
But, if you know that anything you code in VS Code is going to be an ES6, project, then save a step, and add it to your user settings.
Click on either User/Workspace depending on your preference. Search for JSHint or ESLint (whichever you use). Click on any of the Edit in settings.json links, it doesn't matter which one.
Add the pertinent settings depending on whether you use JSHint or ESLint:
JSHint
ESLint
You can add "esversion": 6 to "jshint.options" in the user settings.
{
"jshint.options": {
"esversion": 6
}
}
Just to round out the excellent suggestions already submitted, you can also set this on a file by file basis by added this escaped line (and similar for other jshint settings) to the top of your file.
// jshint esversion:6
Actually you can add it anywhere, but it only effects subsequent code, allowing you to flip settings on and off if you're desperate to do something weird.
Add the next hint before your code:
/* jshint esversion: 6 */
Example
Make sure, you do the above configurations with the json but also remove/disable the jshint extension for workspace if you're using eslint and vice versa.,
Disable your jshint extension like this:

syntax error before '^' token in UIView.h - not fixed by changing compiler setting

I installed the latest official iphone sdk and now my personal project is getting the same compiler error in UIView.h as described in this question:
Syntax error before '^' token
syntax error before '^' token
The solution is apparently to change compiler settings to use GCC 4.2 or LLVM.
I've tried using every compiler setting available in Xcode that but am still getting the errors.
Is there something else I should be doing to support the (^) block syntax in my project. The project was building fine with the previous official sdk release (pre OS4)
Another strange detail, I only get the error in debug config, not release.
I tried comparing the build settings between debug and release but didnt see any major differences. Where there were differences I tried setting the debug config to use the release config values but still getting those errors.
thanks in advance for any help
ok so I just found my problem.
I was changing build settings by right click -> Get Info on the project but I should have been doing it on the target (which was still using GCC 4.0 even though the project was set to 4.2)
Make sure you have the right configuration or configurations picked when you change compile settings. It's easy to overlook this, for example: picking the Release build when you meant the Debug, or vice versa; or by using other custom build configurations.