Skip to content

Commit

Permalink
Pre-commit hooks, removed pretest from npm test (#454)
Browse files Browse the repository at this point in the history
Co-authored-by: rthenhaus <rthenhaus>
  • Loading branch information
rc10house authored May 15, 2024
1 parent dd3d212 commit 39c0b61
Show file tree
Hide file tree
Showing 35 changed files with 2,366 additions and 1,652 deletions.
10 changes: 6 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"modules" : true
}
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"env" : {
"browser" : true,
"es6" : true
},
"extends" : "eslint:recommended",
"rules" : {
"no-cond-assign" : 0,
"no-constant-condition" : 0
}
"no-cond-assign" : "warn",
"no-constant-condition" : "warn",
"@typescript-eslint/no-unused-vars": "warn",
},
}
49 changes: 49 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
bash << EOF
sound() {
echo '\a'
}

echo "Running pre-commit hooks..."

# Check Prettier standards
npm run format ||
(
sound
echo "❌ Prettier Check Failed. Run npm run format, add changes and try commit again.";
exit 1;
)

# Check ESLint Standards
npm run lint ||
(
sound
echo "❌ ESLint Check Failed. Make the required changes listed above, add changes and try to commit again."
exit 1;
)

# TODO: add typescript checks

# If everything passes... Now we can commit
echo "✅ Checks passed, trying to build..."

"npm" run build ||
(
sound
echo "❌ Build failed, check errors."
exit 1;
)

echo "✅ Successful build, running tests..."
# After build, run unit tests
# Right now, runs all tests. Later scope to just unit tets, we can add e2e/integration as github actions on merge
npm run test ||
(
sound
echo "❌ Tests failed: View the logs to see what broke and fix it before re-committing."
exit 1;
)

# If everything passes... Now we can commit
echo '✅ All tests passed'

EOF
10 changes: 10 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
Loading

0 comments on commit 39c0b61

Please sign in to comment.