Skip to content

Commit

Permalink
feat: expose @intlify/vue-i18n/no-raw-text options to consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Nov 26, 2024
1 parent 5a24fe3 commit 4e37ff6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
11 changes: 8 additions & 3 deletions src/configs/vue-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export async function vueI18n(options: OptionsHasTypeScript & OptionsIsInEditor
ignores = [],
isInEditor = false,
localesDirectory = 'locales',
noRawTextIgnores = {
nodes: ['md-icon', 'v-icon', 'vicon'],
pattern: '^[-#:()&/+=!.]+$',
text: ['EUR', 'HKD', 'USD'],
},
overrides = {},
src = 'src',
version = 9,
Expand Down Expand Up @@ -80,9 +85,9 @@ export async function vueI18n(options: OptionsHasTypeScript & OptionsIsInEditor
'@intlify/vue-i18n/no-raw-text': [
isInEditor ? 'warn' : 'error',
{
ignoreNodes: ['md-icon', 'v-icon', 'vicon'],
ignorePattern: '^[-#:()&/+=!.]+$',
ignoreText: ['EUR', 'HKD', 'USD'],
ignoreNodes: noRawTextIgnores.nodes,
ignorePattern: noRawTextIgnores.pattern,
ignoreText: noRawTextIgnores.text,
},
],
'@intlify/vue-i18n/no-unused-keys': [
Expand Down
20 changes: 11 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import type { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
import type { ParserOptions } from '@typescript-eslint/parser';
import type { Options as VueBlocksOptions } from 'eslint-processor-vue-blocks';
import type { Linter } from 'eslint';
import type {
RuleConfig,
} from '@antfu/eslint-define-config';
import type { ConfigNames, RuleOptions } from './typegen';
import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin';

export type WrapRuleConfig<T extends { [key: string]: any }> = {
[K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>
};

export type Awaitable<T> = T | Promise<T>;

export type Rules = RuleOptions;
Expand All @@ -29,8 +22,7 @@ export type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>
plugins?: Record<string, any>;
};

export type OptionsTypescript =
(OptionsTypeScriptWithTypes & OptionsOverrides)
export type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides)
| (OptionsTypeScriptParserOptions & OptionsOverrides);

export interface OptionsFormatters {
Expand Down Expand Up @@ -107,6 +99,12 @@ export interface OptionsCypress extends OptionsOverrides {
testDirectory?: string;
}

interface VueI18nNoRawTextIgnores {
nodes?: string[];
pattern?: string;
text?: string[];
}

export interface OptionsVueI18n extends OptionsOverrides {

/**
Expand All @@ -129,6 +127,10 @@ export interface OptionsVueI18n extends OptionsOverrides {
* @default 9
*/
version?: 8 | 9;
/**
* Optional configuration for @intlify/vue-i18n/no-raw-text rule
*/
noRawTextIgnores?: VueI18nNoRawTextIgnores;
}

export interface OptionsOverrides {
Expand Down

0 comments on commit 4e37ff6

Please sign in to comment.