TypeScript: make vite config files strict TS compliant (#6121)

This commit is contained in:
Matiss Janis Aboltins
2025-11-12 19:32:44 +00:00
committed by GitHub
parent d0f02c7272
commit f23bcaa9d5
5 changed files with 25 additions and 25 deletions

View File

@@ -1,15 +1,15 @@
import globals from 'globals'; import tsParser from '@typescript-eslint/parser';
import { defineConfig } from 'eslint/config'; import { defineConfig } from 'eslint/config';
import pluginImport from 'eslint-plugin-import'; import pluginImport from 'eslint-plugin-import';
import pluginJSXA11y from 'eslint-plugin-jsx-a11y'; import pluginJSXA11y from 'eslint-plugin-jsx-a11y';
import pluginReact from 'eslint-plugin-react'; import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks'; import pluginReactHooks from 'eslint-plugin-react-hooks';
import pluginTypescript from 'typescript-eslint';
import pluginTypescriptPaths from 'eslint-plugin-typescript-paths'; import pluginTypescriptPaths from 'eslint-plugin-typescript-paths';
import pluginActual from './packages/eslint-plugin-actual/lib/index.js'; import globals from 'globals';
import pluginTypescript from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser'; // eslint-disable-next-line import/extensions
import pluginActual from './packages/eslint-plugin-actual/lib/index.js';
const confusingBrowserGlobals = [ const confusingBrowserGlobals = [
// https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals // https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals
@@ -80,35 +80,28 @@ export default defineConfig(
'packages/api/app/bundle.api.js', 'packages/api/app/bundle.api.js',
'packages/api/app/stats.json', 'packages/api/app/stats.json',
'packages/api/dist',
'packages/api/@types', 'packages/api/@types',
'packages/api/migrations', 'packages/api/migrations',
'packages/crdt/dist',
'packages/component-library/src/icons/**/*', 'packages/component-library/src/icons/**/*',
'packages/desktop-client/bundle.browser.js', 'packages/desktop-client/bundle.browser.js',
'packages/desktop-client/build/',
'packages/desktop-client/dev-dist/', 'packages/desktop-client/dev-dist/',
'packages/desktop-client/service-worker/*', 'packages/desktop-client/service-worker/*',
'packages/desktop-client/build-electron/', 'packages/desktop-client/build-electron/',
'packages/desktop-client/build-stats/', 'packages/desktop-client/build-stats/',
'packages/desktop-client/public/kcab/', 'packages/desktop-client/public/kcab/',
'packages/desktop-client/public/data/', 'packages/desktop-client/public/data/',
'packages/desktop-client/**/node_modules/*',
'packages/desktop-client/node_modules/',
'packages/desktop-client/test-results/', 'packages/desktop-client/test-results/',
'packages/desktop-client/playwright-report/', 'packages/desktop-client/playwright-report/',
'packages/desktop-electron/client-build/', 'packages/desktop-electron/client-build/',
'packages/desktop-electron/build/',
'packages/desktop-electron/dist/',
'packages/loot-core/**/node_modules/*',
'packages/loot-core/**/lib-dist/*', 'packages/loot-core/**/lib-dist/*',
'packages/loot-core/**/proto/*', 'packages/loot-core/**/proto/*',
'packages/sync-server/build/',
'packages/sync-server/user-files/', 'packages/sync-server/user-files/',
'packages/sync-server/server-files/', 'packages/sync-server/server-files/',
'packages/plugins-service/dist/',
'.yarn/*', '.yarn/*',
'.github/*', '.github/*',
'**/build/',
'**/dist/',
'**/node_modules/',
], ],
}, },
{ {
@@ -170,7 +163,7 @@ export default defineConfig(
}, },
}, },
{ {
files: ['**/*.{js,ts,jsx,tsx}'], files: ['**/*.{js,ts,jsx,tsx,mjs,mts}'],
plugins: { plugins: {
'jsx-a11y': pluginJSXA11y, 'jsx-a11y': pluginJSXA11y,
'react-hooks': pluginReactHooks, 'react-hooks': pluginReactHooks,
@@ -716,14 +709,18 @@ export default defineConfig(
// Allow configuring vitest with default exports (recommended as per vitest docs) // Allow configuring vitest with default exports (recommended as per vitest docs)
{ {
files: ['**/vitest.config.ts', '**/vitest.web.config.ts'], files: [
'**/vitest.config.{ts,mts}',
'**/vitest.web.config.ts',
'**/vite.config.{ts,mts}',
'eslint.config.mjs',
],
rules: { rules: {
'import/no-anonymous-default-export': 'off', 'import/no-anonymous-default-export': 'off',
'import/no-default-export': 'off', 'import/no-default-export': 'off',
}, },
}, },
{},
{ {
// TODO: fix the issues in these files // TODO: fix the issues in these files
files: [ files: [

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
import * as path from 'path'; import * as path from 'path';
import inject from '@rollup/plugin-inject'; import inject from '@rollup/plugin-inject';
@@ -6,7 +5,7 @@ import basicSsl from '@vitejs/plugin-basic-ssl';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer'; import { visualizer } from 'rollup-plugin-visualizer';
/// <reference types="vitest" /> /// <reference types="vitest" />
import { defineConfig, loadEnv, Plugin } from 'vite'; import { defineConfig, loadEnv, Plugin, type UserConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import viteTsconfigPaths from 'vite-tsconfig-paths'; import viteTsconfigPaths from 'vite-tsconfig-paths';
@@ -123,7 +122,7 @@ export default defineConfig(async ({ mode }) => {
rollupOptions: { rollupOptions: {
output: { output: {
assetFileNames: assetInfo => { assetFileNames: assetInfo => {
const info = assetInfo.name.split('.'); const info = assetInfo.name?.split('.') ?? [];
let extType = info[info.length - 1]; let extType = info[info.length - 1];
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) { if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img'; extType = 'img';
@@ -222,5 +221,6 @@ export default defineConfig(async ({ mode }) => {
}, },
maxWorkers: 2, maxWorkers: 2,
}, },
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
} satisfies UserConfig & { test: any };
}); });

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
import path from 'path'; import path from 'path';
import { visualizer } from 'rollup-plugin-visualizer'; import { visualizer } from 'rollup-plugin-visualizer';
@@ -7,7 +6,6 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
import peggyLoader from 'vite-plugin-peggy-loader'; import peggyLoader from 'vite-plugin-peggy-loader';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
// eslint-disable-next-line import/no-default-export
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const isDev = mode === 'development'; const isDev = mode === 'development';
const outDir = path.resolve(__dirname, 'lib-dist/browser'); const outDir = path.resolve(__dirname, 'lib-dist/browser');

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
import path from 'path'; import path from 'path';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---
TypeScript: make vite config files strict TS compliant