Skip to content

箭头函数中 return 不带参数时导致 fecs 检查报错 #349

@Sheetaa

Description

@Sheetaa

报错信息:

TypeError: Cannot read property 'type' of null(~/lib/js/rules/arrow-body-style.js).	(syntax)

TypeError: Cannot read property 'type' of null
     at validate (/Users/xxx/xxx/fecs/lib/js/rules/arrow-body-style.js:77:54)

引发出错的代码片段:

err => {
    return;
}

分析:

if (asNeeded && firstNode && firstNode.type === 'ReturnStatement') {
     if (!needMaps[firstNode.argument.type]) {
          report(node);
     }
}

firstNode.argument 为 null 导致,应该需要提前判断一下吧

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions