Skip to content

Commit d90f9ac

Browse files
committed
chore: use lint-staged
1 parent 8eddbd6 commit d90f9ac

File tree

12 files changed

+550
-344
lines changed

12 files changed

+550
-344
lines changed

Diff for: .eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"node": true
55
},
66
"parser": "@typescript-eslint/parser",
7-
"plugins": ["@typescript-eslint", "react-hooks"],
7+
"plugins": ["@typescript-eslint"],
88
"extends": [
99
"eslint:recommended",
1010
"plugin:react/recommended",

Diff for: .husky/_/husky.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
if [ -z "$husky_skip_init" ]; then
3+
debug () {
4+
if [ "$HUSKY_DEBUG" = "1" ]; then
5+
echo "husky (debug) - $1"
6+
fi
7+
}
8+
9+
readonly hook_name="$(basename "$0")"
10+
debug "starting $hook_name..."
11+
12+
if [ "$HUSKY" = "0" ]; then
13+
debug "HUSKY env variable is set to 0, skipping hook"
14+
exit 0
15+
fi
16+
17+
if [ -f ~/.huskyrc ]; then
18+
debug "sourcing ~/.huskyrc"
19+
. ~/.huskyrc
20+
fi
21+
22+
export readonly husky_skip_init=1
23+
sh -e "$0" "$@"
24+
exitCode="$?"
25+
26+
if [ $exitCode != 0 ]; then
27+
echo "husky - $hook_name hook exited with code $exitCode (error)"
28+
fi
29+
30+
exit $exitCode
31+
fi

Diff for: .husky/commit-msg

100644100755
File mode changed.

Diff for: .husky/pre-commit

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn pretty-quick --staged
4+
yarn lint-staged

Diff for: package.json

+15-7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"packages/*"
88
],
99
"scripts": {
10+
"prepare": "husky install",
1011
"build": "lerna run build",
1112
"storybook": "start-storybook -p 6006",
1213
"test": "lerna run test",
14+
"lint": "lerna run lint",
1315
"ui": "yarn workspace @template/ui",
1416
"website": "yarn workspace @template/website"
1517
},
@@ -19,17 +21,16 @@
1921
"@commitlint/config-conventional": "14.1.0",
2022
"@storybook/addon-essentials": "6.3.12",
2123
"@storybook/react": "6.3.12",
22-
"@typescript-eslint/eslint-plugin": "5.3.1",
23-
"@typescript-eslint/parser": "5.3.1",
24+
"@typescript-eslint/eslint-plugin": "5.4.0",
25+
"@typescript-eslint/parser": "5.4.0",
2426
"babel-loader": "8.2.3",
25-
"concurrently": "6.3.0",
27+
"concurrently": "6.4.0",
2628
"eslint": "8.2.0",
27-
"eslint-plugin-react": "7.26.1",
28-
"eslint-plugin-react-hooks": "4.2.0",
29+
"eslint-plugin-react": "7.27.0",
2930
"husky": "7.0.4",
3031
"lerna": "4.0.0",
32+
"lint-staged": "12.0.2",
3133
"prettier": "2.4.1",
32-
"pretty-quick": "3.1.1",
3334
"typescript": "4.4.4"
3435
},
3536
"commitlint": {
@@ -41,5 +42,12 @@
4142
"node": "16.13.0",
4243
"yarn": "1.22.17"
4344
},
44-
"dependencies": {}
45+
"lint-staged": {
46+
"**/*.{js,jsx,ts,tsx}": [
47+
"eslint --fix"
48+
],
49+
"**/*.{js,jsx,ts,tsx,json,html}": [
50+
"prettier --write"
51+
]
52+
}
4553
}

Diff for: packages/ui/esbuild.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { build } from 'esbuild'
33
const ExcludeExternalPackagesPlugin = {
44
name: 'ExcludeExternalPackagesPlugin',
55
setup(build) {
6-
const filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/
6+
const filter = /^[^./]|^\.[^./]|^\.\.[^/]/
77
build.onResolve({ filter }, (args) => ({ path: args.path, external: true }))
88
},
99
}

Diff for: packages/ui/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"scripts": {
2323
"prebuild": "rimraf dist",
2424
"build": "node ./esbuild.js",
25+
"lint": "eslint --fix --ext .ts,.tsx ./src",
2526
"types": "tsc --emitDeclarationOnly",
2627
"test": "jest"
2728
},
@@ -36,9 +37,9 @@
3637
"@testing-library/react-hooks": "7.0.2",
3738
"@testing-library/user-event": "13.5.0",
3839
"@types/jest": "27.0.2",
39-
"@types/react": "17.0.34",
40+
"@types/react": "17.0.35",
4041
"@types/react-dom": "17.0.11",
41-
"esbuild": "0.13.12",
42+
"esbuild": "0.13.14",
4243
"jest": "27.3.1"
4344
},
4445
"jest": {

Diff for: packages/ui/src/Button.stories.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React, { useState } from 'react'
2+
import { Button } from './Button'
3+
4+
export default {
5+
title: 'My Button Story',
6+
}
7+
8+
export const Demo = () => {
9+
const [state, setstate] = useState(0)
10+
11+
return <Button onClick={() => setstate(state + 1)}>{state.toString()}</Button>
12+
}

Diff for: packages/ui/src/Button.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react'
22

33
interface ButtonProps {
4-
label: string
4+
children: React.ReactNode
5+
onClick?: () => void
56
}
67

78
export const Button = (props: ButtonProps) => {
8-
return <button style={{ background: 'blue' }}>{props.label}</button>
9+
return <button style={{ background: 'blue' }} {...props} />
910
}

Diff for: packages/website/package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8-
"start": "next start",
9-
"lint": "next lint"
8+
"start": "next start"
109
},
1110
"dependencies": {
1211
"@template/ui": "1.0.0",
13-
"next": "12.0.3",
12+
"next": "12.0.4",
1413
"react": "17.0.2",
1514
"react-dom": "17.0.2"
1615
},
1716
"devDependencies": {
18-
"@types/node": "16.11.6",
19-
"@types/react": "17.0.34",
17+
"@types/node": "16.11.7",
18+
"@types/react": "17.0.35",
2019
"eslint": "8.2.0",
21-
"eslint-config-next": "12.0.3",
20+
"eslint-config-next": "12.0.4",
2221
"typescript": "4.4.4"
2322
}
2423
}

Diff for: packages/website/pages/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import type { NextPage } from 'next'
21
import { Button } from '@template/ui'
2+
import type { NextPage } from 'next'
3+
import React from 'react'
34

45
const Home: NextPage = () => {
56
return (
67
<div>
78
<h1>Hello World</h1>
8-
<Button label="Hello World" />
9+
10+
<Button>Hello World</Button>
911
</div>
1012
)
1113
}

0 commit comments

Comments
 (0)