Skip to content

Commit efc67a8

Browse files
committed
migrate to TS
1 parent e4ab5d4 commit efc67a8

7 files changed

Lines changed: 164 additions & 30 deletions

File tree

eslint.config.js

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,94 @@
1-
import globals from 'globals'
2-
import typescriptLint from 'typescript-eslint';
3-
import pluginVue from 'eslint-plugin-vue'
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
import pluginVue from 'eslint-plugin-vue';
5+
import prettierConfig from 'eslint-config-prettier';
46

5-
export default typescriptLint.config({
6-
files: [
7-
'src/**/*.{ts,vue,js,tsx,jsx}'
8-
],
7+
/** @type {import('eslint').Linter.Config[]} */
8+
export default tseslint.config(
9+
{
10+
ignores: [
11+
'**/dist/**',
12+
'**/node_modules/**',
13+
'**/public/**',
14+
'src/sitemap/sitemap.js',
15+
'src/env.d.ts',
16+
],
17+
},
18+
19+
...pluginVue.configs['flat/recommended'],
920

10-
extends: [
11-
...typescriptLint.configs.recommended,
12-
...pluginVue.configs['flat/recommended'],
13-
],
21+
/**
22+
* The TypeScript lint settings
23+
*/
24+
{
25+
files: ['**/*.ts', '**/*.tsx'],
26+
extends: [
27+
...tseslint.configs.recommendedTypeChecked,
28+
...tseslint.configs.stylisticTypeChecked,
29+
],
30+
languageOptions: {
31+
parserOptions: {
32+
projectService: true,
33+
tsconfigRootDir: import.meta.dirname,
34+
},
35+
},
36+
},
37+
38+
/**
39+
* These are the Vue lint settings
40+
*/
41+
{
42+
files: ['**/*.vue'],
43+
plugins: {
44+
vue: pluginVue,
45+
},
46+
languageOptions: {
47+
parser: pluginVue.parser,
48+
parserOptions: {
49+
parser: tseslint.parser,
50+
extraFileExtensions: ['.vue'],
51+
sourceType: 'module',
52+
}
53+
},
54+
},
1455

15-
rules: {
16-
// override/add rules settings here, such as:
17-
// 'vue/no-unused-vars': 'error'
56+
/**
57+
* The global variables and language options
58+
*/
59+
{
60+
languageOptions: {
61+
globals: {
62+
...globals.browser,
63+
...globals.node,
64+
},
65+
},
1866
},
19-
languageOptions: {
20-
sourceType: 'module',
21-
globals: {
22-
...globals.browser
23-
}
67+
{
68+
rules: {
69+
'vue/no-v-html': [
70+
'error',
71+
{
72+
ignorePattern: '^sanitizedHtml',
73+
},
74+
],
75+
// '@typescript-eslint/no-explicit-any': 'warn',
76+
// 'no-unused-vars': 'off',
77+
// '@typescript-eslint/no-unused-vars': [
78+
// 'warn',
79+
// {
80+
// argsIgnorePattern: '^_',
81+
// varsIgnorePattern: '^_',
82+
// },
83+
// ],
84+
// '@typescript-eslint/no-unsafe-assignment': 'warn',
85+
// '@typescript-eslint/no-unsafe-member-access': 'warn',
86+
// '@typescript-eslint/no-unsafe-call': 'warn',
87+
// '@typescript-eslint/no-unsafe-return': 'warn',
88+
// '@typescript-eslint/no-floating-promises': 'warn',
89+
// '@typescript-eslint/await-thenable': 'warn',
90+
// '@typescript-eslint/no-unsafe-argument': 'warn',
91+
}
2492
},
25-
})
93+
prettierConfig,
94+
);

jsconfig.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88
"build": "vite build",
99
"preview": "vite preview --host",
1010
"test:unit": "vitest",
11-
"lint": "eslint",
11+
"lint": "eslint -c eslint.config.js",
12+
"lint:fix": "eslint -c eslint.config.js --fix",
1213
"format": "prettier --write src/",
1314
"prebuild": "npm run build-sitemap",
1415
"build-sitemap": "node src/sitemap/sitemap.js"
1516
},
1617
"dependencies": {
1718
"front-matter": "^4.0.2",
1819
"prismjs": "^1.30.0",
19-
"typescript-eslint": "^8.54.0",
2020
"vite-plugin-prismjs": "^0.0.11",
2121
"vue": "^3.5.27",
2222
"vue-router": "^5.0.2",
2323
"xml": "^1.0.1"
2424
},
2525
"devDependencies": {
26+
"typescript-eslint": "^8.54.0",
2627
"@iconify/vue": "^5.0.0",
2728
"@tailwindcss/postcss": "^4.1.18",
2829
"@types/prismjs": "^1.26.5",

tsconfig.app.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ESNext",
6+
"useDefineForClassFields": true,
7+
"module": "ESNext",
8+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
9+
"skipLibCheck": true,
10+
11+
/* Bundler mode */
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"moduleDetection": "force",
17+
"noEmit": true,
18+
"jsx": "preserve",
19+
"jsxImportSource": "vue",
20+
"allowJs": true,
21+
22+
/* Linting */
23+
"strict": true,
24+
"noUnusedLocals": true,
25+
"noUnusedParameters": true,
26+
"noFallthroughCasesInSwitch": true,
27+
28+
"baseUrl": ".",
29+
"paths": {
30+
"@/*": ["./src/*"],
31+
"@blog/*": ["./blog/*"],
32+
"@public/*": ["./public/*"]
33+
}
34+
},
35+
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx", "src/**/*.vue", "src/**/*.d.ts"]
36+
}

tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files": [],
3+
"references": [
4+
{ "path": "./tsconfig.app.json" },
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.vitest.json" }
7+
]
8+
}

tsconfig.node.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
5+
"skipLibCheck": true,
6+
"module": "ESNext",
7+
"moduleResolution": "bundler",
8+
"allowSyntheticDefaultImports": true,
9+
"strict": true,
10+
"noEmit": true,
11+
"allowJs": true
12+
},
13+
"include": [
14+
"vite.config.js",
15+
"vitest.config.js",
16+
"eslint.config.js",
17+
"postcss.config.js"
18+
]
19+
}

tsconfig.vitest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.app.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"lib": ["ESNext", "DOM"],
6+
"types": ["node", "vitest"]
7+
},
8+
"include": ["src/**/*.spec.ts", "src/**/*.test.ts"]
9+
}

0 commit comments

Comments
 (0)