[英]How to disallow usage of 'concise methods' using eslint
Check this sample code below 请查看下面的示例代码
var Syntax = {
/* eslint should throw error for this */
concise () {
console.log("Concise syntax (es6). No 'function' keyword.");
},
normal: function () {
console.log("Normal syntax.");
}
};
es6
environment to false
& ecmaParser
option to 5
in .eslintrc config. es6
环境设置为false
和ecmaParser
选项为5
。 Still not throwing any errors There is this eslint plugin: https://www.npmjs.com/package/eslint-plugin-no-inferred-method-name 有这个eslint插件: https ://www.npmjs.com/package/eslint-plugin-no-inferred-method-name
It seems to do what you said. 它似乎做你说的。 It claims to throw an error if you define:
如果您定义:它声称抛出错误:
{
concise () { ... }
}
But will not throw an error if you did: 但如果你这样做,不会抛出错误:
{
normal: function() { ... }
}
To use it first install: 要先使用它安装:
$ npm install -g eslint-plugin-no-inferred-method-name
and add: 并添加:
"plugins": [
"no-inferred-method-name"
],
to your eslint file. 到你的eslint文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.