Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ea6899d
[#43] 🔥 Removew deprecated rule
yongholeeme Nov 20, 2024
c0cfc01
[#43] 🔧 Set version in migration temporarily
yongholeeme Nov 20, 2024
aadc72d
[#43] ✨ Migrate to esm
yongholeeme Nov 20, 2024
843fdda
[#43] 📦️ ESLint@9
yongholeeme Nov 20, 2024
762fccb
[#43] 📝 Update readme for eslint 9 migration
yongholeeme Nov 20, 2024
e87b932
[#43] 👽️ Update deprecated interfaces
yongholeeme Nov 25, 2024
f3289b5
[#43] 🔧 Add script for watcing test
yongholeeme Nov 25, 2024
d503e5e
[#43] 👽️ Convert eslintrc to flat config
yongholeeme Nov 25, 2024
9464b7a
[#43] 🔥 Remove a duplicate test case
yongholeeme Nov 25, 2024
c546271
[#43] 👽️ Convert node to flat config
yongholeeme Nov 23, 2024
5e3502d
[#43] 👽️ Convert front to flat config
yongholeeme Nov 23, 2024
2173ea8
[#43] 🔥 Remove unsupported config
yongholeeme Nov 25, 2024
1f6755d
[#43] 👽️ Convert ts to flat config
yongholeeme Nov 25, 2024
1287cf2
[#43] 👽️ Convert custom to flat config
yongholeeme Nov 27, 2024
7bb7bce
[#43] 🔧 Change jest to child package
yongholeeme Nov 27, 2024
ba186ba
[#43] ✨ Support esm/cjs dual packages
yongholeeme Nov 30, 2024
cab1a6c
[#43] 📦️ Remove unused modules
yongholeeme Nov 30, 2024
1c288e8
[#43] 🔨 Execute build script before lint script
yongholeeme Dec 3, 2024
f8ed418
[#43] 🔨 Execute build script before test script
yongholeeme Dec 3, 2024
b039911
[#43] 🔧 Add ignore configs
yongholeeme Dec 3, 2024
43b9468
[#58] ✨ eslint-config-standard -> neostandard
yongholeeme Dec 4, 2024
bbddf2e
[#62] 🚚 디렉토리 구조 변경
yongholeeme Dec 9, 2024
6861a8e
[#62] 📝 Flat Config 에 맞게 업데이트
yongholeeme Dec 9, 2024
6bc9f65
[#62] 🔥 불필요 룰 제거
yongholeeme Dec 9, 2024
af098a7
[#58] ✨ Add a strict config
yongholeeme Dec 10, 2024
f6d23f1
[#58] ✨ Enforce consistent usage of type imports
yongholeeme Dec 11, 2024
64b4b61
[#58] ✨ Disallow unused imports
yongholeeme Dec 11, 2024
50d800c
[#58] 🚚 Rename a file
yongholeeme Dec 11, 2024
dc95fa1
[#58] ✨ Enforce a convention in the order
yongholeeme Dec 11, 2024
a67a94b
[#58] ✨ Export strict
yongholeeme Dec 11, 2024
b1686d1
[#58] 🐛 Fix tseslint
yongholeeme Dec 17, 2024
336b452
[#58] ✨ eslint-plugin-yml
yongholeeme Dec 10, 2024
b08c1ba
[#58] 🎨 Add .yml to prettier
yongholeeme Dec 11, 2024
7ff7d5d
[#67] 🔧 use lefthook instead of husky, lint-staged
yongholeeme Dec 19, 2024
61a94fe
[#67] 🔧 vscode settings
yongholeeme Dec 19, 2024
dd5d33b
[#65] 📦️ update turbo to v2
yongholeeme Dec 19, 2024
4c08af6
[#58] ✨ Add vitest gloabals
yongholeeme Dec 18, 2024
b52f720
Merge branch 'main' into eslint9
yongholeeme Dec 20, 2024
69bbb8b
✨ convert import-server-only to esm
yongholeeme Dec 20, 2024
9488903
🚚 yaml 분리
yongholeeme Dec 23, 2024
234bf61
📝 revise usage instructions
Jan 2, 2025
7454f4c
📝 add an warning for @typescript-eslint rules with YAML
Jan 3, 2025
458c03d
[#75] 📦️ remove unused packages
yongholeeme Jan 3, 2025
2cd83b6
[#75] 📦️ move peers to deps
yongholeeme Jan 3, 2025
2ef60c8
📝 add keywords
yongholeeme Jan 3, 2025
3bc7146
🔧 build before publish
yongholeeme Jan 3, 2025
2016891
🔧 add canary script
yongholeeme Jan 3, 2025
a642199
[#75] 🔧 remove unused script
yongholeeme Jan 3, 2025
5aefc73
[#75] 👷 update trigger types in changesets workflow
yongholeeme Jan 8, 2025
2c19ec7
Merge pull request #76 from NaverPayDev/feature/75_deps
yongholeeme Jan 8, 2025
8277a65
add changeset
yongholeeme Jan 10, 2025
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
13 changes: 13 additions & 0 deletions .changeset/cg-eslint-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@naverpay/eslint-config": major
---

- Support ESLint 9 and Flat Config
- **Config Changes**:
- Renamed `front` to `react`
- Removed `typescript/next` config
- Added `strict` config that extends `unicorn` and `sonarjs`
- Added YAML lint in `node` and `react` configs
- Disallowed unused imports in `node` and `react` configs
- Enforced consistent usage of type imports in `typescript` and `react` configs
- <https://github.com/NaverPayDev/code-style/pull/74>
6 changes: 6 additions & 0 deletions .changeset/cg-eslint-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@naverpay/eslint-plugin": major
---

- Support ESLint 9 and Flat Config
- <https://github.com/NaverPayDev/code-style/pull/74>
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

61 changes: 30 additions & 31 deletions .github/workflows/add-assignee.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
name: 'add assignee to pull request automatically'
on:
pull_request:
types: [ opened, ready_for_review, synchronize, reopened ]
branches:
- '**'
- '!main'
pull_request:
types: [opened, ready_for_review, synchronize, reopened]
branches:
- '**'
- '!main'
jobs:
ADD_ASSIGNEE_TO_PULL_REQUEST:
runs-on: ubuntu-latest
steps:
- name: Add Assignee to pr
uses: actions/github-script@v3
with:
script: |
try {
const result = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.number,
})
ADD_ASSIGNEE_TO_PULL_REQUEST:
runs-on: ubuntu-latest
steps:
- name: Add Assignee to pr
uses: actions/github-script@v3
with:
script: |
try {
const result = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.number,
})

console.log(result)

if (result.data.assignee === null) {
await github.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: context.actor,
})
}
} catch (err) {
console.error(`Check Pull Request Error ${err}`)
}
console.log(result)

if (result.data.assignee === null) {
await github.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: context.actor,
})
}
} catch (err) {
console.error(`Check Pull Request Error ${err}`)
}
6 changes: 3 additions & 3 deletions .github/workflows/changeset-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: changeset-publish

on:
push:
branches:
- main
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changesets-detect-add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
branches:
- '**'
types: [opened, reopened, synchronize]
types: [opened, reopened, synchronize, labeled, unlabeled]

jobs:
detect-add:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# etc
.idea
.vscode

# Dependency directories
node_modules/
Expand Down
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.github
.changeset
.husky
.changeset
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"DavidAnson.vscode-markdownlint"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.markdownlint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.importModuleSpecifier": "non-relative"
}
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import naverpay from '@naverpay/eslint-config'

export default [
{
ignores: ['**/dist/**'],
},
...naverpay.configs.node,
]
23 changes: 23 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Configure lefthook
# @see https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md

# Note: commit-msg hook takes a single parameter,
# the name of the file that holds the proposed commit log message.
# @see https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md#git-arguments
commit-msg:
commands:
commit-helper:
run: 'npx --yes @naverpay/commit-helper {1}'

pre-commit:
parallel: true
commands:
lint:
glob: '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,yaml,yml}'
run: pnpm eslint {staged_files}
prettier:
glob: '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,yaml,yml}'
run: pnpm prettier --check {staged_files}
markdownlit:
glob: '*.md'
run: pnpm markdownlint {staged_files}
32 changes: 13 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,29 @@
},
"description": "code-style for naverpay",
"scripts": {
"prepare": "husky install",
"lint": "eslint '**/*.{js,jsx,ts,tsx}'",
"lint:fix": "pnpm run lint --fix",
"prettier": "prettier --check '**/*.{json,yaml,md,ts,tsx,js,jsx}'",
"prettier:fix": "prettier --write '**/*.{json,yaml,md,ts,tsx,js,jsx}'",
"postinstall": "lefthook install",
"build": "turbo build",
"prelint": "pnpm run build",
"lint": "eslint",
"lint:fix": "eslint --fix",
"prettier": "prettier --check '**/*.{json,yaml,yml,md,ts,tsx,js,jsx}'",
"prettier:fix": "prettier --write '**/*.{json,yaml,yml,md,ts,tsx,js,jsx}'",
"markdownlint": "markdownlint '**/*.md' '#.changeset' '#**/CHANGELOG.md'",
"markdownlint:fix": "markdownlint --fix '**/*.md' '#.changeset' '#**/CHANGELOG.md'",
"test": "turbo run test",
"release": "changeset publish"
},
"lint-staged": {
"**/*.{json,yaml,md,ts,tsx,js,jsx}": "prettier --check",
"**/*.{ts,tsx,js,jsx}": "eslint",
"**/*.{css,scss}": "stylelint"
"test": "turbo test",
"test:watch": "turbo test:watch",
"release": "pnpm build && changeset publish",
"release:canary": "pnpm build && changeset publish --tag canary"
},
"devDependencies": {
"@babel/preset-react": "^7.24.7",
"@changesets/cli": "^2.26.2",
"@naverpay/eslint-config": "workspace:*",
"@naverpay/eslint-plugin": "workspace:*",
"@naverpay/markdown-lint": "workspace:*",
"@naverpay/prettier-config": "workspace:*",
"@naverpay/stylelint-config": "workspace:*",
"glob": "^9.3.4",
"husky": "^8.0.3",
"jest": "^29.5.0",
"lint-staged": "^15.0.1",
"lefthook": "^1.9.3",
"prettier": "^3.2.5",
"turbo": "^1.10.16",
"turbo": "^2.3.3",
"typescript": "^5.2.2"
},
"packageManager": "pnpm@9.1.3",
Expand Down
2 changes: 0 additions & 2 deletions packages/editorconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"version": "0.0.4",
"description": "editorconfig for naverpay",
"scripts": {
"version": "pnpm version",
"deploy": "pnpm publish",
"postinstall": "node index.js"
},
"author": "@NaverPayDev/frontend",
Expand Down
51 changes: 32 additions & 19 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@

네이버페이 스타일 가이드에 맞게 lint rule을 커스텀하여 제공합니다.

## 설치 방법
## 사용 방법

```bash
npm install @naverpay/eslint-config -D
```

## 사용 방법
프로젝트 환경에 알맞는 config를 import해 사용합니다.

프로젝트 환경에 알맞는 config를 extend 합니다.
- `node` - JS로 작성된 node 환경에서 사용
- `typescript` - TS로 작성된 환경에서 사용
[Note: `@typescript-eslint` 룰 중 일부는 `yaml`룰과 충돌할 수 있으니 유의하시기 바랍니다.](https://github.com/NaverPayDev/code-style/commit/948890376bb250d975e50d5f82e418a3eb50bb7c#diff-d6e0200228324b775c1bd5390161c9d64f8a4581b542d5e93463abe457cd73caR6-R15)
- `react` - TS로 작성된 react17+ 환경에서 사용
- `strict` - 보다 엄격한 룰을 원하는 환경에서 위 config와 함께 사용

- **@naverpay/eslint-config/front**
- JS로 작성된 react17+ 환경에서 사용합니다.
- **@naverpay/eslint-config/node**
- JS로 작성된 node 환경에서 사용합니다.
- **@naverpay/eslint-config/typescript**
- TS로 작성된 react17+ 환경에서 사용합니다.
- **@naverpay/eslint-config/typescript/next**
- TS로 작성된 Next12+ 환경에서 사용합니다.
예시 `eslint.config.js`

```jsonc
// .eslintrc
{
"extends": ["@naverpay/eslint-config/typescript"]
}
```js
import naverpay from '@naverpay/eslint-config'

export default [
{
ignores: ['**/dist/**'],
},
...naverpay.configs.node,
...naverpay.configs.typescript,
...naverpay.configs.strict,
]
```

## CLI
Expand All @@ -36,13 +39,13 @@ package.json에 스크립트를 추가하여 lint 검사를 할 수 있습니다
// package.json
{
"scripts": {
"lint": "eslint '**/*.{js,jsx,ts,tsx}'",
"lint:fix": "eslint '**/*.{js,jsx,ts,tsx}' --fix",
"lint": "eslint '**/*.{js,jsx,ts,tsx,yaml,yml}'",
"lint:fix": "eslint '**/*.{js,jsx,ts,tsx,yaml,yml}' --fix",
}
}
```

> [husky](https://github.com/typicode/husky) & [lint-staged](https://github.com/lint-staged/lint-staged)를 사용해서 commit 또는 push 전에 스타일 확인을 자동화할 것을 권장합니다.
> [lefthook](https://github.com/evilmartians/lefthook)을 사용해서 commit 또는 push 전에 스타일 확인을 자동화할 것을 권장합니다.

## Integrating with IDE

Expand All @@ -64,6 +67,16 @@ package.json에 스크립트를 추가하여 lint 검사를 할 수 있습니다
}
```

#### Typescript

만약 typescript 를 사용 중이라면 아래의 설정을 활성화해주세요.

```json
{
"typescript.preferences.preferTypeOnlyAutoImports": true
}
```

### WebStorm

Settings > Language > JavaScript > Code Quality > ESLint > Automatic ESLint configuration 을 설정합니다.
12 changes: 4 additions & 8 deletions packages/eslint-config/custom/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const importOrder = ({ruleSeverities = 'error', pathGroups = []} = {}) => [
import {commonBaseRules, commonExcludes} from './typescript/naming-convention.js'

export const importOrder = ({ruleSeverities = 'error', pathGroups = []} = {}) => [
ruleSeverities,
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index', 'type'], // 그룹간 require/import 순서
Expand All @@ -24,8 +26,7 @@ const importOrder = ({ruleSeverities = 'error', pathGroups = []} = {}) => [
},
]

const {commonBaseRules, commonExcludes} = require('./typescript/naming-convention')
const typescriptNamingConvention = ({
export const typescriptNamingConvention = ({
ruleSeverities = 'warn',
customRules = [],
baseRules = commonBaseRules,
Expand All @@ -52,8 +53,3 @@ const typescriptNamingConvention = ({

return [ruleSeverities, ...rules]
}

module.exports = {
importOrder,
typescriptNamingConvention,
}
10 changes: 3 additions & 7 deletions packages/eslint-config/custom/typescript/naming-convention.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const commonExcludes = ['_*', '__html', 'Component']
const commonBaseRules = [
export const commonExcludes = ['_*', '__html', 'Component']

export const commonBaseRules = [
{
selector: 'default',
format: ['camelCase'],
Expand Down Expand Up @@ -66,8 +67,3 @@ const commonBaseRules = [
modifiers: ['requiresQuotes'],
},
]

module.exports = {
commonExcludes,
commonBaseRules,
}
Loading
Loading