Skip to content

Commit d7c9b42

Browse files
committed
chore: update eslint config and fix type errors
1 parent 0c0bfc8 commit d7c9b42

15 files changed

+282
-318
lines changed

e2e/helper.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { JSDOM } from 'jsdom'
22

33
import type { Page } from 'playwright'
44

5-
export async function sleep(delay: number) {
5+
export function sleep(delay: number) {
66
return new Promise(resolve => setTimeout(resolve, delay))
77
}
88

@@ -43,7 +43,7 @@ export async function assetLocaleHead(page: Page, headSelector: string) {
4343
},
4444
[headHandle, localeHeadValue]
4545
)
46-
headHandle?.dispose()
46+
await headHandle?.dispose()
4747
}
4848

4949
export function getDom(html: string) {
@@ -57,10 +57,7 @@ export function getDataFromDom(dom: Document, selector: string) {
5757
)
5858
}
5959

60-
export async function assertLocaleHeadWithDom(
61-
dom: Document,
62-
headSelector: string
63-
) {
60+
export function assertLocaleHeadWithDom(dom: Document, headSelector: string) {
6461
const localeHead = getDataFromDom(dom, headSelector)
6562
const headData = [...localeHead.link, ...localeHead.meta]
6663
for (const head of headData) {

eslint.config.mjs

+40-41
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import globals from 'globals'
22
import js from '@eslint/js'
3-
import { FlatCompat } from '@eslint/eslintrc'
43
import ts from 'typescript-eslint'
5-
import eslintConfigPrettier from 'eslint-config-prettier'
4+
import pritter from 'eslint-config-prettier'
5+
import vue from 'eslint-plugin-vue'
66

7-
const vue = extendVuePlugin('plugin:vue/vue3-recommended', ts.parser)
8-
9-
/** @type { import("eslint").Linter.FlatConfig[] } */
107
export default [
118
// ignore globally
129
{
@@ -24,11 +21,6 @@ export default [
2421
]
2522
},
2623

27-
js.configs.recommended,
28-
...ts.configs.recommended,
29-
eslintConfigPrettier,
30-
...vue,
31-
3224
// globals
3325
{
3426
// files: ['**/*.js', '**/*.ts', '**/*.vue', '**/*.json'],
@@ -45,6 +37,44 @@ export default [
4537
}
4638
},
4739

40+
js.configs.recommended,
41+
42+
//...ts.configs.recommended,
43+
...ts.configs.recommendedTypeChecked,
44+
{
45+
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts', '**/*.vue'],
46+
languageOptions: {
47+
parserOptions: {
48+
project: true,
49+
tsconfigRootDir: import.meta.dirname,
50+
parser: ts.parser,
51+
extraFileExtensions: ['.vue']
52+
}
53+
},
54+
rules: {
55+
'@typescript-eslint/no-unsafe-member-access': 'off',
56+
'@typescript-eslint/no-unsafe-assignment': 'off',
57+
'@typescript-eslint/no-unsafe-call': 'off',
58+
'@typescript-eslint/no-unsafe-argument': 'off',
59+
'@typescript-eslint/no-unsafe-return': 'off',
60+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
61+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
62+
'@typescript-eslint/unbound-method': 'off',
63+
'@typescript-eslint/no-implied-eval': 'off',
64+
'@typescript-eslint/no-redundant-type-constituents': 'off',
65+
'@typescript-eslint/restrict-template-expressions': 'off',
66+
'@typescript-eslint/no-base-to-string': 'off'
67+
}
68+
},
69+
{
70+
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
71+
...ts.configs.disableTypeChecked
72+
},
73+
74+
...vue.configs['flat/recommended'],
75+
76+
pritter,
77+
4878
// custom rules
4979
{
5080
rules: {
@@ -64,34 +94,3 @@ export default [
6494
}
6595
}
6696
]
67-
68-
/**
69-
* extend eslint-plugin-vue with @typescript-eslint/parser
70-
* (NOTE: eslint-plugin-vue flat config WIP currently https://github.com/vuejs/eslint-plugin-vue/issues/1291)
71-
*
72-
* @param { 'plugin:vue/vue3-essential' | 'plugin:vue/vue3-strongly-recommended' | 'plugin:vue/vue3-recommended' } vueConfigPattern
73-
* @param { import("typescript-eslint").Config.parser } tsParser
74-
*
75-
* @return { import("eslint").Linter.FlatConfig[] }
76-
*/
77-
function extendVuePlugin(vueConfigPattern, tsParser) {
78-
const compat = new FlatCompat()
79-
const vuePlugin = compat.extends(vueConfigPattern)
80-
const vueLangOptions = vuePlugin[2]
81-
vueLangOptions.files = [
82-
'**/*.vue',
83-
'**/*.ts',
84-
'**/*.tsx',
85-
'**/*.mts',
86-
'**/*.cts'
87-
]
88-
vueLangOptions.languageOptions = {
89-
// NOTE:
90-
// https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser
91-
parserOptions: {
92-
parser: tsParser
93-
},
94-
ecmaVersion: 'latest'
95-
}
96-
return vuePlugin
97-
}

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"docs:dev": "vitepress dev docs",
4545
"docs:serve": "vitepress serve docs",
4646
"docs:setup": "pnpm build:typed && pnpm docs:apigen",
47+
"eslint:inspector": "npx @eslint/config-inspector",
4748
"example:ssr": "cd examples/ssr/vite && pnpm dev",
4849
"fix": "run-p lint:fix format:fix",
4950
"format:fix": "run-p \"format:prettier --write\" format:package",
@@ -69,7 +70,6 @@
6970
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts"
7071
},
7172
"devDependencies": {
72-
"@eslint/eslintrc": "^3.0.0",
7373
"@eslint/js": "^8.57.0",
7474
"@intlify/core-base": "workspace:*",
7575
"@intlify/message-compiler": "workspace:*",
@@ -81,11 +81,13 @@
8181
"@rollup/plugin-terser": "^0.4.3",
8282
"@secretlint/secretlint-rule-preset-recommend": "^3.1.0",
8383
"@textlint-rule/textlint-rule-no-unmatched-pair": "^2.0.0",
84+
"@types/brotli": "^1.3.4",
85+
"@types/eslint": "^8.56.7",
8486
"@types/js-yaml": "^4.0.5",
8587
"@types/jsdom": "^21.1.1",
88+
"@types/minimist": "^1.2.5",
8689
"@types/node": "^20.11.21",
87-
"@typescript-eslint/eslint-plugin": "^6.5.0",
88-
"@typescript-eslint/parser": "^6.5.0",
90+
"@types/rc": "^1.2.4",
8991
"@vitest/coverage-v8": "^1.3.0",
9092
"api-docs-gen": "^0.4.0",
9193
"benchmark": "^2.1.4",
@@ -95,7 +97,7 @@
9597
"esbuild-register": "^3.5.0",
9698
"eslint": "^8.57.0",
9799
"eslint-config-prettier": "^9.1.0",
98-
"eslint-plugin-vue": "^9.22.0",
100+
"eslint-plugin-vue": "^9.24.0",
99101
"execa": "^5.0.0",
100102
"fixpack": "^4.0.0",
101103
"globals": "^15.0.0",
@@ -114,7 +116,7 @@
114116
"playwright": "^1.34.0",
115117
"prettier": "^3.2.5",
116118
"rc": "^1.2.8",
117-
"rimraf": "^3.0.2",
119+
"rimraf": "^5.0.5",
118120
"rollup": "^3.29.2",
119121
"rollup-plugin-node-builtins": "^2.1.2",
120122
"rollup-plugin-node-globals": "^1.4.0",
@@ -141,7 +143,7 @@
141143
"trash-cli": "^5.0.0",
142144
"tslib": "^2.6.2",
143145
"typescript": "^5.3.3",
144-
"typescript-eslint": "^7.1.0",
146+
"typescript-eslint": "^7.5.0",
145147
"vitepress": "1.0.2",
146148
"vitest": "^1.3.0",
147149
"vue": "3.4.21",

packages/format-explorer/src/App.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ async function compile(
7272
lastSuccessCode =
7373
evalCode.toString() + `\n\n// Check the console for the AST`
7474
lastSuccessfulMap =
75+
// eslint-disable-next-line @typescript-eslint/await-thenable
7576
options.sourceMap && map ? await new SourceMapConsumer(map) : null
7677
lastSuccessfulMap?.computeColumnSpans()
7778
} catch (e: unknown) {
@@ -222,11 +223,7 @@ const onChangeOptions = async (options: CompileOptions) => {
222223
@change-model="onChangeModel"
223224
@ready="onReadyInput"
224225
/>
225-
<Editor
226-
class="output"
227-
:code="genCodes"
228-
@ready="onReadyOutput"
229-
/>
226+
<Editor class="output" :code="genCodes" @ready="onReadyOutput" />
230227
</div>
231228
</div>
232229
</template>

0 commit comments

Comments
 (0)