How to configure eslint for particular ECMA features? - eslint

The project targets specific version of Node.js. This is the runtime of the code.
There is no transpilation step. JavaScript code is deployed as it is.
Particular Node version can support particular ECMA version partly. I want to use those features that are supported.
Eslint allows for specifying compatibility as ECMA version only, as far as I know.
How can I tell Eslint that a particular ECMA feature is supported?
For example: https://kangax.github.io/compat-table/es2016plus/#node16_9. Node v16.9 supports ES2022 only partly, so I cannot set ecmaVersion to 2022. But I want to use instance class fields, for example, which is supported by Node v16.9.
I know about https://github.com/mysticatea/eslint-plugin-node and its fork https://github.com/eslint-community/eslint-plugin-n, which are supposed to somehow configure Eslint based on the package.engines.node value. But my question is about the core Eslint - is there a way of configuring particular ECMA features that are supported by the runtime?

Related

What locales are supported in the Intl API in Node.js by default?

The Node docs say you have to build your own node binary configured with the flag --with-intl=full-icu if you need to support all languages. (Aside: there's an open feature request to build Node like this by default.)
What locales are included by in Node's standard builds today? I can't find a simple list anywhere.

Is #types/core-js still necessary for TS typings in a Node.js project?

I have several backend-only Node.js projects which use a simple TypeScript config.
Before March 2018, I had this in package.json:
"devDependencies": {
"#types/core-js": "^0.9.46",
"#types/node": "^9.6.2"
}
since ~March 2018, I have been omitting "#types/core-js" and everything seems to compile fine. Do we need "#types/core-js" anymore?
I have several Node-based projects written in TypeScript. I never ever used #types/core-js in my projects. So it is definitely not necessary to use #types/core-js in order to write Node-based code. Having #types/node, on the other hand, is a boon if you're going to use Node's API.
The first thing to do if you run into a compilation issue that appears to be caused by the compiler not knowing about features introduced in ES6 is to set lib to load the proper typings you need. For instance, if you decide to target es5 but want to use methods, classes, functions introduced in ES6, you do need to specify "es6" in your lib setting because by default the target es5 loads the lib es5 too. (According to the documentation, a target of es5 sets lib by default to DOM,ES5,ScriptHost, whereas a target of es6 sets lib by default to DOM,ES6,DOM.Iterable,ScriptHost.)
I've run into some very rare cases where there's something missing in the es6 lib. In such cases, I just write a definition to fix that specific problem. Loading #types/core-js might also fix the issue, but it also contains a lot of other things that are not necessary, and it adds a dependency to the project, which then must be managed, etc. Not worth it.
The focus above was Node projects, but even in web-based projects where I have a dependency on core-js I don't use #types/core-js. As I see it, the presence of core-js in a project should be entirely transparent to the project's application code. I'm writing code made to run on any platform providing an API that conforms to ES6 or later, I'm not writing code made to run with core-js specifically.
You should only need #types/core-js if you're using something that is in that declaration that is not available in your TypeScript declarations for your major version. This is useful if you're expecting to use core JavaScript ES6 features that are in core-js but were not implemented in the version of TS you were using at the time. There's more information available on the TS GitHub related to your question but in all reality if you're just using ES stuff that's there now, no you shouldn't need it anymore.
edit: Before I had stated it as node, but in all possibilities since it's TS it probably didn't know how to compile to the target without the declaration. As of TS 2 and NodeJS 6 you shouldn't really need it anymore.

Having source code for third party javascript libraries available whilst debugging

I would like to know whether it is possible to have third-party javascript libraries' source code available whilst debugging.
FYI, I use npm/nodejs and the angular CLI (which itself relies on Webpack).
Example libraries (together with their source languages) that I would like to have available during debugging are:
Angular 2 (typescript)
RxJS (typescript)
I guess what I want to achieve is related to configuring source maps.
Any comment or guidance welcome.
edit: Can someone please advise how to configure the angular CLI in order to have angular and RxJS typescript sources available whilst debugging?
Yes, to be able to set breakpoints in source files while debugging, you need sourcemaps. But this is not the thing that can be configured in the IDE, you need to set up your build tools accordingly. The only thing that should be configured on the IDE end is the run configuration - you might need to specify Remote URL mappings for your project directories
To complement lena's answer and as of #angular/cli version's 6.1 is it now possible to output source maps for vendor libraries using the following syntax:
ng serve --source-map --vendor-source-map
It also works for the ng build command.
See also: https://blog.ninja-squad.com/2018/07/27/angular-cli-6.1/
It is then possible to debug third-party libraries using an IDE or the browser.

Azure functions experimental templates

I am trying to use Azure functions and I see that there are Sample and Experimental type of templates.
Can I trust experimental templates in production environment?
Basically, experimental templates are for languages and/or features which are still in preview (e.g. features like external files and any language other than C#, F#, or Node).
It's possible that there could be significant breaking changes introduced for these preview languages and features. However, you are able to decide whether or not to upgrade your functions runtime to the newer version, so the old version should still work in production.

How can I enable Groovy plugin features in my eclipse plugin?

I am writing an eclipse plugin which needs to support features from the Groovy eclipse plugin.
The Groovy website talks about Groovy eclipse plugins, and Groovy compiler support within eclipse and maven, but I did not find anything similar to what I need to do here.
If I look at the list of available plugin dependencies, I see a number of them:
How can I enable some discovery mechanism or otherwise, in order to install the Groovy plugin after the installation of my plugin completes?
Which plugin can I add as dependency to achieve this? Or should I have to individually add all of them?
If you want to add single plug-ins you can easily do that in the Manifest-Editor of your plug-in. If you need to add a dependency to a feature, you need to create a feature for your own plug-in and add the additional feature dependency in the feature-Editor.
To find out which groovy plug-ins are required to add the "groovy compiler support", I suppose you must rather look at the groovy features in your installation. Usually complex features like a compiler or the like are grouped within a feature.
Add on:
I think the discovery mechanism is already integrated in p2.
I suppose these plug-ins are part of a feature. Find this feature and add that to your product.
For stability I would recommend to add the specific plug-ins to your product/feature. That way you can be sure, people are using the exact version you proposed in your implmentation.

Resources