Skip to content

chore: set eslint rule 'semi' to 'always'#1007

Open
Menci wants to merge 1 commit intoOI-wiki:masterfrom
Menci:master
Open

chore: set eslint rule 'semi' to 'always'#1007
Menci wants to merge 1 commit intoOI-wiki:masterfrom
Menci:master

Conversation

@Menci
Copy link
Member

@Menci Menci commented Dec 24, 2021

即使 JavaScript 有 ASI(Automatic Semicolon Insertion)的特性,可以在大部分情况下自动在行尾加入分号的语义,但仍然推荐在编写 JavaScript 代码时手动加入分号。

举一个依赖 ASI 时会遇到问题的场景:

// wrong:
const a = foo()
[a, b, c].map(x => {})
// interpreted as: `const a = foo()[a, b, c].map(x => {})`

// possible fix:
const a = foo()
;[a, b, c].map(x => {})

// recommended
const a = foo();
[a, b, c].map(x => {});

所以应当通过 ESLint 来规范对于分号的使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants