class-fields

Eslint does not allow static class properties

天大地大妈咪最大 提交于 2021-02-04 17:08:08
问题 I'm current developing an API on Node 12.14.1 and using Eslint to help me write the code. Unfortunately it does not allow me to set static class properties as shown below: class AuthManager { static PROP = 'value' } The following error is given: Parsing error: Unexpected token =eslint Static class properties are already supported on JS and on Node. How can this rule be disable? I also have the following .eslintrc.json file: { "env": { "es6": true, "node": true }, "extends": "eslint

Eslint does not allow static class properties

柔情痞子 提交于 2021-02-04 17:07:37
问题 I'm current developing an API on Node 12.14.1 and using Eslint to help me write the code. Unfortunately it does not allow me to set static class properties as shown below: class AuthManager { static PROP = 'value' } The following error is given: Parsing error: Unexpected token =eslint Static class properties are already supported on JS and on Node. How can this rule be disable? I also have the following .eslintrc.json file: { "env": { "es6": true, "node": true }, "extends": "eslint

Eslint does not allow static class properties

一世执手 提交于 2021-02-04 17:05:30
问题 I'm current developing an API on Node 12.14.1 and using Eslint to help me write the code. Unfortunately it does not allow me to set static class properties as shown below: class AuthManager { static PROP = 'value' } The following error is given: Parsing error: Unexpected token =eslint Static class properties are already supported on JS and on Node. How can this rule be disable? I also have the following .eslintrc.json file: { "env": { "es6": true, "node": true }, "extends": "eslint

What's difference between two ways of defining method on React Class in ES6

两盒软妹~` 提交于 2020-12-31 05:20:30
问题 I see this a lot in ES6 React code class Foo extends React.Component { bar = () => { console.log("bar") } baz() { console.log("baz") } } Seems like they both define methods bar and baz on Foo but how are they different. 回答1: The declarations differ in how the function are written and the context of this , In the first syntax bar = () => { console.log("bar") } the function is written using Arrow function syntax. An arrow function does not have its own this ; the this value of the enclosing