Skip to Content
React学习手册
book

React学习手册

by Alex Banks, Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from React学习手册
226
10
命令
eslint .
将会检查我们的整个目录。为此,用户很有可能需要
ESLint
忽略某些
JavaScript
文件。
.eslintignore
文件是用户可以添加需要
ESLint
忽略的文件或者目录名
称的地方:
dist/assets/
sample.js
.eslintignore
文件会告知
ESLint
忽略对新的
sample.js
文件的检查。这就和
dist/assets
文件
夹下的其他任意文件一样。
ESLint
将会分析客户端
bundle.js
文件,并且会在该文件中
报告大量警告信息。
让我们在
package.json
中添加一个脚本,以便可以运行代码检查命令:
"scripts": {
"lint": "./node_modules/.bin/eslint ."
}
现在随时都可以使用
npm run lint
命令调用
ESLint
进行代码格式检查工作了,它会分
析除了已经忽略的文件之外的所有项目文件。
测试
Redux
测试对于
Redux
至关重要,因为它只和数据打交道,它并不包含
UI
Redux
天生就是
可测试的,因为它的
Reducer
是纯函数,并且它可以方便地将
State
注入
Store
。编写一
Reducer
的测试,首先使得用户更容易理解该
Reducer
的工作机制。为
Store
Action
生成器编写测试代码,可以提高用户对客户端数据层能够按照预期运行的信心。
在本节中,我们将会为颜色管理器的
Redux
组件编写一些单元测试。
测试驱动开发
测试驱动开发(
Test-Driven Development ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React快速上手开发

React快速上手开发

Stoyan Stefanov
流畅的Python

流畅的Python

Luciano Ramalho
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787519814236