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

Commit e8dbaf9

Browse files
hmaurerevykassirer
authored andcommitted
add pre-commit hook to run tests & linter (#78)
1 parent 0bcfbfc commit e8dbaf9

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

Diff for: CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Please report unacceptable behavior to [email protected]
8686

8787
- Make sure you properly unit test your changes.
8888
- Run tests with `npm test`
89+
- Install Git hooks with `npm run setup-hooks`. This will add a pre-commit hook which makes sure tests are passing and the code is eslint-compliant.
8990
- If you want to see what the expression tree looks like at any point
9091
in the code, for debugging, you can log `node` as an expression string
9192
(e.g. '2x + 5') with `console.log(print(node))`, and you can log the full

Diff for: lib/simplifyExpression/stepThrough.js

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ function step(node) {
109109
// Removes unnecessary parens throughout the steps.
110110
// TODO: Ideally this would happen in NodeStatus instead.
111111
function removeUnnecessaryParensInStep(nodeStatus) {
112-
let substeps = [];
113112
if (nodeStatus.substeps.length > 0) {
114113
nodeStatus.substeps.map(removeUnnecessaryParensInStep);
115114
}

Diff for: lib/solveEquation/stepThrough.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function logSteps(equationStatus) {
260260
if (equationStatus.substeps.length > 0) {
261261
// eslint-disable-next-line
262262
console.log('\n substeps: ');
263-
equationStatus.substeps.forEach(substep => logSteps);
263+
equationStatus.substeps.forEach(logSteps);
264264
}
265265
}
266266

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
},
1414
"scripts": {
1515
"lint": "node_modules/.bin/eslint .",
16-
"test": "node_modules/.bin/mocha --recursive"
16+
"test": "node_modules/.bin/mocha --recursive",
17+
"setup-hooks": "ln -s ../../scripts/git-hooks/pre-commit.sh .git/hooks/pre-commit"
1718
},
1819
"repository": {
1920
"type": "git",

Diff for: scripts/git-hooks/pre-commit.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
npm test &&
4+
npm run lint

0 commit comments

Comments
 (0)