对此有什么拖延规则?
错误代码:
const {bar} = foo;
function Foo(props) {
const {bar} = props;
}
好代码:
const bar = foo.bar;
function Foo({bar}){
}
答案 0 :(得分:0)
到目前为止,我得到了这两个规则,以防止从对象声明变量,并防止没有对象的函数的有效载荷:
'no-restricted-syntax': [
'warn',
{
'selector': 'VariableDeclarator > ObjectPattern',
'message': 'Can not declare variable by exploding the object.',
},
{
'selector': 'FunctionDeclaration[params] > Identifier.params',
'message': 'Function\'s payload must be sent with object.',
},
],
虽然我仍在测试这些行为,但我将其设置为“警告”级别
no-restricted-syntax
规则要求CSS之类的选择器在AST树中进行选择,