eslint 规则/fasle 检查:如果比较条件
eslint rules / fasle check: if compare condition
我正在寻找的规则将
显示错误
if(!package)
因为最好有
if(typeof(package) !== 'undefine')
在 eslint page 聊天,@ljharb 帮我整理好了,
No, we don't.
Jordan Harband @ljharb
it might be a bug, but it's impossible to know that statically that's
something unit tests, not linting, has to catch. if you mean == vs
===, it's because == is likely to be a bug a falsiness check is not, that's a completely valid pattern that appears all over the place, and
is correct.
Kevin Partington @platinumazure
@seeliang If you really want more specific checks, you could certainly
find or write a plugin with a rule that forbids general falsy checks.
But I don't think that will ever be added to core because it's not
obviously an error in most cases.
我正在寻找的规则将 显示错误
if(!package)
因为最好有
if(typeof(package) !== 'undefine')
在 eslint page 聊天,@ljharb 帮我整理好了,
No, we don't.
Jordan Harband @ljharb
it might be a bug, but it's impossible to know that statically that's something unit tests, not linting, has to catch. if you mean == vs ===, it's because == is likely to be a bug a falsiness check is not, that's a completely valid pattern that appears all over the place, and is correct.
Kevin Partington @platinumazure
@seeliang If you really want more specific checks, you could certainly find or write a plugin with a rule that forbids general falsy checks. But I don't think that will ever be added to core because it's not obviously an error in most cases.