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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 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.

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

- name: Install dev dependencies
run: pnpm install --dev
- name: Install dependencies
run: pnpm install
Comment on lines -132 to +133
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AS-IS: Dev 의존성만 설치 -> eslint-config-next/parser.js에서 next/dist/compiled/babel/eslint-parser 의존성을 찾지 못함

TO-BE: 모든 의존성 설치

(더 나은 해결 방법 있으면 알려주세요..)


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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
1 change: 0 additions & 1 deletion apps/frontend/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
6 changes: 2 additions & 4 deletions apps/frontend/components/shadcn/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
Expand Down
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!) {
Expand Down
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'
})
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -106,7 +106,6 @@
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"eslint-config-next": "^14.2.17",
"jsdom": "^25.0.1",
"lucide-react": "^0.456.0",
"msw": "^2.6.4",
Expand Down
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'
Expand Down
2 changes: 0 additions & 2 deletions apps/frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
},
Expand Down
179 changes: 179 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import { fixupConfigRules } from '@eslint/compat'
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
})

const patchedNextLintConfig = fixupConfigRules(
flatCompat.extends('next/core-web-vitals')
)

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,
{
languageOptions: {
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'
}
},
Comment on lines +111 to +121
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/* Frontend configuration */
...patchedNextLintConfig.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 = {
Expand Down
Loading
Loading