Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Declare RTLCSSPlugin and rename the property of `PluginOptionsNorma…
…lized`
  • Loading branch information
aleen42 authored and elchininet committed May 21, 2024
commit 81834d3cf61ebb3eb994dabaa4366da052e523f7
12 changes: 11 additions & 1 deletion src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export interface PluginStringMap {
replace: strings;
}

export type RTLCSSPlugin = {
name: string;
priority: number;
directives: {
control: Object,
value: Array<Object>
};
}

export interface DeclarationPluginProcessor {
expr: RegExp;
action: (prop: string, value: string, context: object) => object;
Expand Down Expand Up @@ -72,8 +81,9 @@ export interface PluginOptions {
processDeclarationPlugins?: DeclarationPlugin[];
}

export interface PluginOptionsNormalized extends Omit<Required<PluginOptions>, 'stringMap' | 'prefixSelectorTransformer'> {
export interface PluginOptionsNormalized extends Omit<Required<PluginOptions>, 'stringMap' | 'processDeclarationPlugins' | 'prefixSelectorTransformer'> {
stringMap: StringMap[];
plugins: RTLCSSPlugin[];
prefixSelectorTransformer: PrefixSelectorTransformer | null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/data/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const defaultOptions = (): PluginOptionsNormalized => ({
stringMap: getRTLCSSStringMap(defaultStringMap),
greedy: false,
aliases: {},
processDeclarationPlugins: []
plugins: []
});

const store: Store = {
Expand Down Expand Up @@ -232,7 +232,7 @@ const normalizeOptions = (options: PluginOptions): PluginOptionsNormalized => {
});
}
if (isAcceptedProcessDeclarationPlugins(options.processDeclarationPlugins)) {
returnOptions.processDeclarationPlugins = options.processDeclarationPlugins.map(plugin => ({
returnOptions.plugins = options.processDeclarationPlugins.map(plugin => ({
...plugin, directives: {control: {}, value: []},
}));
}
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const parseDeclarations = (
stringMap,
greedy,
aliases,
processDeclarationPlugins
plugins
} = store.options;

const deleteDeclarations: Declaration[] = [];
Expand Down Expand Up @@ -161,7 +161,7 @@ export const parseDeclarations = (
stringMap,
greedy,
aliases
}, processDeclarationPlugins);
}, plugins);

/* the source could be undefined in certain cases but not during the tests */
/* istanbul ignore next */
Expand Down