@markuplint/ml-config 3.3.0 → 3.4.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.
package/lib/types.d.ts CHANGED
@@ -2,92 +2,96 @@ import type { ParserOptions } from '@markuplint/ml-ast';
2
2
  import type { RegexSelector } from '@markuplint/selector';
3
3
  export type { RegexSelector } from '@markuplint/selector';
4
4
  export interface Config {
5
- $schema?: string;
6
- extends?: string | string[];
7
- plugins?: (PluginConfig | string)[];
8
- parser?: ParserConfig;
9
- parserOptions?: ParserOptions;
10
- specs?: SpecConfig;
11
- excludeFiles?: string[];
12
- pretenders?: Pretender[];
13
- rules?: Rules;
14
- nodeRules?: NodeRule[];
15
- childNodeRules?: ChildNodeRule[];
16
- overrides?: Record<string, Omit<Config, '$schema' | 'extends' | 'overrides'>>;
5
+ $schema?: string;
6
+ extends?: string | string[];
7
+ plugins?: (PluginConfig | string)[];
8
+ parser?: ParserConfig;
9
+ parserOptions?: ParserOptions;
10
+ specs?: SpecConfig;
11
+ excludeFiles?: string[];
12
+ pretenders?: Pretender[];
13
+ rules?: Rules;
14
+ nodeRules?: NodeRule[];
15
+ childNodeRules?: ChildNodeRule[];
16
+ overrides?: Record<string, Omit<Config, '$schema' | 'extends' | 'overrides'>>;
17
17
  }
18
18
  export type PluginConfig = {
19
- name: string;
20
- settings: Record<string, any>;
19
+ name: string;
20
+ settings: Record<string, any>;
21
21
  };
22
22
  export interface ParserConfig {
23
- [extensionPattern: string]: string;
23
+ [extensionPattern: string]: string;
24
24
  }
25
25
  export type SpecConfig = {
26
- [extensionPattern: string]: string;
26
+ [extensionPattern: string]: string;
27
27
  };
28
28
  export type Pretender = {
29
- /**
30
- * Target node selectors
31
- */
32
- selector: string;
33
- /**
34
- * If it is a string, it is resolved as an element name.
35
- * An element has the same attributes as the pretended custom element
36
- * because attributes are just inherited.
37
- *
38
- * If it is an Object, It creates the element by that.
39
- */
40
- as: string | OriginalNode;
29
+ /**
30
+ * Target node selectors
31
+ */
32
+ selector: string;
33
+ /**
34
+ * If it is a string, it is resolved as an element name.
35
+ * An element has the same attributes as the pretended custom element
36
+ * because attributes are just inherited.
37
+ *
38
+ * If it is an Object, It creates the element by that.
39
+ */
40
+ as: string | OriginalNode;
41
41
  };
42
42
  export type OriginalNode = {
43
- /**
44
- * Element name
45
- */
46
- element: string;
47
- /**
48
- * Namespace
49
- *
50
- * Supports `"svg"` and `undefined` only.
51
- * If it is `undefined`, the namespace is HTML.
52
- */
53
- namespace?: 'svg';
54
- /**
55
- * Attributes
56
- */
57
- attrs?: {
58
- /**
59
- * Attribute name
60
- */
61
- name: string;
62
- /**
63
- * If it omits this property, the attribute is resolved as a boolean.
64
- */
65
- value?: string | {
66
- fromAttr: string;
67
- };
68
- }[];
69
- /**
70
- * To have attributes the defined element has.
71
- */
72
- inheritAttrs?: boolean;
73
- /**
74
- * ARIA properties
75
- */
76
- aria?: PretenderARIA;
43
+ /**
44
+ * Element name
45
+ */
46
+ element: string;
47
+ /**
48
+ * Namespace
49
+ *
50
+ * Supports `"svg"` and `undefined` only.
51
+ * If it is `undefined`, the namespace is HTML.
52
+ */
53
+ namespace?: 'svg';
54
+ /**
55
+ * Attributes
56
+ */
57
+ attrs?: {
58
+ /**
59
+ * Attribute name
60
+ */
61
+ name: string;
62
+ /**
63
+ * If it omits this property, the attribute is resolved as a boolean.
64
+ */
65
+ value?:
66
+ | string
67
+ | {
68
+ fromAttr: string;
69
+ };
70
+ }[];
71
+ /**
72
+ * To have attributes the defined element has.
73
+ */
74
+ inheritAttrs?: boolean;
75
+ /**
76
+ * ARIA properties
77
+ */
78
+ aria?: PretenderARIA;
77
79
  };
