Skip to content

Commit 733d17e

Browse files
committed
chore: fix lint config and globals
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 637d92c commit 733d17e

6 files changed

Lines changed: 43 additions & 9 deletions

File tree

env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
declare module '*.vue' {
44
import type { DefineComponent } from 'vue'
5-
const component: DefineComponent<{}, {}, any>
5+
const component: DefineComponent<Record<string, never>, Record<string, never>, unknown>
66
export default component
77
}

eslint.config.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: AGPL-3.0-or-later
33

44
const js = require('@eslint/js')
5+
const globals = require('globals')
56
const vue = require('eslint-plugin-vue')
67
const tsPlugin = require('@typescript-eslint/eslint-plugin')
78
const tsParser = require('@typescript-eslint/parser')
@@ -22,18 +23,22 @@ const vitestGlobals = {
2223

2324
module.exports = [
2425
{
25-
ignores: ['dist/**', 'dist-demo/**', 'node_modules/**'],
26+
ignores: ['dist/**', 'dist-demo/**', 'node_modules/**', '.eslintrc.js'],
2627
},
2728
js.configs.recommended,
2829
{
29-
files: ['**/*.{js,ts,vue}'],
30+
files: ['**/*.{ts,vue}'],
3031
languageOptions: {
3132
parser: vueParser,
3233
parserOptions: {
3334
parser: tsParser,
3435
ecmaVersion: 2021,
3536
sourceType: 'module',
3637
},
38+
globals: {
39+
...globals.browser,
40+
...globals.es2021,
41+
},
3742
},
3843
plugins: {
3944
vue,
@@ -42,17 +47,45 @@ module.exports = [
4247
rules: {
4348
...vue.configs['flat/essential'].rules,
4449
...tsPlugin.configs.recommended.rules,
50+
'no-undef': 'off',
51+
'@typescript-eslint/no-explicit-any': 'off',
4552
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
4653
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
4754
},
4855
},
56+
{
57+
files: ['eslint.config.js', '**/*.config.js', '**/*.config.cjs', 'postcss.config.js'],
58+
languageOptions: {
59+
globals: {
60+
...globals.node,
61+
...globals.es2021,
62+
},
63+
sourceType: 'script',
64+
},
65+
rules: {
66+
'no-undef': 'off',
67+
},
68+
},
69+
{
70+
files: ['vite.config.ts', 'vitest.config.ts'],
71+
languageOptions: {
72+
globals: {
73+
...globals.node,
74+
...globals.es2021,
75+
},
76+
},
77+
},
4978
{
5079
files: ['tests/**/*.ts'],
5180
plugins: {
5281
vitest,
5382
},
5483
languageOptions: {
55-
globals: vitestGlobals,
84+
globals: {
85+
...globals.browser,
86+
...globals.es2021,
87+
...vitestGlobals,
88+
},
5689
},
5790
rules: {
5891
...(vitest.configs?.recommended?.rules || {}),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"eslint": "^9.0.0",
5555
"eslint-plugin-vue": "^10.8.0",
5656
"eslint-plugin-vitest": "^0.5.4",
57+
"globals": "^15.9.0",
5758
"happy-dom": "^20.7.0",
5859
"postcss": "^8.5.6",
5960
"rollup-plugin-visualizer": "^7.0.0",

src/components/PDFElements.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export default defineComponent({
544544
},
545545
546546
getDisplayedPageScale(docIndex, pageIndex) {
547-
this.pageBoundsVersion
547+
void this.pageBoundsVersion
548548
const doc = this.pdfDocuments[docIndex]
549549
if (!doc) return 1
550550
const baseWidth = doc.pageWidths?.[pageIndex] || 0

src/components/PDFPage.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
dynamicScale: this.scale,
2929
isRendering: false,
3030
pendingRender: false,
31-
renderTask: null as any,
31+
renderTask: null as { cancel: () => void; promise: Promise<void> } | null,
3232
}
3333
},
3434
watch: {
@@ -44,7 +44,7 @@ export default defineComponent({
4444
if (this.renderTask) {
4545
try {
4646
this.renderTask.cancel()
47-
} catch (e) {
47+
} catch {
4848
// Ignore render cancellation errors.
4949
}
5050
this.renderTask = null
@@ -76,7 +76,7 @@ export default defineComponent({
7676
if (this.renderTask) {
7777
try {
7878
this.renderTask.cancel()
79-
} catch (e) {
79+
} catch {
8080
// Ignore render cancellation errors.
8181
}
8282
this.renderTask = null

tests/components/PDFElements.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const makeWrapper = () => {
5353

5454
describe('PDFElements business rules', () => {
5555
it('adds object to page with generated id', () => {
56-
const { wrapper, ctx } = makeWrapper()
56+
const { ctx } = makeWrapper()
5757
const doc = makeDoc()
5858
ctx.pdfDocuments = [doc]
5959
ctx.selectedDocIndex = 0

0 commit comments

Comments
 (0)