【发布时间】:2020-06-25 06:40:20
【问题描述】:
我正在尝试使用 eslint 的 padded-blocks 和 lines-around-comment 评论规则。
这是我的 eslint 配置文件。
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"es6": true,
"node": true,
"browser": false,
"jest": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"modules": false
}
},
"rules": {
"padded-blocks": [WARN, "never"],
"lines-around-comment": [WARN, { "beforeBlockComment": true}],
}
};
如果我这样写
class MyClass {
/**
* Creates an instance of MyClass.
* @param {Object} arg1 dependency object
* @memberof MyClass
*/
constructor(arg1) {
this.var1 = arg1;
}
/**
* My function
*
* @memberof MyClass
*/
myFunction() {
}
}
module.exports = MyClass;
1:15 warning Block must not be padded by blank lines padded-blocks
如果我这样写
class MyClass {
/**
* Creates an instance of MyClass.
* @param {Object} arg1 dependency object
* @memberof MyClass
*/
constructor(arg1) {
this.var1 = arg1;
}
/**
* My function
*
* @memberof MyClass
*/
myFunction() {
}
}
module.exports = MyClass;
我收到这个错误
2:2 warning Expected line before comment lines-around-comment
似乎这些规则在课程开始时彼此相反。
我如何忽略 padded-blocks 构造函数命名的规则?
【问题讨论】: