Skip to content

Commit e1ac5df

Browse files
authored
Merge pull request #15 from Bibimbap-Team/12-add-formatting-check-in-ci
Add ESLinter and Prettier
2 parents 7e037d2 + 8cdb634 commit e1ac5df

File tree

14 files changed

+213
-57
lines changed

14 files changed

+213
-57
lines changed

.eslintrc.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
{
2-
"extends": "next/core-web-vitals"
3-
}
2+
"parser": "@typescript-eslint/parser",
3+
"extends": ["eslint:recommended", "next", "next/core-web-vitals", "prettier", "plugin:@typescript-eslint/recommended"],
4+
"rules": {
5+
"prefer-const": "warn",
6+
"no-undef": "off",
7+
"import/order": [
8+
"warn",
9+
{
10+
"groups": ["builtin", "external", ["parent", "sibling"], "index"],
11+
"newlines-between": "always"
12+
}
13+
],
14+
"@typescript-eslint/no-unnecessary-type-constraint": "off",
15+
"@typescript-eslint/no-explicit-any": "warn",
16+
"@next/next/no-img-element": "off",
17+
"@typescript-eslint/no-empty-interface": "off"
18+
}
19+
}

.github/workflows/ci.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Set NODE_ENV
17-
run: echo "NODE_ENV=development" >> $GITHUB_ENV
18-
1916
- name: Checkout repository
2017
uses: actions/checkout@v4
2118

@@ -25,6 +22,18 @@ jobs:
2522
node-version: '20' # Changed to 20, as 22 is not yet stable
2623
cache: 'yarn'
2724

25+
- name: Get yarn cache directory path
26+
id: yarn-cache-dir-path
27+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
28+
29+
- uses: actions/cache@v4
30+
id: yarn-cache
31+
with:
32+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
33+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-yarn-
36+
2837
- name: Install Yarn
2938
run: corepack enable
3039

@@ -33,3 +42,9 @@ jobs:
3342

3443
- name: Run unit tests
3544
run: yarn run test
45+
46+
- name: Run linter
47+
run: yarn run lint
48+
49+
- name: Run prettier
50+
run: yarn run prettier

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"singleQuote": true,
3+
"jsxSingleQuote": true,
4+
"semi": true,
5+
"useTabs": false,
6+
"tabWidth": 2,
7+
"trailingComma": "all",
8+
"printWidth": 88,
9+
"arrowParens": "always"
10+
}

__tests__/pages/landing.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Home from '@/app/page';
55
it('renders 6 change logs', () => {
66
render(<Home />);
77
// Finds all p tags with date logs
8-
const numListItems = screen
9-
.getByTestId('changelog')
10-
.querySelectorAll('p').length;
8+
const numListItems = screen.getByTestId('changelog').querySelectorAll('p').length;
119
expect(numListItems).toBe(6);
1210
});

jest.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* https://jestjs.io/docs/configuration
44
*/
55

6-
import type {Config} from 'jest';
6+
import type { Config } from 'jest';
77
import nextJest from 'next/jest.js';
88

99
const createJestConfig = nextJest({
1010
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
1111
dir: './',
12-
})
12+
});
1313

1414
const config: Config = {
1515
// All imported modules in your tests should be mocked automatically
@@ -31,15 +31,15 @@ const config: Config = {
3131
// collectCoverageFrom: undefined,
3232

3333
// The directory where Jest should output its coverage files
34-
coverageDirectory: "coverage",
34+
coverageDirectory: 'coverage',
3535

3636
// An array of regexp pattern strings used to skip coverage collection
3737
// coveragePathIgnorePatterns: [
3838
// "/node_modules/"
3939
// ],
4040

4141
// Indicates which provider should be used to instrument code for coverage
42-
coverageProvider: "v8",
42+
coverageProvider: 'v8',
4343

4444
// A list of reporter names that Jest uses when writing coverage reports
4545
// coverageReporters: [
@@ -152,7 +152,7 @@ const config: Config = {
152152
// snapshotSerializers: [],
153153

154154
// The test environment that will be used for testing
155-
testEnvironment: "jsdom",
155+
testEnvironment: 'jsdom',
156156

157157
// Options that will be passed to the testEnvironment
158158
// testEnvironmentOptions: {},

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "next build",
99
"start": "next start",
1010
"lint": "next lint",
11+
"prettier": "npx prettier --config ./.prettierrc --write **/*.{ts,tsx}",
1112
"test": "jest",
1213
"test:watch": "jest --watch"
1314
},
@@ -32,13 +33,19 @@
3233
"@types/node": "^20",
3334
"@types/react": "^18",
3435
"@types/react-dom": "^18",
36+
"@typescript-eslint/eslint-plugin": "^7.18.0",
37+
"@typescript-eslint/parser": "^7.18.0",
3538
"eslint": "^8",
3639
"eslint-config-next": "14.2.4",
40+
"eslint-config-prettier": "^9.1.0",
41+
"eslint-plugin-prettier": "^5.2.1",
3742
"jest": "^29.7.0",
3843
"jest-cli": "^29.7.0",
3944
"jest-environment-jsdom": "^29.7.0",
4045
"postcss": "^8",
46+
"prettier": "^3.3.3",
4147
"tailwindcss": "^3.4.1",
4248
"typescript": "^5"
43-
}
49+
},
50+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
4451
}

src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { Metadata } from 'next';
22
import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter';
33
import { Container, ThemeProvider } from '@mui/material';
4+
45
import theme from '../theme';
6+
57
import './globals.css';
68
import Navigation from '@/components/Navigation';
79

src/app/login/SubmitBox.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { FormEvent } from 'react';
33
import { Box } from '@mui/material';
44

55
// This file holds the handling logic for the login form submission.
6-
export default function LoginSubmitBox({
7-
children,
8-
}: {
9-
children: React.ReactNode;
10-
}) {
6+
export default function LoginSubmitBox({ children }: { children: React.ReactNode }) {
117
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
128
event.preventDefault();
139
const data = new FormData(event.currentTarget);

src/app/login/page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import {
99
Typography,
1010
} from '@mui/material';
1111
import { LockOutlined } from '@mui/icons-material';
12+
13+
import LoginSubmitBox from './SubmitBox';
14+
1215
import Copyright from '@/components/Copyright';
1316
import CustomLink from '@/components/CustomLink';
14-
import LoginSubmitBox from './SubmitBox';
1517

1618
export default function Login() {
1719
return (
@@ -55,12 +57,7 @@ export default function Login() {
5557
control={<Checkbox value='remember' color='primary' />}
5658
label='Remember me'
5759
/>
58-
<Button
59-
type='submit'
60-
fullWidth
61-
variant='contained'
62-
sx={{ mt: 3, mb: 2 }}
63-
>
60+
<Button type='submit' fullWidth variant='contained' sx={{ mt: 3, mb: 2 }}>
6461
Login
6562
</Button>
6663
<Grid container>

src/app/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ export default function Home() {
1919
<Stack direction={{ sm: 'column', md: 'row' }} gap={2} mt={2}>
2020
<Paper sx={{ p: 2 }} elevation={3}>
2121
<Typography variant='body1'>
22-
The mission of Polygon is to provide platform for creation of
23-
programming contest problems. Polygon supports the whole development
24-
cycle:
22+
The mission of Polygon is to provide platform for creation of programming
23+
contest problems. Polygon supports the whole development cycle:
2524
</Typography>
2625
<ul className='list-disc list-inside'>
2726
<li>problem statement writing</li>

0 commit comments

Comments
 (0)