45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
// @ts-check
|
|
import withNuxt from './.nuxt/eslint.config.mjs'
|
|
import tseslint from 'typescript-eslint'
|
|
import * as pluginVue from 'eslint-plugin-vue'
|
|
|
|
// NOTE: eslint-plugin-tailwindcss does not support Tailwind CSS 4 yet.
|
|
// When v4 support lands, we can enable it back.
|
|
|
|
// Base Nuxt config
|
|
const baseConfig = withNuxt()
|
|
|
|
// Add ban on Cyrillic in code (use only i18n keys)
|
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
const hardcodedI18nGuard = [
|
|
{
|
|
name: 'no-cyrillic-hardcode',
|
|
files: ['app/**/*.{ts,tsx,vue}', 'modules/**/*.{ts,tsx,vue}', 'server/**/*.{ts,tsx}'],
|
|
plugins: {
|
|
vue: pluginVue,
|
|
},
|
|
languageOptions: {
|
|
parser: tseslint.parser,
|
|
parserOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
},
|
|
},
|
|
rules: {
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: "Literal[value][typeof value === 'string'][/\\p{Script=Cyrillic}/u.test(value)]",
|
|
message: 'Use i18n keys instead of hardcoded Russian text',
|
|
},
|
|
{
|
|
selector: "TemplateElement[value.raw][/\\p{Script=Cyrillic}/u.test(value.raw)]",
|
|
message: 'Use i18n keys instead of hardcoded Russian text',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
export default [...baseConfig, ...hardcodedI18nGuard]
|