Skip to content

Commit 834739e

Browse files
committed
文档部分调整
1 parent e139c75 commit 834739e

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

.eslintrc.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
// JS 书写规范
33
// http://eslint.org
44
// http://standardjs.com/rules.html
5-
//
5+
// 具体规范参见文档[javascript-style-guide](https://github.com/webcoding/javascript-style-guide/blob/master/docs)
6+
67
// 配置参看 [config-eslint.md](https://github.com/webcoding/javascript-style-guide/blob/master/docs/config-eslint.md)
78

8-
// NOTE: 在新项目中使用 error 级别,在老项目中使用 warning 级别
9+
// NOTE: 兼容性设定,放置在项目根目录,同时支持 ES5、ES6 便于切换
910

1011
module.exports = {
1112
root: true,
1213
parser: 'babel-eslint',
1314
installedESLint: true,
1415
parserOptions: {
15-
ecmaVersion: 6,
16+
// ecmaVersion: 6,
1617
sourceType: 'module',
1718
},
1819
globals: {
@@ -23,20 +24,19 @@ module.exports = {
2324
// 处理 html 文件内 js 代码规范等
2425
'html',
2526
],
26-
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
27-
// https://github.com/feross/eslint-config-standard/blob/master/eslintrc.json
28-
// extends: 'standard',
27+
// ES5 推荐规范
28+
// extends: 'webcoding/configurations/airbnb/es5',
2929
// ES6 推荐规范
3030
extends: 'airbnb',
31-
// extends: 'defaults/configurations/airbnb/es6',
31+
// extends: 'webcoding/configurations/airbnb/es6',
3232

3333
// add your custom rules here
3434
rules: {
3535
// 行尾分号,默认配置always,要求在行末加上分号,standard 配置强制不带
36-
semi: ['error', "never"],
36+
semi: ['error', 'never'],
3737
// 多行模式必须带逗号,单行模式不能带逗号
3838
'comma-dangle': ['error', 'always-multiline'],
39-
// "max-len": ['error', 120],
39+
// 'max-len': ['error', 120],
4040
// 禁止使用 console debugger
4141
// 'no-console': 1,
4242
// 'no-debugger': 1,

docs/config-eslint.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,29 @@
55

66
> 为什么选用 `.eslintrc.js` 后缀名?因为 `.json` 没法加注释,格式要求比较严格,而 `.eslintrc` 格式在 vscode 中默认做 json 处理了,其中的注释 # 就显示为了异常,所以统一使用 js 格式,通用了
77
8+
NOTE: 可扩展需求
9+
10+
- eslint-plugin-html html 内 js 规范
11+
- eslint-plugin-react react 规范
12+
- eslint-plugin-jsx-a11y JSX 代码段内应用 AST 检查器
13+
- eslint-plugin-promise 回调函数使用最佳实践
14+
- eslint-plugin-vue 支持 vue 文件
15+
816
## 项目配置,安装 ESLint 依赖
917

1018
可以安装到全局,全部共用
1119

1220
```
1321
// ES6 推荐使用 airbnb
1422
npm install -g eslint eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-airbnb
23+
// 之后设置
24+
extend: 'airbnb',
25+
1526
16-
// 如果使用 standardjs(仅仅涉及 ES5)
17-
npm install -g eslint-config-standard eslint-plugin-standard eslint-plugin-promise
27+
// ES5 推荐使用 airbnb/es5()
28+
npm install -g eslint eslint-config-webcoding
29+
// 之后设置
30+
extend: 'webcoding/configurations/airbnb/es5',
1831
```
1932

2033

docs/es5.eslintrc.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,42 @@
22
// JS 书写规范
33
// http://eslint.org
44
// http://standardjs.com/rules.html
5-
//
6-
// @dependencies 安装到全局,就不用每个项目单独安装了
7-
// standard: npm install -g eslint-config-standard eslint-plugin-standard eslint-plugin-promise
8-
// airbnb: npm install -g eslint eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-airbnb
5+
// 具体规范参见文档[javascript-style-guide](https://github.com/webcoding/javascript-style-guide/blob/master/docs)
96

10-
// NOTE: 在新项目中使用 error 级别,在老项目中使用 warning 级别
7+
// 配置参看 [config-eslint.md](https://github.com/webcoding/javascript-style-guide/blob/master/docs/config-eslint.md)
8+
9+
// NOTE: 兼容性设定,放置在项目根目录,同时支持 ES5、ES6 便于切换
1110

1211
module.exports = {
1312
root: true,
1413
parser: 'babel-eslint',
14+
installedESLint: true,
1515
parserOptions: {
16-
ecmaVersion: 6,
16+
// ecmaVersion: 6,
1717
sourceType: 'module',
1818
},
1919
globals: {
2020
Vue: false,
2121
},
2222

2323
plugins: [
24+
// 处理 html 文件内 js 代码规范等
2425
'html',
2526
],
26-
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
27-
// https://github.com/feross/eslint-config-standard/blob/master/eslintrc.json
2827
// extends: 'standard',
2928
// ES5 推荐规范
29+
extends: 'webcoding/configurations/airbnb/es5',
30+
// ES6 推荐规范
3031
// extends: 'airbnb',
31-
extends: 'defaults/configurations/airbnb/es5',
32+
// extends: 'webcoding/configurations/airbnb/es6',
3233

3334
// add your custom rules here
3435
rules: {
3536
// 行尾分号,默认配置always,要求在行末加上分号,standard 配置强制不带
3637
semi: ['error', 'never'],
3738
// 多行模式必须带逗号,单行模式不能带逗号
3839
'comma-dangle': ['error', 'always-multiline'],
40+
// 'max-len': ['error', 120],
3941
// 禁止使用 console debugger
4042
// 'no-console': 1,
4143
// 'no-debugger': 1,

docs/es6_zh-cn_v3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,10 +1477,10 @@ Other Style Guides
14771477

14781478

14791479
<a name="iterators-and-generators"></a>
1480-
## Iterators and Generators 迭代器 & 生成器
1480+
## Iterators and Generators
14811481

14821482
<a name="iterators--nope"></a><a name="11.1"></a>
1483-
- [11.1](#iterators--nope) 不要使用 iterators。使用高阶函数例如 `map()``reduce()` 替代 `for-in` or `for-of`
1483+
- [11.1](#iterators--nope) 不要使用迭代器 iterators。使用高阶函数例如 `map()``reduce()` 替代 `for-in` or `for-of`
14841484
eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax)
14851485

14861486
> 为什么? 这加强了我们不变的规则。处理纯函数的回调值更易读,这比它带来的副作用更重要。
@@ -1520,7 +1520,7 @@ Other Style Guides
15201520
```
15211521

15221522
<a name="generators--nope"></a><a name="11.2"></a>
1523-
- [11.2](#generators--nope) 现在还不要使用生成器 generators。
1523+
- [11.2](#generators--nope) 现在还不要使用 generators。
15241524

15251525
> 为什么? 因为它们现在还没法很好地编译到 ES5。 (译者注:目前(2016/03) Chrome 和 Node.js 的稳定版本都已支持 generators)
15261526

docs/js-in-html.html

Whitespace-only changes.

0 commit comments

Comments
 (0)