Skip to content

Commit

Permalink
chore: update eslint and prettier (#2993)
Browse files Browse the repository at this point in the history
* chore: update eslint and prettier

* fix: lint errors

* fix

* fix
  • Loading branch information
kazupon authored Jun 26, 2024
1 parent 755bdd2 commit 7930a27
Show file tree
Hide file tree
Showing 39 changed files with 387 additions and 291 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup develoment
run: pnpm dev:prepare

- name: Linting
run: pnpm lint

Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ coverage
.nuxt
.output
docs/content
.vscode/settings.json
.vscode/settings.json
pnpm-lock.yaml
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.useFlatConfig": true
}
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ pnpm i

Note: This project is using `pnpm`.

- Setup type generation

```sh
pnpm dev:prepare
```

- Create a new branch for your changes:

```sh
git checkout -b my-new-feature
```

- Code, code, code!
- Run ESLint and Vitest
- Run ESLint, Prettier and Vitest

```sh
pnpm fix
pnpm test:unit
pnpm test:e2e
pnpm lint # lint and format check
pnpm fix # auto fix for lint and format
pnpm test:unit # unit tests
pnpm test:spec # e2e tests
```

- Commit and push your changes
Expand Down
71 changes: 51 additions & 20 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
import globals from 'globals'
import tseslint from 'typescript-eslint'
import js from '@eslint/js'
import ts from 'typescript-eslint'
import eslintConfigPrettier from 'eslint-config-prettier'

/**
* @typedef {import("eslint").Linter.FlatConfig[]} FlatConfigs
*/

/** @type { FlatConfigs } */
export default [
// Ignores
// ignores
{
ignores: [
'.eslintcache/**',
'dist/**',
'playground/**',
'specs/fixtures/**',
'specs/utils/**',
'test/fixtures/**',
'coverage/**',
'src/runtime/templates/**',
'docs/**'
]
ignores: ['.nuxt', 'dist', 'playground', 'specs', 'test/fixtures', 'coverage', 'src/runtime/templates/**', 'docs']
},

// Globals
// for global and envrionment
{
files: ['**/*.js', '**/*.ts', '**/*.vue', '**/*.json'],
languageOptions: {
globals: globals.node,
parserOptions: { sourceType: 'module' }
globals: {
...globals.node,
...globals.browser
}
}
},

// Extends
...tseslint.configs.recommended,
// eslint built-in
js.configs.recommended,

// typescript-eslint
...ts.configs.recommendedTypeChecked,
{
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
languageOptions: {
parser: ts.parser,
parserOptions: {
sourceType: 'module',
project: true,
tsconfigRootDir: import.meta.dirname
}
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
]
}
},
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
...ts.configs.disableTypeChecked
},

// prettier
eslintConfigPrettier,

// Rules
// override rules
{
rules: { '@typescript-eslint/ban-ts-comment': 'off' }
}
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@
"docs:build": "nuxi build docs",
"docs:generate": "nuxi generate docs",
"docs:preview": "nuxi preview docs",
"fix": "run-p lint:fix format:fix",
"format": "prettier --config .prettierrc.mjs --ignore-path .prettierignore --list-different '**/*.{js,json,html,md}'",
"format:fix": "pnpm format --write",
"lint": "eslint . --cache",
"lint:fix": "pnpm lint --fix",
"fix": "run-s \"fix:*\"",
"fix:prettier": "prettier . --write",
"fix:eslint": "pnpm lint:eslint --fix",
"lint": "run-p \"lint:* {@}\" --",
"lint:prettier": "prettier . --check",
"lint:eslint": "eslint .",
"test": "pnpm dev:prepare && run-s test:types test:unit test:spec",
"test:types": "tsc --noEmit --project tsconfig.test.json",
"test:unit": "vitest run test",
Expand Down Expand Up @@ -108,15 +109,17 @@
"@babel/parser": "^7.24.7",
"@babel/plugin-syntax-import-assertions": "^7.24.7",
"@babel/types": "^7.24.7",
"@eslint/js": "9.5.0",
"@nuxt/module-builder": "^0.6.0",
"@nuxt/schema": "^3.10.3",
"@types/debug": "^4.1.9",
"@types/eslint": "^8.56.6",
"@unhead/vue": "^1.8.8",
"bumpp": "^9.4.1",
"changelogithub": "^0.13.7",
"consola": "^3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint": "^9.5.0",
"eslint-config-prettier": "^9.1.0",
"execa": "^9.3.0",
"get-port-please": "^3.1.1",
"gh-changelogen": "^0.2.8",
Expand All @@ -134,7 +137,7 @@
"prettier": "^3.3.2",
"ts-essentials": "^9.4.2",
"typescript": "^5.5.2",
"typescript-eslint": "^7.0.1",
"typescript-eslint": "^7.14.0",
"unbuild": "^2.0.0",
"undici": "^6.19.2",
"unhead": "^1.8.8",
Expand Down
Loading

0 comments on commit 7930a27

Please sign in to comment.