当使用“#”在 javascript 类中声明私有成员时,eslint 会抛出错误Parsing error: Unexpected character '#'。
例如。
class Test{
#priavteMember; //Parsing error: Unexpected character '#'
}
Run Code Online (Sandbox Code Playgroud)
eslint配置:.eslintrc.json
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"airbnb-base"
],
"rules": {
"no-use-before-define": "off",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-nested-ternary": "off",
"lines-between-class-members": "off"
},
"globals": {
"root": "readonly",
"app": "readonly",
"db": "readonly"
}
}
Run Code Online (Sandbox Code Playgroud)