diff --git a/.oxlintrc.json b/.oxlintrc.json index 4160601d9e..276ef5461d 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -2,16 +2,20 @@ "$schema": "./node_modules/oxlint/configuration_schema.json", "ignorePatterns": [ ".i18nrc.cjs", - "components.d.ts", - "lint-staged.config.js", - "vitest.setup.ts", + ".nx/*", "**/vite.config.*.timestamp*", "**/vitest.config.*.timestamp*", + "components.d.ts", + "coverage/*", + "dist/*", "packages/registry-types/src/comfyRegistryTypes.ts", + "playwright-report/*", "src/extensions/core/*", "src/scripts/*", "src/types/generatedManagerTypes.ts", - "src/types/vue-shim.d.ts" + "src/types/vue-shim.d.ts", + "test-results/*", + "vitest.setup.ts" ], "plugins": [ "eslint", @@ -24,9 +28,55 @@ ], "rules": { "no-async-promise-executor": "off", + "no-console": [ + "error", + { + "allow": [ + "warn", + "error" + ] + } + ], "no-control-regex": "off", "no-eval": "off", "no-redeclare": "error", + "no-restricted-imports": [ + "error", + { + "paths": [ + { + "name": "primevue/calendar", + "message": "Calendar is deprecated in PrimeVue 4+. Use DatePicker instead: import DatePicker from 'primevue/datepicker'" + }, + { + "name": "primevue/dropdown", + "message": "Dropdown is deprecated in PrimeVue 4+. Use Select instead: import Select from 'primevue/select'" + }, + { + "name": "primevue/inputswitch", + "message": "InputSwitch is deprecated in PrimeVue 4+. Use ToggleSwitch instead: import ToggleSwitch from 'primevue/toggleswitch'" + }, + { + "name": "primevue/overlaypanel", + "message": "OverlayPanel is deprecated in PrimeVue 4+. Use Popover instead: import Popover from 'primevue/popover'" + }, + { + "name": "primevue/sidebar", + "message": "Sidebar is deprecated in PrimeVue 4+. Use Drawer instead: import Drawer from 'primevue/drawer'" + }, + { + "name": "@/i18n--to-enable", + "importNames": [ + "st", + "t", + "te", + "d" + ], + "message": "Don't import `@/i18n` directly, prefer `useI18n()`" + } + ] + } + ], "no-self-assign": "allow", "no-unused-expressions": "off", "no-unused-private-class-members": "off", @@ -64,5 +114,16 @@ "typescript/no-floating-promises": "error", "vue/no-import-compiler-macros": "error", "vue/no-dupe-keys": "error" - } + }, + "overrides": [ + { + "files": [ + "**/*.{stories,test,spec}.ts", + "**/*.stories.vue" + ], + "rules": { + "no-console": "allow" + } + } + ] } \ No newline at end of file diff --git a/eslint.config.ts b/eslint.config.ts index 394df066d3..69efe4bef6 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -62,16 +62,20 @@ export default defineConfig([ { ignores: [ '.i18nrc.cjs', - 'components.d.ts', - 'lint-staged.config.js', - 'vitest.setup.ts', + '.nx/*', '**/vite.config.*.timestamp*', '**/vitest.config.*.timestamp*', + 'components.d.ts', + 'coverage/*', + 'dist/*', 'packages/registry-types/src/comfyRegistryTypes.ts', + 'playwright-report/*', 'src/extensions/core/*', 'src/scripts/*', 'src/types/generatedManagerTypes.ts', - 'src/types/vue-shim.d.ts' + 'src/types/vue-shim.d.ts', + 'test-results/*', + 'vitest.setup.ts' ] }, { @@ -103,24 +107,17 @@ export default defineConfig([ tseslintConfigs.recommended, // Difference in typecheck on CI vs Local - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Bad types in the plugin pluginVue.configs['flat/recommended'], eslintPluginPrettierRecommended, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Type incompatibility between import-x plugin and ESLint config types storybook.configs['flat/recommended'], - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Type incompatibility between import-x plugin and ESLint config types + // @ts-expect-error Type incompatibility between import-x plugin and ESLint config types importX.flatConfigs.recommended, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Type incompatibility between import-x plugin and ESLint config types + // @ts-expect-error Type incompatibility between import-x plugin and ESLint config types importX.flatConfigs.typescript, { plugins: { 'unused-imports': unusedImports, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Type incompatibility in i18n plugin + // @ts-expect-error Type incompatibility in i18n plugin '@intlify/vue-i18n': pluginI18n }, rules: { @@ -138,7 +135,6 @@ export default defineConfig([ 'import-x/no-useless-path-segments': 'error', 'import-x/no-relative-packages': 'error', 'unused-imports/no-unused-imports': 'error', - 'no-console': ['error', { allow: ['warn', 'error'] }], 'vue/no-v-html': 'off', // Prohibit dark-theme: and dark: prefixes 'vue/no-restricted-class': ['error', '/^dark(-theme)?:/'], @@ -153,39 +149,7 @@ export default defineConfig([ 'vue/no-use-v-else-with-v-for': 'error', 'vue/one-component-per-file': 'error', 'vue/require-default-prop': 'off', // TODO: fix -- this one is very worthwhile - // Restrict deprecated PrimeVue components - 'no-restricted-imports': [ - 'error', - { - paths: [ - { - name: 'primevue/calendar', - message: - 'Calendar is deprecated in PrimeVue 4+. Use DatePicker instead: import DatePicker from "primevue/datepicker"' - }, - { - name: 'primevue/dropdown', - message: - 'Dropdown is deprecated in PrimeVue 4+. Use Select instead: import Select from "primevue/select"' - }, - { - name: 'primevue/inputswitch', - message: - 'InputSwitch is deprecated in PrimeVue 4+. Use ToggleSwitch instead: import ToggleSwitch from "primevue/toggleswitch"' - }, - { - name: 'primevue/overlaypanel', - message: - 'OverlayPanel is deprecated in PrimeVue 4+. Use Popover instead: import Popover from "primevue/popover"' - }, - { - name: 'primevue/sidebar', - message: - 'Sidebar is deprecated in PrimeVue 4+. Use Drawer instead: import Drawer from "primevue/drawer"' - } - ] - } - ], + // i18n rules '@intlify/vue-i18n/no-raw-text': [ 'error', @@ -273,12 +237,6 @@ export default defineConfig([ ] } }, - { - files: ['**/*.{test,spec,stories}.ts', '**/*.stories.vue'], - rules: { - 'no-console': 'off' - } - }, { files: ['scripts/**/*.js'], languageOptions: { diff --git a/lint-staged.config.js b/lint-staged.config.js deleted file mode 100644 index 5283d261ed..0000000000 --- a/lint-staged.config.js +++ /dev/null @@ -1,17 +0,0 @@ -export default { - './**/*.js': (stagedFiles) => formatAndEslint(stagedFiles), - - './**/*.{ts,tsx,vue,mts}': (stagedFiles) => [ - ...formatAndEslint(stagedFiles), - 'pnpm typecheck' - ] -} - -function formatAndEslint(fileNames) { - // Convert absolute paths to relative paths for better ESLint resolution - const relativePaths = fileNames.map((f) => f.replace(process.cwd() + '/', '')) - return [ - `pnpm exec eslint --cache --fix ${relativePaths.join(' ')}`, - `pnpm exec prettier --cache --write ${relativePaths.join(' ')}` - ] -} diff --git a/lint-staged.config.ts b/lint-staged.config.ts new file mode 100644 index 0000000000..89deaa4b0e --- /dev/null +++ b/lint-staged.config.ts @@ -0,0 +1,21 @@ +import path from 'node:path' + +export default { + './**/*.js': (stagedFiles: string[]) => formatAndEslint(stagedFiles), + + './**/*.{ts,tsx,vue,mts}': (stagedFiles: string[]) => [ + ...formatAndEslint(stagedFiles), + 'pnpm typecheck' + ] +} + +function formatAndEslint(fileNames: string[]) { + // Convert absolute paths to relative paths for better ESLint resolution + const relativePaths = fileNames.map((f) => path.relative(process.cwd(), f)) + const joinedPaths = relativePaths.map((p) => `"${p}"`).join(' ') + return [ + `pnpm exec prettier --cache --write ${joinedPaths}`, + `pnpm exec oxlint --fix ${joinedPaths}`, + `pnpm exec eslint --cache --fix --no-warn-ignored ${joinedPaths}` + ] +} diff --git a/src/i18n.ts b/src/i18n.ts index 3ef845ed16..4f09619f65 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -197,6 +197,7 @@ export const i18n = createI18n({ }) /** Convenience shorthand: i18n.global */ +/** @deprecated use useI18n */ export const { t, te, d } = i18n.global /** @@ -204,7 +205,8 @@ export const { t, te, d } = i18n.global * * @param key - The key to translate. * @param fallbackMessage - The fallback message to use if the key is not found. + * @deprecated Remove, use the defaultMsg overload */ export function st(key: string, fallbackMessage: string) { - return te(key) ? t(key) : fallbackMessage + return t(key, fallbackMessage) } diff --git a/src/workbench/extensions/manager/components/manager/registrySearchBar/SearchFilterDropdown.vue b/src/workbench/extensions/manager/components/manager/registrySearchBar/SearchFilterDropdown.vue index e076e0cafb..973820c728 100644 --- a/src/workbench/extensions/manager/components/manager/registrySearchBar/SearchFilterDropdown.vue +++ b/src/workbench/extensions/manager/components/manager/registrySearchBar/SearchFilterDropdown.vue @@ -19,7 +19,7 @@