78
80
  /**
79
81
  * Pretender Node ARIA properties
80
82
  */
81
83
  export type PretenderARIA = {
82
- /**
83
- * Accessible name
84
- *
85
- * - If it is `true`, it assumes the element has any text on its accessible name.
86
- * - If it specifies `fromAttr` property, it assumes the accessible name refers to the value of the attribute.
87
- */
88
- name?: boolean | {
89
- fromAttr: string;
90
- };
84
+ /**
85
+ * Accessible name
86
+ *
87
+ * - If it is `true`, it assumes the element has any text on its accessible name.
88
+ * - If it specifies `fromAttr` property, it assumes the accessible name refers to the value of the attribute.
89
+ */
90
+ name?:
91
+ | boolean
92
+ | {
93
+ fromAttr: string;
94
+ };
91
95
  };
92
96
  export type Rule<T extends RuleConfigValue, O = void> = RuleConfig<T, O> | T | boolean;
93
97
  /**
@@ -100,80 +104,80 @@ export type AnyRule = Rule<RuleConfigValue, unknown>;
100
104
  */
101
105
  export type AnyRuleV2 = RuleV2<RuleConfigValue, unknown>;
102
106
  export interface Rules {
103
- [ruleName: string]: AnyRule;
107
+ [ruleName: string]: AnyRule;
104
108
  }
105
109
  export type RuleConfig<T extends RuleConfigValue, O = void> = {
106
- severity?: Severity;
107
- value?: T;
108
- options?: O;
109
- reason?: string;
110
+ severity?: Severity;
111
+ value?: T;
112
+ options?: O;
113
+ reason?: string;
110
114
  };
111
115
  /**
112
116
  * @deprecated
113
117
  */
114
118
  export type RuleConfigV2<T extends RuleConfigValue, O = void> = {
115
- severity?: Severity;
116
- value?: T;
117
- reason?: string;
118
- /**
119
- * Old property
120
- *
121
- * @deprecated
122
- * @see {this.options}
123
- */
124
- option?: O;
119
+ severity?: Severity;
120
+ value?: T;
121
+ reason?: string;
122
+ /**
123
+ * Old property
124
+ *
125
+ * @deprecated
126
+ * @see {this.options}
127
+ */
128
+ option?: O;
125
129
  };
126
130
  export type Severity = 'error' | 'warning' | 'info';
127
131
  export type RuleConfigValue = string | number | boolean | any[] | null;
128
132
  export interface NodeRule {
129
- selector?: string;
130
- regexSelector?: RegexSelector;
131
- categories?: string[];
132
- roles?: string[];
133
- obsolete?: boolean;
134
- rules?: Rules;
133
+ selector?: string;
134
+ regexSelector?: RegexSelector;
135
+ categories?: string[];
136
+ roles?: string[];
137
+ obsolete?: boolean;
138
+ rules?: Rules;
135
139
  }
136
140
  export interface ChildNodeRule {
137
- selector?: string;
138
- regexSelector?: RegexSelector;
139
- inheritance?: boolean;
140
- rules?: Rules;
141
+ selector?: string;
142
+ regexSelector?: RegexSelector;
143
+ inheritance?: boolean;
144
+ rules?: Rules;
141
145
  }
142
146
  export type Report<T extends RuleConfigValue, O = null> = Report1<T, O> | Report2 | (Report1<T, O> & Report2);
143
147
  export type Report1<T extends RuleConfigValue, O = null> = {
144
- message: string;
145
- scope: Scope<T, O>;
148
+ message: string;
149
+ scope: Scope<T, O>;
146
150
  };
147
151
  export type Report2 = {
148
- message: string;
149
- line: number;
150
- col: number;
151
- raw: string;
152
+ message: string;
153
+ line: number;
154
+ col: number;
155
+ raw: string;
152
156
  };
