2018.6.14 培训学习任务 - 代码风格质量与测试
获取fullstack-training最新代码。
fullstack-training下执行 $ npm install
运行 $ npm run lint
会发现控制台输出你们代码的错误写法。凡是error(红色的)都要改好。黄色的警告也尽量改掉。
以上报错是因为我们启用了eslint 检测。请看根目录下有 .eslintrc,.eslintignore这两个配置文件。更多请看eslint
学习Mocha,中文文档自己找。
自已写几个通方法,然后用 Mocha 写测试用例,并运行测试。
一路的错误
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\06-11lunbo\js\js.js
13:32 warning Expected '===' and instead saw '==' eqeqeq
23:19 warning Missing radix parameter radix
30:25 warning Missing radix parameter radix
30:79 warning Missing radix parameter radix
31:30 warning Missing radix parameter radix
60:15 warning Expected '===' and instead saw '==' eqeqeq
71:15 warning Expected '===' and instead saw '==' eqeqeq
84:26 error Don't make functions within a loop no-loop-func
86:26 warning Expected '===' and instead saw '==' eqeqeq
90:21 warning Missing radix parameter radix
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\06-11lunbo\slider2\js\index_banner.js
76:21 warning Expected '===' and instead saw '==' eqeqeq
85:18 error Infix operators must be spaced space-infix-ops
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\form\js\countdown.js
15:7 warning Unexpected console statement no-console
18:11 warning Unexpected console statement no-console
28:7 warning Unexpected console statement no-console
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\form\js\table.js
29:7 warning Unexpected console statement no-console
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\form\js\userList.js
6:9 warning '_this' is assigned a value but never used no-unused-vars
19:29 warning Identifier 'c_userObj' is not in camel case camelcase
24:11 error Irregular whitespace not allowed no-irregular-whitespace
25:28 warning Identifier 'd_userObj' is not in camel case camelcase
27:32 warning Expected '===' and instead saw '==' eqeqeq
27:72 warning Expected '===' and instead saw '==' eqeqeq
36:33 error 'userList' is already declared in the upper scope no-shadow
44:11 warning '_data' is assigned a value but never used no-unused-vars
45:11 warning 'url' is assigned a value but never used no-unused-vars
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\gulp-study\src\carousel.js
88:21 warning Expected '===' and instead saw '==' eqeqeq
90:7 error Unary operator '--' used no-plusplus
97:7 error Unary operator '++' used no-plusplus
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\js\countdown.js
19:7 warning Unexpected console statement no-console
20:7 warning All 'var' declarations must be at the top of the function scope vars-on-top
20:7 error Unexpected var, use let or const instead no-var
22:11 warning Unexpected console statement no-console
33:7 warning Unexpected console statement no-console
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\js\cut.js
2:22 warning 'require' is defined but never used no-unused-vars
10:11 warning Unexpected console statement no-console
21:7 warning Unexpected console statement no-console
C:\Users\yubhb\github\fullstack-training\dev\chenxiangyan\slider2\js\index_banner.js
76:21 warning Expected '===' and instead saw '==' eqeqeq
78:18 error Infix operators must be spaced space-infix-ops
85:18 error Infix operators must be spaced space-infix-ops
怎么找不到文件,上面一大串
特别关注
npm install正常么
_h
不正常,报的这个错误就是
_h
特别关注
删掉node_modules重新npm install
_h
好的
_h
特别关注
09:47
package.json的内容是啥
特别关注
我先看一下
_h
嗯
Al
特别关注
先装npm install cnpm -g
然后cnpm install
今天 10:04
Al
特别关注
不用npm。npm取国内包好像有问题
特别关注
记住里面的内容,你没权限运行
_h
那就前面加sudo??
Al
特别关注
Mac sudo,Windows管理员身份
我的执行是这样,然后执行npm run lint
里面的error就是要你们改的
每个JS都列有
今天 10:17
Al
特别关注
如 ==要改成===才合规
Al
特别关注
改好执行npm run lint直到没报错为止
先改error再改警告warning
注意优先级
那像我这个第一个样是什么意思?
特别关注
找到那个文件加上那一行
_h
作用百度吗
Al
特别关注
你们进会议室一下
_h
好了
香艳
特别关注
linebreak-style: ["error", "windows"]