Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: eslint migration #2265

Merged
merged 12 commits into from
Jan 9, 2025
Merged
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

72 changes: 0 additions & 72 deletions .eslintrc.js

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -129,8 +129,9 @@ jobs:
with:
install: 'no'

- name: Install dev dependencies
run: pnpm install --dev
# NOTE: eslint-config-next 에서 next 모듈을 찾지 못하는 에러를 해결하기 위해 프론트엔드 의존성을 설치합니다.
- name: Install root and frontend dependencies
run: pnpm install -w --filter frontend

- name: Set up Go
uses: actions/setup-go@v5
45 changes: 0 additions & 45 deletions apps/frontend/.eslintrc.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export default async function EditorLayout({
problem = { ...contestProblem.problem, order: contestProblem.order }

contest = await fetcher(`contest/${contestId}`).json()
contest ? (contest.status = 'ongoing') : null // TODO: refactor this after change status interactively
contest && (contest.status = 'ongoing') // TODO: refactor this after change status interactively
} else {
problem = await fetcher(`problem/${problemId}`).json()
}
1 change: 0 additions & 1 deletion apps/frontend/codegen.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ const config: CodegenConfig = {
// this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure
documents: ['./**/*.{ts,tsx}'],
generates: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'./__generated__/': {
preset: 'client',
plugins: [],
6 changes: 2 additions & 4 deletions apps/frontend/components/shadcn/calendar.tsx
Original file line number Diff line number Diff line change
@@ -60,10 +60,8 @@ export const Calendar = ({
...classNames
}}
components={{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IconLeft: ({ ...props }) => <ChevronLeftIcon className="h-4 w-4" />,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IconRight: ({ ...props }) => <ChevronRightIcon className="h-4 w-4" />
IconLeft: () => <ChevronLeftIcon className="h-4 w-4" />,
IconRight: () => <ChevronRightIcon className="h-4 w-4" />
}}
{...props}
/>
2 changes: 1 addition & 1 deletion apps/frontend/graphql/notice/queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from '@apollo/client'
import { gql } from '@generated'

const GET_NOTICE = gql(`
query GetNotice($groupId: Int!, $noticeId: Int!) {
2 changes: 0 additions & 2 deletions apps/frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withSentryConfig } = require('@sentry/nextjs')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
3 changes: 1 addition & 2 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"dev": "next dev -p 5525",
"build": "pnpm run compile && next build",
"start": "next start --keepAliveTimeout 70000",
"lint": "next lint",
"lint": "eslint .",
"compile": "graphql-codegen --require dotenv/config",
"test": "vitest"
},
@@ -106,7 +106,6 @@
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"eslint-config-next": "^14.2.22",
"jsdom": "^25.0.1",
"lucide-react": "^0.469.0",
"msw": "^2.7.0",
1 change: 0 additions & 1 deletion apps/frontend/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
import typography from '@tailwindcss/typography'
import type { Config } from 'tailwindcss'
import animate from 'tailwindcss-animate'
2 changes: 0 additions & 2 deletions apps/frontend/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -8,9 +8,7 @@ export default defineConfig({
globals: true,
setupFiles: ['./vitest.setup.ts'],
env: {
// eslint-disable-next-line @typescript-eslint/naming-convention
NEXT_PUBLIC_BASEURL: 'https://test.com/api',
// eslint-disable-next-line @typescript-eslint/naming-convention
NEXTAUTH_URL: 'https://test.com/next-auth/api/auth'
}
},
182 changes: 182 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import { FlatCompat } from '@eslint/eslintrc'
import eslintJS from '@eslint/js'
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import eslintTS from 'typescript-eslint'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const flatCompat = new FlatCompat({
baseDirectory: __dirname
})

export default eslintTS.config(
{
ignores: [
'**/dist',
'**/node_modules',
'**/.pnpm-store',
'**/__generated__',
'**/@generated',
'**/collection',
'**/.next',
'**/codegen.ts',
'**/*.config.{js,mjs,ts}'
]
},

/* Common configuration */
eslintPluginPrettier,
eslintJS.configs.recommended,
...eslintTS.configs.recommended,
{
plugins: {
'@typescript-eslint': eslintTS.plugin
},
languageOptions: {
parser: eslintTS.parser,
parserOptions: {
project: true,
emitDecoratorMetadata: true,
ecmaFeatures: {
jsx: true
}
},
globals: {
...globals.node
}
},
rules: {
'object-shorthand': ['warn', 'always'],
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-import-type-side-effects': 'error'
}
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: 'import',
format: ['camelCase', 'PascalCase']
},
{
selector: 'typeLike',
format: ['PascalCase']
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: ['objectLiteralProperty', 'classProperty'],
format: ['camelCase', 'PascalCase']
}
]
}
},

/* Backend configuration */
{
files: ['apps/backend/**/*'],
rules: {
'func-style': ['error', 'expression'],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['apps/*', 'libs/*'],
message:
'Please import with path alias like `@apps/*` or `@libs/*`'
}
]
}
]
}
},
{
files: ['apps/backend/**/*.spec.ts'],
languageOptions: {
globals: {
...globals.mocha
}
},
rules: {
'@typescript-eslint/no-unused-expressions': 'off'
}
},
gyunseo marked this conversation as resolved.
Show resolved Hide resolved

/* Frontend configuration */
...flatCompat
.config({
extends: ['next/core-web-vitals']
})
.map((config) => ({
...config,
files: ['apps/frontend/**/*']
})),
{
files: ['apps/frontend/**/*'],
languageOptions: {
globals: {
...globals.browser
}
},
rules: {
'@next/next/no-html-link-for-pages': [
'error',
path.join(__dirname, 'apps/frontend/app')
],
'no-restricted-imports': [
'error',
{
name: '@apollo/client',
importNames: ['gql'],
message: 'Please use @generated instead.'
},
{
name: '@/__generated__',
message: 'Please use @generated instead.'
},
{
name: '@/__generated__/graphql',
message: 'Please use @generated/graphql instead.'
}
],
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'with-single-extends' }
],
'@typescript-eslint/no-unused-expressions': [
'error',
{ allowShortCircuit: true, allowTernary: true }
]
}
},
{
files: ['apps/frontend/**/*.tsx'],
ignores: ['apps/frontend/components/shadcn/*.tsx'],
rules: {
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration'
}
]
}
}
)
1 change: 0 additions & 1 deletion knip.ts → knip.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { KnipConfig } from 'knip'

const config: KnipConfig = {
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codedang",
"scripts": {
"lint": "eslint . --ext .js,.ts,.tsx,.jsx",
"lint": "eslint .",
eunnbi marked this conversation as resolved.
Show resolved Hide resolved
"format": "prettier --write .",
"format:check": "prettier --check .",
"init:storage": "ts-node scripts/init-storage.ts",
@@ -12,20 +12,22 @@
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@commitlint/types": "^19.5.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@tsconfig/recommended": "^1.0.8",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.1",
"eslint-config-next": "^14.2.22",
"eslint": "^9.17.0",
"eslint-config-next": "^15.1.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.14.0",
"knip": "^5.41.1",
"lefthook": "^1.10.1",
"prettier": "^3.4.2",
"prettier-plugin-tailwindcss": "^0.6.9",
"ts-node": "^10.9.2",
"typescript": "5.7.2"
"typescript": "5.7.2",
"typescript-eslint": "^8.18.1"
},
"packageManager": "pnpm@9.15.2"
}
557 changes: 297 additions & 260 deletions pnpm-lock.yaml

Large diffs are not rendered by default.