diff --git a/src/create-define-rules/create-define-rules.test.ts b/src/create-define-rules/create-define-rules.test.ts index 0518740..aed47cf 100644 --- a/src/create-define-rules/create-define-rules.test.ts +++ b/src/create-define-rules/create-define-rules.test.ts @@ -32,8 +32,8 @@ describe(createDefineRules, () => { expectTypeOf(rules['@morev/sass/no-unused-variables']).toEqualTypeOf<[ true, { - checkRoot: true; - ignore: ['b']; + readonly checkRoot: true; + readonly ignore: readonly ['b']; }, ]>(); }); @@ -48,7 +48,7 @@ describe(createDefineRules, () => { expectTypeOf().toEqualTypeOf<'@morev/sass/no-unused-variables'>(); expectTypeOf(rules['@morev/sass/no-unused-variables']).toEqualTypeOf<[ true, - { checkRoot: true }, + { readonly checkRoot: true }, ]>(); }); @@ -65,9 +65,9 @@ describe(createDefineRules, () => { expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[ true, { - firstChild: true; - severity: 'warning'; - separators: undefined; + readonly firstChild: true; + readonly severity: 'warning'; + readonly separators: undefined; }, ]>(); }); @@ -86,8 +86,8 @@ describe(createDefineRules, () => { expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[ true, { - firstChild: true; - separators: { + readonly firstChild: true; + readonly separators: { readonly element: '__'; }; }, @@ -118,8 +118,8 @@ describe(createDefineRules, () => { expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[ true, { - firstChild: true; - separators: typeof separators; + readonly firstChild: true; + readonly separators: typeof separators; }, ]>(); }); @@ -141,8 +141,8 @@ describe(createDefineRules, () => { expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[ true, { - firstChild: true; - separators: undefined; + readonly firstChild: true; + readonly separators: undefined; }, ]>(); }); diff --git a/src/create-define-rules/create-define-rules.types.ts b/src/create-define-rules/create-define-rules.types.ts index d35b5d0..ccbd3be 100644 --- a/src/create-define-rules/create-define-rules.types.ts +++ b/src/create-define-rules/create-define-rules.types.ts @@ -1,4 +1,4 @@ -import type { ReadonlyDeep, Simplify, WritableDeep } from 'type-fest'; +import type { ReadonlyDeep, Simplify } from 'type-fest'; import type { PluginGlobals, RulesSchema } from '#modules/meta'; import type { RuleWithSeparators } from './create-define-rules'; @@ -63,15 +63,15 @@ type GlobalSeparators = * Secondary options after runtime normalization. * * Rules that consume BEM separators receive separators from plugin globals; - * all other rules keep their secondary options as writable output objects. + * all other rules keep their inferred secondary options. */ type NormalizedRuleOptions< RuleName, Secondary, Globals extends PluginGlobals, > = RuleName extends RuleWithSeparators - ? Simplify, 'separators'> & { separators: GlobalSeparators }> - : WritableDeep; + ? Simplify & { readonly separators: GlobalSeparators }> + : Secondary; /** * Normalized two-item rule tuple returned by `defineRules`.