Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit 79daa2e

Browse files
committed
chore(prettier): setup eslint --fix and prettier to run on precommit
1 parent eb1890b commit 79daa2e

File tree

3 files changed

+356
-21
lines changed

3 files changed

+356
-21
lines changed

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
"babelify": "^7.3.0",
1111
"browserify": "^14.0.0",
1212
"eslint": "^3.18.0",
13+
"husky": "^0.13.2",
14+
"lint-staged": "^3.4.0",
1315
"mocha": "^3.0.1",
1416
"nyc": "^10.0.0",
17+
"prettier": "^0.22.0",
1518
"semantic-release": "^6.3.2"
1619
},
1720
"babel": {
@@ -24,9 +27,10 @@
2427
"test": "npm run lint && npm run test-only",
2528
"test-only": "nyc --require babel-register mocha -u exports",
2629
"build": "browserify -t [ babelify --presets [ es2015 ] ] src/ErrorSubclass.js --standalone ErrorSubclass > umd.js",
27-
"lint": "eslint src test",
30+
"lint": "eslint src",
2831
"prepublish": "npm run build",
29-
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
32+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
33+
"precommit": "lint-staged"
3034
},
3135
"author": "Stephen Sorensen <shuoink@gmail.com> (http://www.stephenjohnsorensen.com/)",
3236
"license": "MIT",
@@ -39,5 +43,12 @@
3943
],
4044
"eslintConfig": {
4145
"extends": "@spudly"
46+
},
47+
"lint-staged": {
48+
"*.js": [
49+
"eslint --fix",
50+
"prettier --write --print-width=100 --single-quote --bracket-spacing=false 'src/**/*.js'",
51+
"git add"
52+
]
4253
}
4354
}

test/ErrorSubclassTest.js renamed to src/ErrorSubclass.test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ class SubSubError extends ErrorSubclass {
1010
const {captureStackTrace} = Error;
1111

1212
const tests = {
13-
1413
ErrorSubclass: {
15-
1614
'Subclass of ErrorSubclass': {
17-
1815
'can be instantiated': () => {
1916
doesNotThrow(() => new SubSubError(ERROR_MESSAGE));
2017
},
2118

2219
'SubSubclass instance': {
23-
2420
afterEach() {
2521
Error.captureStackTrace = captureStackTrace;
2622
},
@@ -53,14 +49,14 @@ const tests = {
5349
ok(instance.stack);
5450
equal(typeof instance.stack, 'string');
5551
ok(instance.stack.match(`SubSubErrorDisplayName: ${ERROR_MESSAGE}`));
56-
},
52+
}
5753

5854
// 'when captureStackTrace is not supported, should have a stack': () => {
5955
// // TODO: how to test?
6056
// },
61-
},
62-
},
63-
},
57+
}
58+
}
59+
}
6460
};
6561

6662
export default tests;

0 commit comments

Comments
 (0)