diff --git a/.oxlintrc.json b/.oxlintrc.json index fb5d00dab..36eef37a9 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -60,11 +60,6 @@ { "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()`" } ] } diff --git a/eslint.config.ts b/eslint.config.ts index 4974637fa..8dc7da5a5 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -279,5 +279,46 @@ export default defineConfig([ 'import-x/no-duplicates': 'off', 'import-x/consistent-type-specifier-style': 'off' } + }, + + // i18n import enforcement + // Vue components must use the useI18n() composable, not the global t/d/st/te + { + files: ['**/*.vue'], + rules: { + 'no-restricted-imports': [ + 'warn', + { + paths: [ + { + name: '@/i18n', + importNames: ['t', 'd', 'st', 'te'], + message: + "In Vue components, use `const { t } = useI18n()` instead of importing from '@/i18n'." + } + ] + } + ] + } + }, + // Non-composable .ts files must use the global t/d/st/te, not useI18n() + { + files: ['**/*.ts'], + ignores: ['**/use[A-Z]*.ts', '**/*.test.ts', 'src/i18n.ts'], + rules: { + 'no-restricted-imports': [ + 'warn', + { + paths: [ + { + name: 'vue-i18n', + importNames: ['useI18n'], + message: + "useI18n() requires Vue setup context. Use `import { t } from '@/i18n'` instead." + } + ] + } + ] + } } ])