Skip to content

Commit b836b58

Browse files
committed
🧑‍💻 add lint, prettier and set husky pre-commit
1 parent f0b9e92 commit b836b58

File tree

11 files changed

+423
-43
lines changed

11 files changed

+423
-43
lines changed

Diff for: .eslintrc.js

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
module.exports = {
2+
ignorePatterns: ['.next/', 'node_modules/', 'public', '.yarn', '@types'],
3+
plugins: ['simple-import-sort'],
4+
extends: ['next/core-web-vitals', 'plugin:@typescript-eslint/recommended', 'prettier'],
5+
parser: '@typescript-eslint/parser',
6+
settings: {
7+
'import/resolver': 'node',
8+
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
9+
'import/parsers': {
10+
'@typescript-eslint/parser': ['.ts', '.tsx'],
11+
},
12+
},
13+
14+
rules: {
15+
// 'React' must be in scope when using JSX 에러 해결 (Next.js)
16+
'react/react-in-jsx-scope': 'off',
17+
'simple-import-sort/imports': [
18+
'error',
19+
{
20+
groups: [
21+
// react > next > @ > a~z
22+
['^react$', '^next', '^@', '^[a-z]'],
23+
// ~
24+
['^~'],
25+
// `../` > './'
26+
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
27+
// Side effect imports
28+
['^\\u0000'],
29+
],
30+
},
31+
],
32+
'import/first': 'error',
33+
'import/newline-after-import': 'error',
34+
'import/no-duplicates': 'error',
35+
36+
'@typescript-eslint/consistent-type-imports': [
37+
'error',
38+
{
39+
prefer: 'type-imports',
40+
fixStyle: 'inline-type-imports',
41+
},
42+
],
43+
'@typescript-eslint/no-shadow': 'error',
44+
'@typescript-eslint/no-unused-vars': [
45+
'error',
46+
{
47+
ignoreRestSiblings: true,
48+
argsIgnorePattern: '_',
49+
varsIgnorePattern: '_',
50+
},
51+
],
52+
'@typescript-eslint/naming-convention': [
53+
'error',
54+
{
55+
selector: 'interface',
56+
format: ['PascalCase'],
57+
},
58+
{
59+
selector: 'typeAlias',
60+
format: ['PascalCase'],
61+
},
62+
],
63+
64+
'react/no-unknown-property': ['error', { ignore: ['css'] }],
65+
'react/button-has-type': 'error',
66+
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
67+
'react/jsx-filename-extension': [
68+
'warn',
69+
{
70+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
71+
},
72+
],
73+
'jsx-a11y/label-has-associated-control': [
74+
'error',
75+
{
76+
labelComponents: ['label'],
77+
labelAttributes: ['label'],
78+
controlComponents: ['StyledHiddenInput'],
79+
depth: 1,
80+
},
81+
],
82+
},
83+
};

Diff for: .eslintrc.json

-3
This file was deleted.

Diff for: .husky/pre-commit

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

Diff for: .idea/inspectionProfiles/Project_Default.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/prettier.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .lintstagedrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"*.{js,jsx,ts,tsx}": [
3+
"yarn lint:fix",
4+
"prettier --write"
5+
]
6+
}

Diff for: .prettierrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
singleQuote: true,
3+
semi: true,
4+
tabWidth: 2,
5+
useTabs: false,
6+
trailingComma: 'all',
7+
printWidth: 120,
8+
arrowParens: 'always',
9+
};

Diff for: package.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,36 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"prepare": "panda codegen",
6+
"prepare": "panda codegen && husky install",
77
"dev": "next dev",
88
"build": "next build",
99
"start": "next start",
10-
"lint": "next lint"
10+
"lint": "next lint",
11+
"lint:fix": "next lint --fix"
1112
},
13+
1214
"dependencies": {
1315
"next": "13.4",
1416
"react": "^18",
1517
"react-dom": "^18"
1618
},
1719
"devDependencies": {
20+
"@next/eslint-plugin-next": "^14.0.3",
1821
"@pandacss/dev": "^0.18.3",
1922
"@types/node": "^20",
2023
"@types/react": "^18",
2124
"@types/react-dom": "^18",
25+
"@typescript-eslint/eslint-plugin": "^6.12.0",
26+
"@typescript-eslint/parser": "^6.12.0",
2227
"eslint": "^8",
2328
"eslint-config-next": "14.0.3",
29+
"eslint-config-prettier": "^9.0.0",
30+
"eslint-plugin-import": "^2.29.0",
31+
"eslint-plugin-jsx-a11y": "^6.8.0",
32+
"eslint-plugin-simple-import-sort": "^10.0.0",
33+
"husky": "^8.0.3",
34+
"lint-staged": "^15.1.0",
35+
"prettier": "^3.1.0",
2436
"typescript": "^5"
2537
}
2638
}

Diff for: src/app/layout.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import type { Metadata } from 'next'
2-
import { Inter } from 'next/font/google'
3-
import './globals.css'
1+
import type { Metadata } from 'next';
2+
import { Inter } from 'next/font/google';
43

5-
const inter = Inter({ subsets: ['latin'] })
4+
import './globals.css';
5+
6+
const inter = Inter({ subsets: ['latin'] });
67

78
export const metadata: Metadata = {
89
title: 'Create Next App',
910
description: 'Generated by create next app',
10-
}
11+
};
1112

12-
export default function RootLayout({
13-
children,
14-
}: {
15-
children: React.ReactNode
16-
}) {
13+
export default function RootLayout({ children }: { children: React.ReactNode }) {
1714
return (
1815
<html lang="en">
1916
<body className={inter.className}>{children}</body>
2017
</html>
21-
)
18+
);
19+
}
20+
21+
{
22+
('rr');
2223
}

Diff for: src/app/page.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { css } from '../../styled-system/css';
22

33
export default function Home() {
4-
return (
5-
<div className={css({ fontSize: "2xl", fontWeight: 'bold' })}>Hello 🐼!</div>
6-
)
7-
}
4+
return <div className={css({ fontSize: '2xl', fontWeight: 'bold' })}>Hello 🐼!</div>;
5+
}

0 commit comments

Comments
 (0)