-
Notifications
You must be signed in to change notification settings - Fork 411
Expand file tree
/
Copy pathloadOptions.ts
More file actions
37 lines (32 loc) · 883 Bytes
/
loadOptions.ts
File metadata and controls
37 lines (32 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import cosmiconfig from 'cosmiconfig';
import type { StrictOptions } from '../types';
export type PluginOptions = StrictOptions & {
configFile?: string;
};
const explorer = cosmiconfig('linaria');
export default function loadOptions(
overrides: Partial<PluginOptions> = {}
): Partial<StrictOptions> {
const { configFile, ignore, ...rest } = overrides;
const result =
configFile !== undefined
? explorer.loadSync(configFile)
: explorer.searchSync();
return {
displayName: false,
evaluate: true,
rules: [
{
action: require('../evaluators/shaker').default,
},
{
// The old `ignore` option is used as a default value for `ignore` rule.
test: ignore ?? /\/node_modules\//,
action: 'ignore',
},
],
injectStyleTags: false,
...(result ? result.config : null),
...rest,
};
}