@markuplint/ml-config 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ export function mergeConfig(a, b) {
14
14
  a.rules, b.rules),
15
15
  nodeRules: concatArray(a.nodeRules, b.nodeRules),
16
16
  childNodeRules: concatArray(a.childNodeRules, b.childNodeRules),
17
+ overrideMode: b.overrideMode ?? a.overrideMode,
17
18
  overrides: mergeObject(a.overrides, b.overrides),
18
19
  // delete all
19
20
  extends: undefined,
package/lib/types.d.ts CHANGED
@@ -14,6 +14,7 @@ export type Config = {
14
14
  readonly rules?: Rules;
15
15
  readonly nodeRules?: readonly NodeRule[];
16
16
  readonly childNodeRules?: readonly ChildNodeRule[];
17
+ readonly overrideMode?: 'merge' | 'reset';
17
18
  readonly overrides?: Readonly<Record<string, OverrideConfig>>;
18
19
  };
19
20
  export type PrimitiveScalar = string | number | boolean;
@@ -23,7 +24,7 @@ export type PlainData = Nullable<PrimitiveScalar> | readonly PlainData[] | {
23
24
  export type NonNullablePlainData = PrimitiveScalar | readonly NonNullablePlainData[] | {
24
25
  readonly [key: string]: NonNullablePlainData;
25
26
  };
26
- export type OverrideConfig = Omit<Config, '$schema' | 'extends' | 'overrides'>;
27
+ export type OverrideConfig = Omit<Config, '$schema' | 'extends' | 'overrideMode' | 'overrides'>;
27
28
  export type PluginConfig = {
28
29
  readonly name: string;
29
30
  readonly settings: Readonly<Record<string, NonNullablePlainData>>;
@@ -34,6 +35,10 @@ export type ParserConfig = {
34
35
  export type SpecConfig = {
35
36
  readonly [extensionPattern: string]: string;
36
37
  };
38
+ export type PretenderFileData = {
39
+ readonly version: string;
40
+ readonly data: readonly Pretender[];
41
+ };
37
42
  export type Pretender = {
38
43
  /**
39
44
  * Target node selectors
@@ -47,12 +52,81 @@ export type Pretender = {
47
52
  * If it is an Object, It creates the element by that.
48
53
  */
49
54
  readonly as: string | OriginalNode;
55
+ /**
56
+ * If it is a string, it is resolved as an element name.
57
+ * An element regards as having the same attributes
58
+ * as the pretended custom element because these are inherited.
59
+ * If it is an Object, It can specify in detail the element's attributes.
60
+ *
61
+ * @experimental
62
+ */
63
+ readonly filePath?: string;
64
+ /**
65
+ * Dynamic scaning
66
+ *
67
+ * @experimental
68
+ */
69
+ readonly scan?: readonly PretenderScanConfig[];
50
70
  };
51
71
  export type OriginalNode = {
52
72
  /**
53
73
  * Element name
54
74
  */
55
75
  readonly element: string;
76
+ /**
77
+ * It should specify slots if the component can define a slot element or children.
78
+ *
79
+ * For example, the following:
80
+ *
81
+ * ```jsx
82
+ * const Component = ({children}) => (
83
+ * <div>
84
+ * <h2>lorem ipsum</h2>
85
+ * <p>{children}</p>
86
+ * </div>
87
+ * );
88
+ * ```
89
+ *
90
+ * In the above case, the `p` element has the `children`,
91
+ * so it specifies the element to this field.
92
+ *
93
+ * Or:
94
+ *
95
+ * ```html
96
+ * <template>
97
+ * <h2>lorem ipsum</h2>
98
+ * <p><span slot="my-text">{children}</span></p>
99
+ * </template>
100
+ * ```
101
+ *
102
+ * It notes that what needs to be specified
103
+ * in this field is not the element with the slot attribute
104
+ * but the element that wraps it.
105
+ *
106
+ * This field accepts an array
107
+ * because a component and a custom element can have multiple slots.
108
+ *
109
+ * If `null`,
110
+ * it means the component **doesn't accept children or doesn't have slots**.
111
+ *
112
+ * ```jsx
113
+ * const Component = (props) => (
114
+ * <img {...props} />
115
+ * );
116
+ * ```
117
+ *
118
+ * If true, it means the component accepts children or has slots,
119
+ * and **the wrapper element and the outermost element are the same**.
120
+ *
121
+ * ```jsx
122
+ * const Component = ({children}) => (
123
+ * <button>{children}</button>
124
+ * );
125
+ * ```
126
+ *
127
+ * @experimental
128
+ */
129
+ readonly slots?: null | true | readonly Slot[];
56
130
  /**
57
131
  * Namespace
58
132
  *
@@ -63,18 +137,7 @@ export type OriginalNode = {
63
137
  /**
64
138
  * Attributes
65
139
  */
66
- readonly attrs?: readonly {
67
- /**
68
- * Attribute name
69
- */
70
- readonly name: string;
71
- /**
72
- * If it omits this property, the attribute is resolved as a boolean.
73
- */
74
- readonly value?: string | {
75
- readonly fromAttr: string;
76
- };
77
- }[];
140
+ readonly attrs?: readonly PretenderAttr[];
78
141
  /**
79
142
  * To have attributes the defined element has.
80
143
  */
@@ -84,6 +147,22 @@ export type OriginalNode = {
84
147
  */
85
148
  readonly aria?: PretenderARIA;
86
149
  };
150
+ /**
151
+ * @experimental
152
+ */
153
+ export type Slot = Omit<OriginalNode, 'slot'>;
154
+ export type PretenderAttr = {
155
+ /**
156
+ * Attribute name
157
+ */
158
+ readonly name: string;
159
+ /**
160
+ * If it omits this property, the attribute is resolved as a boolean.
161
+ */
162
+ readonly value?: string | {
163
+ readonly fromAttr: string;
164
+ };
165
+ };
87
166
  /**
88
167
  * Pretender Node ARIA properties
89
168
  */
@@ -98,6 +177,24 @@ export type PretenderARIA = {
98
177
  readonly fromAttr: string;
99
178
  };
100
179
  };
180
+ /**
181
+ * @experimental
182
+ */
183
+ export type PretenderScanConfig = {
184
+ /**
185
+ * Supporting for Glob format
186
+ */
187
+ readonly files: string;
188
+ readonly type: string;
189
+ readonly options: PretenderScanOptions;
190
+ };
191
+ /**
192
+ * @experimental
193
+ */
194
+ export interface PretenderScanOptions {
195
+ readonly cwd?: string;
196
+ readonly ignoreComponentNames?: readonly string[];
197
+ }
101
198
  export type Rule<T extends RuleConfigValue, O extends PlainData = undefined> = RuleConfig<T, O> | Readonly<T> | boolean;
102
199
  /**
103
200
  * @deprecated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-config",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "JSON Schema and TypeScript types of markuplint configure JSON",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -24,14 +24,14 @@
24
24
  "clean": "tsc --build --clean"
25
25
  },
26
26
  "dependencies": {
27
- "@markuplint/ml-ast": "4.2.0",
28
- "@markuplint/selector": "4.5.0",
29
- "@markuplint/shared": "4.2.0",
27
+ "@markuplint/ml-ast": "4.3.0",
28
+ "@markuplint/selector": "4.6.0",
29
+ "@markuplint/shared": "4.3.0",
30
30
  "@types/mustache": "4.2.5",
31
31
  "deepmerge": "4.3.1",
32
32
  "is-plain-object": "5.0.0",
33
33
  "mustache": "4.2.0",
34
- "type-fest": "4.15.0"
34
+ "type-fest": "4.18.1"
35
35
  },
36
- "gitHead": "d5c8786b0dbbd82cdd89018dd57941d62bbe8d06"
36
+ "gitHead": "b8d7bae9bdcdad63ff79abe21b88be12abde3633"
37
37
  }