Skip to content

Commit 7b193c7

Browse files
feat: add lint-staged
1 parent 9d09662 commit 7b193c7

File tree

6 files changed

+279
-8
lines changed

6 files changed

+279
-8
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"jsx-a11y/accessible-emoji": "off",
2525
"no-duplicate-imports": "error",
2626
"no-multi-spaces": "warn",
27+
"no-undef":"off",
2728
"no-unused-vars": "warn",
2829
"no-useless-rename": "warn",
2930
"react/jsx-sort-props": ["warn", { "reservedFirst": ["key"] }],

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
.eslintcache

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"lint": "eslint .",
2323
"lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx,yml,yaml}\"",
2424
"test": "react-scripts test",
25-
"eject": "react-scripts eject"
25+
"eject": "react-scripts eject",
26+
"prepare": "husky install"
2627
},
2728
"eslintConfig": {
2829
"extends": [
@@ -49,11 +50,19 @@
4950
"eslint-plugin-prettier": "^4.0.0",
5051
"eslint-plugin-react": "^7.30.0",
5152
"eslint-plugin-react-hooks": "^4.6.0",
53+
"husky": "^8.0.1",
54+
"lint-staged": "^13.0.3",
5255
"postcss": "^8.4.14",
5356
"prettier": "^2.7.0",
5457
"prettier-plugin-tailwindcss": "^0.1.11",
5558
"stylelint": "^14.9.1",
5659
"stylelint-config-recommended": "^8.0.0",
5760
"tailwindcss": "^3.1.2"
61+
},
62+
"lint-staged": {
63+
"*.{js,jsx}": [
64+
"eslint --cache --fix",
65+
"prettier --write"
66+
]
5867
}
5968
}

src/__tests__/Home.test.jsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { render } from '@testing-library/react';
2+
import Home from '../pages/Home';
3+
4+
describe('HomePage', () => {
5+
it('home page content rendered properly', () => {
6+
const { getByText } = render(<Home />);
7+
8+
expect(getByText(/Telusuri Kategori/i)).toBeInTheDocument();
9+
});
10+
});

0 commit comments

Comments
 (0)