Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/create-define-rules/create-define-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
},
]>();
});
Expand All @@ -48,7 +48,7 @@ describe(createDefineRules, () => {
expectTypeOf<keyof typeof rules>().toEqualTypeOf<'@morev/sass/no-unused-variables'>();
expectTypeOf(rules['@morev/sass/no-unused-variables']).toEqualTypeOf<[
true,
{ checkRoot: true },
{ readonly checkRoot: true },
]>();
});

Expand All @@ -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;
},
]>();
});
Expand All @@ -86,8 +86,8 @@ describe(createDefineRules, () => {
expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[
true,
{
firstChild: true;
separators: {
readonly firstChild: true;
readonly separators: {
readonly element: '__';
};
},
Expand Down Expand Up @@ -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;
},
]>();
});
Expand All @@ -141,8 +141,8 @@ describe(createDefineRules, () => {
expectTypeOf(rules['@morev/bem/block-variable']).toEqualTypeOf<[
true,
{
firstChild: true;
separators: undefined;
readonly firstChild: true;
readonly separators: undefined;
},
]>();
});
Expand Down
8 changes: 4 additions & 4 deletions src/create-define-rules/create-define-rules.types.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -63,15 +63,15 @@ type GlobalSeparators<Globals extends PluginGlobals> =
* 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<Omit<WritableDeep<Secondary>, 'separators'> & { separators: GlobalSeparators<Globals> }>
: WritableDeep<Secondary>;
? Simplify<Omit<Secondary, 'separators'> & { readonly separators: GlobalSeparators<Globals> }>
: Secondary;

/**
* Normalized two-item rule tuple returned by `defineRules`.
Expand Down
Loading