Skip to content

Commit 8501c85

Browse files
committed
[migrate] upgrade to ESLint 9 & other latest Upstream packages
[optimize] some detail configuration
1 parent bdc14b6 commit 8501c85

File tree

10 files changed

+995
-718
lines changed

10 files changed

+995
-718
lines changed

.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/deploy-production.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Pick Docker Compose
4545
run: |
4646
mkdir ./build
47-
mv ${{ env.ARTIFACT_PATH }} ./docker-compose.yml ./start.sh ./build
47+
mv ${{ env.ARTIFACT_PATH }} ./.env ./docker-compose.yml ./start.sh ./build
4848
4949
- name: Transport Image
5050
uses: appleboy/[email protected]
@@ -65,9 +65,9 @@ jobs:
6565
username: ${{ secrets.USER }}
6666
password: ${{ secrets.SSH_KEY }}
6767
command: |
68-
mkdir -p ~/${{ env.BOX_NAME }}
6968
cd /tmp/${{ env.BOX_NAME }}
70-
mv docker-compose.yml start.sh ~/${{ env.BOX_NAME }}
69+
mkdir -p ~/${{ env.BOX_NAME }}
70+
mv .env docker-compose.yml start.sh ~/${{ env.BOX_NAME }}
7171
cd ~/${{ env.BOX_NAME }}
7272
chmod +x start.sh
7373
echo '${{ secrets.SSH_KEY }}' | sudo -S ./start.sh /tmp/${{ env.BOX_NAME }}/${{ env.ARTIFACT_PATH }}

eslint.config.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// @ts-check
2+
import eslint from '@eslint/js';
3+
import { currentModulePath } from '@tech_query/node-toolkit';
4+
import eslintConfigPrettier from 'eslint-config-prettier';
5+
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
6+
import globals from 'globals';
7+
import tsEslint from 'typescript-eslint';
8+
9+
const tsconfigRootDir = currentModulePath();
10+
11+
export default tsEslint.config(
12+
// register all of the plugins up-front
13+
{
14+
plugins: {
15+
'@typescript-eslint': tsEslint.plugin,
16+
'simple-import-sort': simpleImportSortPlugin
17+
}
18+
},
19+
// config with just ignores is the replacement for `.eslintignore`
20+
{ ignores: ['**/node_modules/**', '**/dist/**', 'type/**', '*.mjs'] },
21+
22+
// extends ...
23+
eslint.configs.recommended,
24+
...tsEslint.configs.recommended,
25+
26+
// base config
27+
{
28+
languageOptions: {
29+
globals: { ...globals.es2022, ...globals.node },
30+
parserOptions: {
31+
projectService: true,
32+
tsconfigRootDir,
33+
warnOnUnsupportedTypeScriptVersion: false
34+
}
35+
},
36+
rules: {
37+
'simple-import-sort/exports': 'error',
38+
'simple-import-sort/imports': 'error',
39+
'@typescript-eslint/no-unused-vars': 'warn',
40+
'@typescript-eslint/no-empty-object-type': 'off',
41+
'@typescript-eslint/no-unsafe-declaration-merging': 'warn'
42+
}
43+
},
44+
{
45+
files: ['**/*.js'],
46+
extends: [tsEslint.configs.disableTypeChecked],
47+
rules: {
48+
// turn off other type-aware rules
49+
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
50+
51+
// turn off rules that don't apply to JS code
52+
'@typescript-eslint/explicit-function-return-type': 'off'
53+
}
54+
},
55+
eslintConfigPrettier
56+
);

package.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@koa/cors": "^5.0.0",
2222
"@koa/multer": "^3.0.2",
23-
"@koa/router": "^13.0.1",
23+
"@koa/router": "^13.1.0",
2424
"class-transformer": "^0.5.1",
2525
"class-validator": "^0.14.1",
2626
"cross-env": "^7.0.3",
@@ -36,38 +36,43 @@
3636
"marked": "^14.1.2",
3737
"mobx-github": "^0.3.4",
3838
"mobx-restful": "^1.0.1",
39-
"pg": "^8.12.0",
40-
"pg-connection-string": "^2.6.4",
39+
"pg": "^8.13.0",
40+
"pg-connection-string": "^2.7.0",
4141
"reflect-metadata": "^0.2.2",
4242
"routing-controllers": "^0.10.4",
4343
"routing-controllers-openapi": "^4.0.0",
4444
"tslib": "^2.7.0",
45-
"typeorm": "npm:@helveg/typeorm@^0.3.20",
46-
"undici": "^6.19.8",
47-
"web-utility": "^4.4.0"
45+
"typeorm": "npm:@helveg/typeorm@^0.3.21",
46+
"undici": "^6.20.1",
47+
"web-utility": "^4.4.1"
4848
},
4949
"devDependencies": {
50+
"@eslint/js": "^9.12.0",
5051
"@octokit/openapi-types": "^22.2.0",
52+
"@tech_query/node-toolkit": "^2.0.0-alpha.0",
53+
"@types/eslint-config-prettier": "^6.11.3",
54+
"@types/eslint__js": "^8.42.3",
5155
"@types/jest": "^29.5.13",
52-
"@types/jsonwebtoken": "^9.0.6",
56+
"@types/jsonwebtoken": "^9.0.7",
5357
"@types/koa": "^2.15.0",
5458
"@types/koa-logger": "^3.1.5",
55-
"@types/node": "^20.16.5",
56-
"@typescript-eslint/eslint-plugin": "^8.5.0",
57-
"@typescript-eslint/parser": "^8.5.0",
58-
"eslint": "^8.57.0",
59+
"@types/node": "^20.16.11",
60+
"eslint": "^9.12.0",
61+
"eslint-config-prettier": "^9.1.0",
5962
"eslint-plugin-simple-import-sort": "^12.1.1",
63+
"globals": "^15.11.0",
6064
"husky": "^9.1.6",
6165
"jest": "^29.7.0",
6266
"koajax": "^3.0.2",
6367
"lint-staged": "^15.2.10",
6468
"prettier": "^3.3.3",
6569
"sqlite3": "^5.1.7",
66-
"start-server-and-test": "^2.0.7",
70+
"start-server-and-test": "^2.0.8",
6771
"swagger-typescript-api": "^13.0.22",
6872
"ts-jest": "^29.2.5",
6973
"ts-node": "^10.9.2",
70-
"typescript": "~5.6.2"
74+
"typescript": "~5.6.3",
75+
"typescript-eslint": "^8.9.0"
7176
},
7277
"resolutions": {
7378
"native-file-system-adapter": "npm:@tech_query/native-file-system-adapter@^3.0.1"
@@ -79,7 +84,8 @@
7984
"tabWidth": 4
8085
},
8186
"lint-staged": {
82-
"*.{md,json,yml,ts}": "prettier --write"
87+
"*.{md,json,yml,mjs,ts}": "prettier --write",
88+
"*.ts": "eslint --fix"
8389
},
8490
"jest": {
8591
"preset": "ts-jest"

0 commit comments

Comments
 (0)