Skip to content

Commit 476e5f1

Browse files
committed
merge upstream
2 parents 1e53434 + e8c449f commit 476e5f1

File tree

17 files changed

+92
-15
lines changed

17 files changed

+92
-15
lines changed
File renamed without changes.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ fork 不支持 issue,有问题请直接到[主分支的 issue 列表](https://
88

99
目前的章节已经翻译完成,[**欢迎提交 PULL REQUEST**](https://github.com/pd4d10/js-stack-from-scratch/pulls)
1010

11-
<br/>
12-
13-
[![Build Status](https://travis-ci.org/verekia/js-stack-from-scratch.svg?branch=master)](https://travis-ci.org/verekia/js-stack-from-scratch) [![Join the chat at https://gitter.im/js-stack-from-scratch/Lobby](https://badges.gitter.im/js-stack-from-scratch/Lobby.svg)](https://gitter.im/js-stack-from-scratch/Lobby)
11+
[![Build Status](https://travis-ci.org/pd4d10/js-stack-from-scratch.svg?branch=master)](https://travis-ci.org/pd4d10/js-stack-from-scratch) [![Join the chat at https://gitter.im/js-stack-from-scratch/Lobby](https://badges.gitter.im/js-stack-from-scratch/Lobby.svg)](https://gitter.im/js-stack-from-scratch/Lobby)
1412

1513
[![Yarn](/img/yarn.png)](https://yarnpkg.com/)
1614
[![React](/img/react.png)](https://facebook.github.io/react/)
@@ -74,6 +72,7 @@ fork 不支持 issue,有问题请直接到[主分支的 issue 列表](https://
7472

7573
- [中文](https://github.com/pd4d10/js-stack-from-scratch) by [@pd4d10](http://github.com/pd4d10)
7674
- [Italiano](https://github.com/fbertone/js-stack-from-scratch) by [Fabrizio Bertone](https://github.com/fbertone)
75+
- [日本語](https://github.com/takahashim/js-stack-from-scratch) by [@takahashim](https://github.com/takahashim)
7776

7877
## Credits
7978

how-to-translate.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Since I want to reward you for your good work as much as possible, you can put a
3434

3535
- After your original one-shot translation, if you want to update your repo with the latest change from the main English repo, [sync your fork](https://help.github.com/articles/syncing-a-fork/) with my repo. To make it easy to see what changed since your initial translation, you can use Github's feature to [compare commits](https://help.github.com/articles/comparing-commits-across-time/#comparing-commits). Set the **base** to the last commit from the English repo you used to translate, and compare it to **master**, like so:
3636

37+
<!-- markdownlint-disable MD034 -->
3738
https://github.com/verekia/js-stack-from-scratch/compare/dfab78b581a3da800daeb3686b900dd9ea972da0...master
39+
<!-- markdownlint-enable MD034 -->
3840

3941
That should give you a easy-to-read diff to see exactly what changed in `README.md` files since your translation!

mdlint.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const glob = require('glob');
2+
const markdownlint = require('markdownlint');
3+
4+
const config = {
5+
'default': true,
6+
'line_length': false,
7+
'no-emphasis-as-header': false
8+
}
9+
10+
const files = glob.sync('**/*.md', { ignore: '**/node_modules/**' });
11+
12+
markdownlint({ files, config }, (err, result) => {
13+
if (!err) {
14+
const resultString = result.toString();
15+
console.log('== Linting Markdown Files...');
16+
if (resultString) {
17+
console.log(resultString);
18+
process.exit(1);
19+
} else {
20+
console.log('== OK!');
21+
}
22+
}
23+
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
"version": "1.0.0",
44
"description": "JavaScript Stack from Scratch - Step-by-step tutorial to build a modern JavaScript stack",
55
"scripts": {
6-
"test": "cd tutorial/1-node-npm-yarn-package-json && yarn && yarn run tutorial-test && cd ../2-packages && yarn && yarn run tutorial-test && cd ../3-es6-babel-gulp && yarn && yarn run tutorial-test && cd ../4-es6-syntax-class && yarn && yarn run tutorial-test && cd ../5-es6-modules-syntax && yarn && yarn run tutorial-test && cd ../6-eslint && yarn && yarn run tutorial-test && cd ../7-client-webpack && yarn && yarn run tutorial-test && cd ../8-react && yarn && yarn run tutorial-test && cd ../9-redux && yarn && yarn run tutorial-test && cd ../10-immutable-redux-improvements && yarn && yarn run tutorial-test && cd ../11-testing-mocha-chai-sinon && yarn && yarn run tutorial-test && cd ../12-flow && yarn && yarn run tutorial-test"
6+
"test": "yarn run mdlint && cd tutorial/1-node-npm-yarn-package-json && yarn && yarn run tutorial-test && cd ../2-packages && yarn && yarn run tutorial-test && cd ../3-es6-babel-gulp && yarn && yarn run tutorial-test && cd ../4-es6-syntax-class && yarn && yarn run tutorial-test && cd ../5-es6-modules-syntax && yarn && yarn run tutorial-test && cd ../6-eslint && yarn && yarn run tutorial-test && cd ../7-client-webpack && yarn && yarn run tutorial-test && cd ../8-react && yarn && yarn run tutorial-test && cd ../9-redux && yarn && yarn run tutorial-test && cd ../10-immutable-redux-improvements && yarn && yarn run tutorial-test && cd ../11-testing-mocha-chai-sinon && yarn && yarn run tutorial-test && cd ../12-flow && yarn && yarn run tutorial-test",
7+
"mdlint": "node mdlint.js"
78
},
89
"devDependencies": {
10+
"glob": "^7.1.1",
11+
"markdownlint": "^0.3.0",
912
"yarn": "^0.16.1"
1013
},
1114
"repository": "verekia/js-stack-from-scratch",

tutorial/1-node-npm-yarn-package-json/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macOS 或 Windows 用户可以直接[下载安装文件](https://nodejs.org/en/d
1212
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
1313
sudo apt-get install -y nodejs
1414
```
15+
1516
你需要大于 6.5.0 的 Node 版本。
1617

1718
`npm` 是 Node 的默认包管理器,不需要手动安装。
@@ -30,7 +31,7 @@ sudo apt-get install -y nodejs
3031

3132
-`package.json` 中增加 `scripts` 字段如下:
3233

33-
```
34+
```json
3435
"scripts": {
3536
"start": "node ."
3637
}
@@ -41,7 +42,7 @@ sudo apt-get install -y nodejs
4142
- 运行 `yarn start`,将打印 `Hello world`
4243
- 新建一个 `.gitignore` 文件,增加以下内容:
4344

44-
```
45+
```gitignore
4546
npm-debug.log
4647
yarn-error.log
4748
```
@@ -51,4 +52,3 @@ yarn-error.log
5152
下一章:[2 - 包的安装与使用](/tutorial/2-packages)
5253

5354
回到[目录](https://github.com/pd4d10/js-stack-from-scratch)
54-

tutorial/10-immutable-redux-improvements/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
const obj = { a: 1 };
1111
obj.a = 2; // Mutates `obj`
1212
```
13+
1314
而是这样做:
15+
1416
```javascript
1517
const obj = Immutable.Map({ a: 1 });
1618
obj.set('a', 2); // Returns a new object without mutating `obj`
@@ -35,6 +37,7 @@ obj.set('a', 2); // Returns a new object without mutating `obj`
3537
]
3638
}
3739
```
40+
3841
这样 `Map``List`(我们使用到的两个 Immutable 对象)就不会被 ESLint 视为错误了。这个 JSON 的实际上是被 Yarn/NPM 自动格式化了,所以我们没办法让它更紧凑。
3942

4043
回到 Immutable 的部分:

tutorial/11-testing-mocha-chai-sinon/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('App State', () => {
4141
});
4242
});
4343
```
44+
4445
好,现在我们一起分析一下都发生了什么。
4546

4647
首先,注意我们是如何从 `chai` 中导入 `should` 断言样式的。这让我们使用 `mynumber.should.equal(3)` 这样的语法去做断言,很酷。为了能够让 `should` 让任何对象调用,需要所有测试之前运行 `should()`。这些断言中,有些是表达式,如 `mybook.should.be.true`,这会让 ESLint 报错,因此我们在顶部添加了一个 ESLint 注释,用于禁用 `no-unused-expressions` 这个规则。

tutorial/12-flow/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ import * as Immutable from 'immutable';
9595

9696
**注意**:如果 Flow 在 `node_modules` 文件夹中检测到类型错误,请在 `.flowconfig` 中添加一个`[ignore]` 来忽略特定的包(不要忽略整个 `node_modules` 目录)。看起来像这样
9797

98-
```
98+
```flowconfig
9999
[ignore]
100100
101101
.*/node_modules/gulp-flowtype/.*
102102
```
103+
103104
在我这的情况是,Atom 编辑器的 `linter-flow` 插件会检测 `node_modules/gulp-flowtype` 目录中的类型错误,针对那些用 `// @flow` 注释过的文件。
104105

105106
现在,你的代码已经通过了代码检查,类型检查和测试的考验了,好样的!

tutorial/3-es6-babel-gulp/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ Gulp 本身的 API 很简单。使用 `gulp.task` 定义一系列的任务,使
8686
- 运行 `yarn start`,将会打印 "Hello ES6" 并开始监听文件的更改。你可以试试在 `src/index.js` 中写一些有语法错误的代码,看下 Gulp 是不是报错了。
8787
- 添加 `/lib/``.gitignore` 文件中
8888

89-
9089
下一章:[4 - 使用 ES6 中的 class](/tutorial/4-es6-syntax-class)
9190

9291
回到[上一章](/tutorial/2-packages)[目录](https://github.com/pd4d10/js-stack-from-scratch).

0 commit comments

Comments
 (0)