Skip to content

Commit

Permalink
[FR][CPF-91] Setup commit-lint & lint-staged (#92)
Browse files Browse the repository at this point in the history
* add commit lint

* feat: add commit lint config

* feat: add commit lint config
  • Loading branch information
r1skz3ro authored Jul 8, 2024
1 parent 1a3f4d6 commit d2e6b8f
Show file tree
Hide file tree
Showing 6 changed files with 847 additions and 42 deletions.
2 changes: 2 additions & 0 deletions frontend/.husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd frontend
yarn commitlint --edit $1
4 changes: 1 addition & 3 deletions frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

cd frontend

yarn lint:fix
yarn format
yarn compile
yarn lint-staged
21 changes: 21 additions & 0 deletions frontend/.lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ESLint } from 'eslint';

const removeIgnoredFiles = async (files) => {
const eslint = new ESLint();
const isIgnored = await Promise.all(
files.map((file) => {
return eslint.isPathIgnored(file);
}),
);
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
return filteredFiles.join(' ');
};

export default {
'./src/**/*.{js,cjs,mjs,jsx,ts,tsx,json,md,yml}': async (files) => {
const match = await removeIgnoredFiles(files);
return [`eslint --max-warnings=0 ${match}`, `prettier --write ${match}`];
},
'./**/*.{json,md,yml}': ['prettier --write'],
'package.json': 'npx sort-package-json',
};
1 change: 1 addition & 0 deletions frontend/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
23 changes: 13 additions & 10 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"name": "frontend",
"version": "0.1.0",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "next build",
"compile": "tsc --noEmit",
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "echo \"tests\"",
"format": "prettier 'src/**/*.{js,jsx,ts,tsx}' --write",
"postinstall": "cd .. && husky frontend/.husky",
"lint": "next lint",
"lint:fix": "next lint --fix",
"format": "prettier 'src/**/*.{js,jsx,ts,tsx}' --write",
"postinstall": "cd .. && husky frontend/.husky"
"start": "next start",
"test": "echo \"tests\""
},
"dependencies": {
"@headlessui/react": "^2.0.4",
Expand All @@ -20,15 +21,17 @@
"next": "14.1.3",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.52.0",
"react-easy-crop": "^5.0.7",
"react-hook-form": "^7.52.0",
"react-markdown": "^9.0.1",
"react-tooltip": "^5.26.3",
"remark-gfm": "^4.0.0",
"tailwind-merge": "^2.2.2",
"zustand": "^4.5.4"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@tailwindcss/typography": "^0.5.13",
"@types/node": "^20",
"@types/react": "^18",
Expand All @@ -41,6 +44,7 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-sonarjs": "^0.24.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"postcss": "^8",
"prettier": "3.2.5",
"prettier-plugin-tailwindcss": "^0.6.5",
Expand All @@ -49,8 +53,7 @@
},
"engines": {
"node": ">=20.11.1",
"yarn": ">=1.22.11",
"npm": "please-use-yarn"
},
"license": "UNLICENSED"
"npm": "please-use-yarn",
"yarn": ">=1.22.11"
}
}
Loading

0 comments on commit d2e6b8f

Please sign in to comment.