Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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