153
157
  export type Scope<T extends RuleConfigValue, O = null> = {
154
- rule: RuleInfo<T, O>;
155
- startLine: number;
156
- startCol: number;
157
- raw: string;
158
+ rule: RuleInfo<T, O>;
159
+ startLine: number;
160
+ startCol: number;
161
+ raw: string;
158
162
  };
159
163
  export interface Violation {
160
- ruleId: string;
161
- severity: Severity;
162
- message: string;
163
- reason?: string;
164
- line: number;
165
- col: number;
166
- raw: string;
164
+ ruleId: string;
165
+ severity: Severity;
166
+ message: string;
167
+ reason?: string;
168
+ line: number;
169
+ col: number;
170
+ raw: string;
167
171
  }
168
172
  export interface RuleInfo<T extends RuleConfigValue, O = null> {
169
- disabled: boolean;
170
- severity: Severity;
171
- value: T;
172
- options: O;
173
- reason?: string;
173
+ disabled: boolean;
174
+ severity: Severity;
175
+ value: T;
176
+ options: O;
177
+ reason?: string;
174
178
  }
175
179
  export type GlobalRuleInfo<T extends RuleConfigValue, O = null> = RuleInfo<T, O> & {
176
- nodeRules: RuleInfo<T, O>[];
177
- childNodeRules: RuleInfo<T, O>[];
180
+ nodeRules: RuleInfo<T, O>[];
181
+ childNodeRules: RuleInfo<T, O>[];
178
182
  };
179
183
  export type Nullable<T> = T | null | undefined;
package/lib/utils.d.ts CHANGED
@@ -7,8 +7,13 @@ import type { AnyRule, AnyRuleV2, RuleConfig, RuleConfigV2, RuleConfigValue } fr
7
7
  * @param data Captured string for replacement
8
8
  */
9
9
  export declare function provideValue(template: string, data: Record<string, string>): string | undefined;
10
- export declare function exchangeValueOnRule(rule: AnyRule | AnyRuleV2, data: Record<string, string>): AnyRule | undefined;
11
- export declare function cleanOptions(rule: RuleConfig<RuleConfigValue, unknown> | RuleConfigV2<RuleConfigValue, unknown>): RuleConfig<RuleConfigValue, unknown>;
10
+ export declare function exchangeValueOnRule(
11
+ rule: AnyRule | AnyRuleV2,
12
+ data: Record<string, string>,
13
+ ): AnyRule | undefined;
14
+ export declare function cleanOptions(
15
+ rule: RuleConfig<RuleConfigValue, unknown> | RuleConfigV2<RuleConfigValue, unknown>,
16
+ ): RuleConfig<RuleConfigValue, unknown>;
12
17
  export declare function isRuleConfigValue(v: any): v is RuleConfigValue;
13
18
  /**
14
19
  *
package/lib/utils.js CHANGED
@@ -12,8 +12,9 @@ const mustache_1 = tslib_1.__importDefault(require("mustache"));
12
12
  * @param data Captured string for replacement
13
13
  */
14
14
  function provideValue(template, data) {
15
+ var _a;
15
16
  const ast = mustache_1.default.parse(template);
16
- if (ast.length === 1 && ast[0][0] === 'text') {
17
+ if (ast.length === 1 && ((_a = ast[0]) === null || _a === void 0 ? void 0 : _a[0]) === 'text') {
17
18
  // It doesn't have a variable
18
19
  return template;
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-config",
3
- "version": "3.3.0",
3
+ "version": "3.4.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>",
@@ -23,10 +23,10 @@
23
23
  "@types/mustache": "^4.2.2"
24
24
  },
25
25
  "dependencies": {
26
- "@markuplint/selector": "3.3.0",
26
+ "@markuplint/selector": "3.4.0",
27
27
  "deepmerge": "^4.2.2",
28
28
  "is-plain-object": "^5.0.0",
29
29
  "mustache": "^4.2.0"
30
30
  },
31
- "gitHead": "791fb22a4df7acb985ced3808923fba0cd95c28a"
31
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
32
32
  }