Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable: [js] File is a CommonJS module; it may be converted to an ES6 module

The following is what I want to disable:

[js] File is a CommonJS module; it may be converted to an ES6 module.

I can't find it in settings.
Help appreciated as this is really annoying.

like image 795
SunburntRock89 Avatar asked Mar 31 '18 00:03

SunburntRock89


People also ask

What is the difference between ES6 and CommonJS?

While CommonJS and ES6 modules share similar syntax, they work in fundamentally different ways: ES6 modules are pre-parsed in order to resolve further imports before code is executed. CommonJS modules load dependencies on demand while executing the code.

How do I use the CommonJS module in ES6 module?

An ES6 Module can load other ES6 modules using import. An ES6 Module can load CommonJS using import. A CommonJS module can load other CommonJS modules using require. A CommonJS module previously COULD NOT load an ES6 Module, but today it can load an ES6 module using the import() function.

What is CommonJS vs ES modules?

ES modules are the standard for JavaScript, while CommonJS is the default in Node. js. The ES module format was created to standardize the JavaScript module system. It has become the standard format for encapsulating JavaScript code for reuse.

What does module CommonJS mean?

CommonJS modules are the original way to package JavaScript code for Node. js. Node. js also supports the ECMAScript modules standard used by browsers and other JavaScript runtimes.


2 Answers

This is a new feature added in Visual Studio Code called "Suggestion Code Actions". "Suggestion Code Actions" are enabled by default in JavaScript and TypeScript.

You can disable them by setting: "typescript.suggestionActions.enabled": false or "javascript.suggestionActions.enabled": false in your user/workspace settings. The documentation can be found here.

(Image provided by Yusuf Yaşar.)

like image 52
HSir Avatar answered Sep 19 '22 21:09

HSir


For anyone using Vim with coc.nvim, you can make the same change by adding the same in the :CocConfig object:

"javascript.suggestionActions.enabled": false 

If you haven't added any settings to :CocConfig before, then you need to make sure the above setting is wrapped in a JSON object:

{     "javascript.suggestionActions.enabled": false } 
like image 42
icc97 Avatar answered Sep 21 '22 21:09

icc97