非常教程

Standard JS 参考手册

规则 | Rules

分号 | Semicolons

Semicolons

  • No semicolons. (see: 1, 2, 3) eslint: semi window.alert('hi')   // ✓ okwindow.alert('hi');  // ✗ avoid
  • Never start a line with (, [, `, or a handful of other unlikely possibilities. This is the only gotcha with omitting semicolons, and standard protects you from this potential issue. (The full list is: [, (, `, +, *, /, -, ,, ., but most of these will never appear at the start of a line in real code.) eslint: no-unexpected-multiline // ✓ ok;(function () {  window.alert('ok')}()) // ✗ avoid(function () {  window.alert('ok')}()) // ✓ ok;[1, 2, 3].forEach(bar) // ✗ avoid[1, 2, 3].forEach(bar) // ✓ ok;`hello`.indexOf('o') // ✗ avoid`hello`.indexOf('o') Note: If you're often writing code like this, you may be trying to be too clever. Clever short-hands are discouraged, in favor of clear and readable expressions, whenever possible. Instead of this: ;[1, 2, 3].forEach(bar) This is strongly preferred: var nums = [1, 2, 3]nums.forEach(bar)

规则 | Rules相关

Standard JS

JavaScript 代码规范,自带 linter & 代码自动修正,可以帮助你(及你的团队)节省大量时间

Standard JS 目录

1.快速开始 | quick start
2.常见问题 | FAQ
3.规则 | Rules
4.系统 | Ecosystem