-
Notifications
You must be signed in to change notification settings - Fork 1
[Init] eslint, prettier 세팅 #14
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5950a99
add: eslint, prettier plugin 설치 (#10)
hummingbbird 2753150
feat: eslint 룰 초기 세팅 (#10)
hummingbbird 1d8aeb3
feat: prettier 룰 추가 (#10)
hummingbbird 24f24cf
feat: prettier 룰 추가 (#10)
hummingbbird a3d229a
chore: unused 코드 삭제 (#10)
hummingbbird 5e0a661
chore: 화살표 함수 권장 룰 추가 (#10)
hummingbbird 4b65894
fix: react-arrrow function 플러그인 설치 (#10)
hummingbbird File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Dependencies | ||
| node_modules/ | ||
|
|
||
| # Environment variables | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Production builds | ||
| out/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Cache Report | ||
| .cache/ | ||
| .vite/ | ||
| .vite-cache/ | ||
| coverage/ | ||
| tsconfig.tsbuildinfo | ||
|
|
||
| # Logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| # Lock files | ||
| pnpm-lock.yaml | ||
| yarn.lock | ||
| package-lock.json | ||
|
|
||
| # IDE | ||
| .idea/ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "arrowParens": "always", | ||
| "bracketSpacing": true, | ||
| "semi": true, | ||
| "singleQuote": false, | ||
| "jsxSingleQuote": false, | ||
| "printWidth": 80, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "endOfLine": "lf", | ||
| "quoteProps": "as-needed", | ||
| "trailingComma": "es5", | ||
| "proseWrap": "preserve", | ||
| "singleAttributePerLine": false | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,100 @@ | ||
| import js from '@eslint/js' | ||
| import globals from 'globals' | ||
| import reactHooks from 'eslint-plugin-react-hooks' | ||
| import reactRefresh from 'eslint-plugin-react-refresh' | ||
| import tseslint from 'typescript-eslint' | ||
| import { defineConfig, globalIgnores } from 'eslint/config' | ||
| import js from "@eslint/js"; | ||
| import globals from "globals"; | ||
| import reactHooks from "eslint-plugin-react-hooks"; | ||
| import reactRefresh from "eslint-plugin-react-refresh"; | ||
| import tseslint from "typescript-eslint"; | ||
| import { defineConfig } from "eslint/config"; | ||
| import importPlugin from "eslint-plugin-import"; | ||
| import typescriptParser from "@typescript-eslint/parser"; | ||
| import eslintConfigPrettier from "eslint-config-prettier"; | ||
|
|
||
| export default defineConfig([ | ||
| globalIgnores(['dist']), | ||
| { ignores: ["dist", "node_modules", "build", "*.config.js", "*.config.ts"] }, | ||
|
|
||
| importPlugin.flatConfigs.recommended, | ||
| importPlugin.flatConfigs.typescript, | ||
| js.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| reactHooks.configs.flat.recommended, | ||
| reactRefresh.configs.vite, | ||
|
|
||
| { | ||
| files: ['**/*.{ts,tsx}'], | ||
| extends: [ | ||
| js.configs.recommended, | ||
| tseslint.configs.recommended, | ||
| reactHooks.configs.flat.recommended, | ||
| reactRefresh.configs.vite, | ||
| ], | ||
| files: ["**/*.{ts,tsx}"], | ||
| settings: { | ||
| react: { | ||
| version: "detect", | ||
| }, | ||
| "import/resolver": { | ||
| typescript: { | ||
| alwaysTryTypes: true, | ||
| project: "./tsconfig.app.json", | ||
| }, | ||
| }, | ||
| }, | ||
| languageOptions: { | ||
| ecmaVersion: 2020, | ||
| globals: globals.browser, | ||
| sourceType: "module", | ||
| parser: typescriptParser, | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| }, | ||
| rules: { | ||
| "no-var": "error", // var 금지 | ||
| "no-console": ["warn", { allow: ["warn", "error"] }], // console.log 경고 | ||
|
|
||
| "no-unused-vars": "off", // ts 룰로 대체함 | ||
| "@typescript-eslint/no-unused-vars": [ | ||
| // 사용하지 않는 변수 경고 | ||
| "warn", | ||
| { | ||
| argsIgnorePattern: "^_", | ||
| varsIgnorePattern: "^_", | ||
| caughtErrorsIgnorePattern: "^_", | ||
| }, | ||
| ], | ||
|
|
||
| "@typescript-eslint/consistent-type-imports": [ | ||
| // type import 사용 권장 | ||
| "error", | ||
| { prefer: "type-imports" }, | ||
| ], | ||
| "@typescript-eslint/no-explicit-any": "warn", // any 사용 경고 | ||
| "@typescript-eslint/no-non-null-assertion": "warn", // non-null assertion 경고 | ||
|
|
||
| "react-hooks/rules-of-hooks": "error", // Hooks 규칙 준수 | ||
| "react-hooks/exhaustive-deps": "warn", // useEffect 의존성 배열 검사 | ||
|
|
||
| // import 정렬 order 설정 | ||
| "import/order": [ | ||
| "warn", | ||
| { | ||
| groups: [ | ||
| "builtin", | ||
| "external", | ||
| "internal", | ||
| "parent", | ||
| "sibling", | ||
| "index", | ||
| "type", | ||
| ], | ||
| "newlines-between": "always", | ||
| alphabetize: { order: "asc", caseInsensitive: true }, | ||
| }, | ||
| ], | ||
|
Comment on lines
+82
to
+98
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import를 할 때마다 모듈 종류에 상관없이 순서가 뒤죽박죽돼서 import문의 가독성이 좋지 않았던 경우가 많은데
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 import 순서 강제하는 거 너무 좋네요 😍 |
||
| "import/first": "error", // import문 최상단 위치 | ||
| "import/no-duplicates": "error", // 중복 import 금지 | ||
| "import/no-unresolved": "off", // TS resolver가 처리 | ||
| "import/default": "off", // default export 불필요한 경고 제거 | ||
| "import/prefer-default-export": "off", // named export 사용(최적화 관점) | ||
|
|
||
| // Prettier와 충돌 방지 | ||
| "arrow-body-style": "off", | ||
| "prefer-arrow-callback": "off", | ||
| }, | ||
| }, | ||
| ]) | ||
| eslintConfigPrettier, | ||
| ]); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import/order에서"type"그룹을 별도로 두고 마지막에 배치한 구조는 타입 import와 런타임 import를 명확히 구분하려는 의도로 해석되는 것 같네용!!다만 이 설정이
@typescript-eslint/consistent-type-imports와 함께 적용될 경우,type import가 항상 분리·이동되면서import관련 diff가 커질 수 있는 포인트가 될 수도 있다고 하네요 ㅠㅠ수빈님이 위에서 리뷰 달아주신 것과 같이
import정렬 컨벤션을 한 번 확정하고 가면 좋을 것 같습니다!! :)제가 리뷰달고 있는 이 경우는 제가 생각했을 때는 아래 예시와 같이 타입☺️
import는import type으로 항상 분리하고,import/order의"type"그룹은 항상 마지막으로 두는 방식으로 가면 어떨까요??이렇게 하면 타입/런타임
import의 역할이 명확해지고,consistent-type-imports와import/order가 만들어내는 결과가 항상 동일해져서 자동 정렬로 인한 불필요한 import diff를 줄일 수 있을 것 같습니다!!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 이해하기로는 '코드 작성 시에 type import를 가장 마지막에 하는 컨벤션을 지키자~' 로 이해했는데 맞을까요~??(코드 수정 x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 맞습니다!! :)
앞으로는
type import를 항상 마지막에 두는 컨벤션으로 맞춰가면 좋겠다는 제안이었습니다 🙂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다! 웹파트 노션 > 코드 컨벤션 페이지에 해당 룰 추가해두도록 하겠습니다 좋은 의견 감사합니다☺️