diff --git a/browser_tests/tsconfig.json b/browser_tests/tsconfig.json index f600c4a7f..391298333 100644 --- a/browser_tests/tsconfig.json +++ b/browser_tests/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { /* Test files should not be compiled */ "noEmit": true, - // "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "resolveJsonModule": true diff --git a/build/tsconfig.json b/build/tsconfig.json new file mode 100644 index 000000000..1c24810a8 --- /dev/null +++ b/build/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + /* Build scripts configuration */ + "noEmit": true, + "strict": true, + "esModuleInterop": true, + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true + }, + "include": [ + "**/*.ts" + ] +} \ No newline at end of file diff --git a/eslint.config.ts b/eslint.config.ts index 04f4b2578..ab3bf09f5 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -33,7 +33,13 @@ export default defineConfig([ }, parserOptions: { parser: tseslint.parser, - projectService: true, + projectService: { + allowDefaultProject: [ + 'vite.config.mts', + 'vite.electron.config.mts', + 'vite.types.config.mts' + ] + }, tsConfigRootDir: import.meta.dirname, ecmaVersion: 2020, sourceType: 'module', diff --git a/scripts/collect-i18n-node-defs.ts b/scripts/collect-i18n-node-defs.ts index ed443015a..e16740421 100644 --- a/scripts/collect-i18n-node-defs.ts +++ b/scripts/collect-i18n-node-defs.ts @@ -9,9 +9,18 @@ import { normalizeI18nKey } from '../src/utils/formatUtil' const localePath = './src/locales/en/main.json' const nodeDefsPath = './src/locales/en/nodeDefs.json' +interface WidgetInfo { + name?: string + label?: string +} + +interface WidgetLabels { + [key: string]: Record +} + test('collect-i18n-node-defs', async ({ comfyPage }) => { // Mock view route - comfyPage.page.route('**/view**', async (route) => { + await comfyPage.page.route('**/view**', async (route) => { await route.fulfill({ body: JSON.stringify({}) }) @@ -20,6 +29,7 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => { const nodeDefs: ComfyNodeDefImpl[] = ( Object.values( await comfyPage.page.evaluate(async () => { + // @ts-expect-error - app is dynamically added to window const api = window['app'].api as ComfyApi return await api.getNodeDefs() }) @@ -52,7 +62,7 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => { ) async function extractWidgetLabels() { - const nodeLabels = {} + const nodeLabels: WidgetLabels = {} for (const nodeDef of nodeDefs) { const inputNames = Object.values(nodeDef.inputs).map( @@ -65,12 +75,15 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => { const widgetsMappings = await comfyPage.page.evaluate( (args) => { const [nodeName, displayName, inputNames] = args + // @ts-expect-error - LiteGraph is dynamically added to window const node = window['LiteGraph'].createNode(nodeName, displayName) if (!node.widgets?.length) return {} return Object.fromEntries( node.widgets - .filter((w) => w?.name && !inputNames.includes(w.name)) - .map((w) => [w.name, w.label]) + .filter( + (w: WidgetInfo) => w?.name && !inputNames.includes(w.name) + ) + .map((w: WidgetInfo) => [w.name, w.label]) ) }, [nodeDef.name, nodeDef.display_name, inputNames] diff --git a/scripts/diff-i18n.ts b/scripts/diff-i18n.ts index 331333367..7b4ff8da1 100644 --- a/scripts/diff-i18n.ts +++ b/scripts/diff-i18n.ts @@ -72,7 +72,7 @@ function capture(srcLocaleDir: string, tempBaseDir: string) { const relativePath = file.replace(srcLocaleDir, '') const targetPath = join(tempBaseDir, relativePath) ensureDir(dirname(targetPath)) - writeFileSync(targetPath, readFileSync(file)) + writeFileSync(targetPath, readFileSync(file, 'utf8')) } console.log('Captured current locale files to temp/base/') } diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 000000000..789e142b8 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + /* Script files configuration */ + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true + }, + "include": [ + "**/*.ts" + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 97346f56e..75926b943 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,5 @@ "src/**/*", "src/types/**/*.d.ts", "tests-ui/**/*", - "vite.config.mts", - "vitest.config.ts", ] } diff --git a/vite.electron.config.mts b/vite.electron.config.mts index 88413e38f..8ec68a64f 100644 --- a/vite.electron.config.mts +++ b/vite.electron.config.mts @@ -1,5 +1,5 @@ -import { Plugin, defineConfig } from 'vite' -import { mergeConfig } from 'vite' +import { defineConfig, mergeConfig } from 'vite' +import type { Plugin } from 'vite' import baseConfig from './vite.config.mts'