Skip to content

Commit

Permalink
Add lint-staged, husky for formatting during commits (#324)
Browse files Browse the repository at this point in the history
* Add lint-staged, husky

* Add .lingstagedrc

* Remove unnecessary .lintstagedrc
  • Loading branch information
skanderm authored Jan 31, 2024
1 parent f16dc20 commit ef38743
Show file tree
Hide file tree
Showing 4 changed files with 497 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ui/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd ui/
npx lint-staged
14 changes: 14 additions & 0 deletions ui/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// from https://nextjs.org/docs/pages/building-your-application/configuring/eslint#lint-staged
const path = require("path");

const buildEslintCommand = (filenames) =>
`next lint --fix --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(" --file ")}`;

const prettierCommand = "prettier --ignore-unknown --write";

module.exports = {
"*.{js,jsx,ts,tsx}": [buildEslintCommand, prettierCommand],
"!*.{js,jsx,ts,tsx}": prettierCommand,
};
Loading

0 comments on commit ef38743

Please sign in to comment.