Browse Source

使用 husky 强制代码提交前必须通过测试

modood 8 years ago
parent
commit
cc78047f36
2 changed files with 18 additions and 10 deletions
  1. 9 9
      .eslintrc.js
  2. 9 1
      package.json

+ 9 - 9
.eslintrc.js

@@ -2,14 +2,14 @@ module.exports = {
   root: true,
   extends: 'standard',
   globals: {
-    'describe': true,
-    'it': true,
-    'before': true,
-    'beforeEach': true,
-    'after': true,
-    'afterEach': true,
-    'context': true,
-    'expect': true
+    // mocha BDD
+    describe: true,
+    context: true,
+    it: true,
+    specify: true,
+    before: true,
+    beforeEach: true,
+    after: true,
+    afterEach: true
   }
 }
-

+ 9 - 1
package.json

@@ -4,7 +4,8 @@
   "description": "中华人民共和国行政区划:省份、城市、区县、乡镇(街道)",
   "main": "index.js",
   "scripts": {
-    "test": "mocha -t 5000"
+    "test": "eslint . && mocha -t 5000",
+    "precommit": "npm test"
   },
   "repository": {
     "type": "git",
@@ -33,6 +34,13 @@
     "iconv-lite": "^0.4.15"
   },
   "devDependencies": {
+    "eslint": "^3.19.0",
+    "eslint-config-standard": "^10.2.1",
+    "eslint-plugin-import": "^2.3.0",
+    "eslint-plugin-node": "^4.2.2",
+    "eslint-plugin-promise": "^3.5.0",
+    "eslint-plugin-standard": "^3.0.1",
+    "husky": "^0.13.4",
     "mocha": "^3.1.0"
   },
   "license": "MIT",