Skip to content

Commit

Permalink
chore: configure ESLint (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogyuchi authored Mar 30, 2024
1 parent 2be714a commit fc9645d
Show file tree
Hide file tree
Showing 8 changed files with 822 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/maintain-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ permissions:
contents: read

jobs:
lint:
name: Lint
ci:
name: ci
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -35,6 +35,8 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies

- name: Check format
run: pnpm format:check
- name: Lint
run: pnpm lint
- name: Check types
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

echo "$FILES" | xargs ./node_modules/.bin/eslint --no-warn-ignored

echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write \
&& echo "$FILES" | xargs git add
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["esbenp.prettier-vscode", "EditorConfig.EditorConfig"]
"recommendations": [
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig",
"dbaeumer.vscode-eslint"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"eslint.experimental.useFlatConfig": true
}
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// @ts-check

import eslint from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
ignores: ['cli-incremental-info', 'coverage', 'dist/*'],
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
eslintConfigPrettier,
{
languageOptions: {
ecmaVersion: 2023,
globals: {
...globals.node,
},
parserOptions: {
allowAutomaticSingleRunInference: true,
cacheLifetime: {
glob: 'Infinity',
},
project: ['tsconfig.json', 'tsconfig.*.json'],
},
},
},
{
// TODO
rules: {
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'no-unsafe-finally': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'prefer-const': 'off',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
},
},
)
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"build:debug": "swc --source-maps=true src --out-dir=dist",
"build:debug:watch": "swc --watch --source-maps=true src --out-dir=dist",
"format": "prettier --write .",
"lint": "prettier --check .",
"format:check": "prettier --check .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"check:types": "tsc",
"prepare": "node .husky/install.mjs"
},
Expand Down Expand Up @@ -39,10 +41,14 @@
"@types/node": "20.12.2",
"chokidar": "3.6.0",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"globals": "15.0.0",
"husky": "9.0.11",
"npm-run-all2": "6.1.2",
"prettier": "3.2.5",
"typescript": "5.4.3"
"typescript": "5.4.3",
"typescript-eslint": "7.4.0"
},
"author": "kazukazu123123",
"license": "MIT",
Expand Down
Loading

0 comments on commit fc9645d

Please sign in to comment.