How to disable some ES2015 features using ESLint 2?

In ESLint 1, I can use the ecmaFeatures parameter to disable or enable certain language features. For instance.

 ecmaFeatures: defaultParams: false 

Above the configuration, defaultParams disabled.

This is very useful because at run time, such as Node, not all functions are available, and I do not want to use the transpiler.

But in ESLint 2 this has been removed. You only got ecmaVersion , which doesn’t warn you about using ES2015 functions at all, even if you give it ecmaVersion of 5. I assume that makes sense, because the JavaScript interpreter will complain about using unsupported syntax when interpreting time, but what about development for browsers different levels of support for ES2015? The syntax that works for Chrome will not work for IE9.

Is there a way to use language features, for example. disable destructuring?

+5
source share
1 answer

The no-restricted-syntax rule prohibits specific syntax. This "syntax" refers to AST node types. AST specification is here: https://github.com/estree/estree

The eslint-plugin-node no-unsupported-features rule disables unsupported ECMA functions by a specific version of Node. I do not know if a similar rule exists for browsers.

+4
source

Source: https://habr.com/ru/post/1246505/


All Articles