vize_l0 0.646.0

L0 - the Davinci foundation level: ids, side tables, keys, dumps, diagnostics, passes and facts
Documentation
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
//! Typed per-rule lint options.
//!
//! A handful of lint rules accept project-local configuration so teams can
//! enforce their own architecture and design-system conventions through
//! `vize lint` instead of running a sidecar tool. Options live under
//! `linter.ruleOptions.<rule-name>` and are parsed into typed structs (no
//! untyped `serde_json::Value`) so the schema is discoverable and validation
//! stays strict.

use serde::{Deserialize, Serialize};

use crate::String;

mod attribute_hyphenation;
mod casing;
mod component_registration;
mod content_directives;
mod define_macros_order;
mod html_quotes;
mod html_self_closing;
mod hyphenation;
mod merge;
mod mustache_spacing;
mod no_mutating_props;
mod prop_name_casing;
mod props_destructuring;
mod restrictions;
mod sfc_element_order;
mod strict_boolean;
mod v_bind_style;
mod v_on_event_hyphenation;
mod v_on_style;
mod v_slot_style;
mod valid_v_on;
mod valid_v_slot;

pub use attribute_hyphenation::{AttributeHyphenationConfig, AttributeHyphenationOptions};
pub use casing::{
    ComponentNameInTemplateCasingOptions, CustomEventNameCasing, CustomEventNameCasingOptions,
    TemplateComponentNameCasing,
};
pub use define_macros_order::DefineMacrosOrderOptions;
pub use html_quotes::{HtmlQuoteStyle, HtmlQuotesConfig, HtmlQuotesOptions};
pub use html_self_closing::{
    HtmlSelfClosingHtmlOptions, HtmlSelfClosingOptions, HtmlSelfClosingStyle,
};
pub use hyphenation::HyphenationStyle;
pub use mustache_spacing::MustacheInterpolationSpacingStyle;
pub use no_mutating_props::NoMutatingPropsOptions;
pub use prop_name_casing::{PropNameCasingOptions, PropNameCasingStyle};
pub use props_destructuring::{DefinePropsDestructuringOptions, PropsDestructureMode};
pub use restrictions::{
    MuseaDesignToken, MuseaPreferDesignTokensOptions, NoRestrictedGlobalsOptions,
    NoRestrictedMembersOptions, RestrictedGlobal, RestrictedMember,
};
pub use sfc_element_order::{SfcElementOrderGroup, SfcElementOrderOptions};
pub use strict_boolean::StrictBooleanExpressionsOptions;
pub use v_bind_style::VBindStyle;
pub use v_on_event_hyphenation::{VOnEventHyphenationConfig, VOnEventHyphenationOptions};
pub use v_on_style::VOnStyle;
pub use v_slot_style::{
    VSlotNamedStyle, VSlotStyle, VSlotStyleOptions, VSlotStyleValue, VSlotUniformStyle,
};

/// Per-rule configuration keyed by rule name.
///
/// Only the rules that actually accept options have typed fields; everything
/// else is ignored. The map is intentionally typed (rather than a free-form
/// `Value` bag) so unknown keys are rejected and the JSON schema is precise.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct LintRuleOptions {
    /// Options for `script/no-restricted-globals`.
    #[serde(rename = "script/no-restricted-globals")]
    pub no_restricted_globals: Option<NoRestrictedGlobalsOptions>,
    /// Options for `script/no-restricted-members`.
    #[serde(rename = "script/no-restricted-members")]
    pub no_restricted_members: Option<NoRestrictedMembersOptions>,
}

impl LintRuleOptions {
    /// Whether no rule options are configured.
    #[inline]
    pub fn is_empty(&self) -> bool {
        self.no_restricted_globals.is_none() && self.no_restricted_members.is_none()
    }

    /// Configured deny list for `script/no-restricted-globals` as
    /// `(name, optional message)` pairs. Empty when unconfigured.
    pub fn restricted_globals(&self) -> Vec<(String, Option<String>)> {
        self.no_restricted_globals
            .as_ref()
            .map(|options| {
                options
                    .globals
                    .iter()
                    .map(|global| (global.name.clone(), global.message.clone()))
                    .collect()
            })
            .unwrap_or_default()
    }

    /// Configured deny list for `script/no-restricted-members` as
    /// `(object, property, optional message)` tuples. Empty when unconfigured.
    pub fn restricted_members(&self) -> Vec<(String, String, Option<String>)> {
        self.no_restricted_members
            .as_ref()
            .map(|options| {
                options
                    .members
                    .iter()
                    .map(|member| {
                        (
                            member.object.clone(),
                            member.property.clone(),
                            member.message.clone(),
                        )
                    })
                    .collect()
            })
            .unwrap_or_default()
    }

    /// Apply a later config layer to this option set.
    pub fn merge_from(&mut self, overlay: &Self) {
        if let Some(options) = &overlay.no_restricted_globals {
            self.no_restricted_globals = Some(options.clone());
        }
        if let Some(options) = &overlay.no_restricted_members {
            self.no_restricted_members = Some(options.clone());
        }
    }
}

/// Full typed lint rule options parsed from config.
///
/// This wraps the stable public [`LintRuleOptions`] shape with new config-only
/// options, so existing Rust consumers can still construct `LintRuleOptions`
/// using the previous fields while the CLI and LSP can read newer rule options.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct ConfigLintRuleOptions {
    #[serde(flatten)]
    stable: LintRuleOptions,
    /// Options for `vue/require-component-registration`.
    #[serde(
        rename = "vue/require-component-registration",
        skip_serializing_if = "Option::is_none"
    )]
    require_component_registration: Option<component_registration::ComponentRegistrationOptions>,
    #[serde(
        rename = "html/no-empty-palpable-content",
        skip_serializing_if = "Option::is_none"
    )]
    no_empty_palpable_content: Option<content_directives::ContentDirectivesOptions>,
    #[serde(rename = "type/strict-boolean-expressions")]
    strict_boolean_expressions: Option<StrictBooleanExpressionsOptions>,
    /// Options for `script/define-props-destructuring`.
    #[serde(rename = "script/define-props-destructuring")]
    define_props_destructuring: Option<DefinePropsDestructuringOptions>,
    /// Options for `script/define-macros-order`.
    #[serde(rename = "script/define-macros-order")]
    define_macros_order: Option<DefineMacrosOrderOptions>,
    /// Options for `vue/component-name-in-template-casing`.
    #[serde(rename = "vue/component-name-in-template-casing")]
    component_name_in_template_casing: Option<ComponentNameInTemplateCasingOptions>,
    /// Options for `script/custom-event-name-casing`.
    #[serde(rename = "script/custom-event-name-casing")]
    custom_event_name_casing: Option<CustomEventNameCasingOptions>,
    /// Casing of the component's own declared prop names.
    #[serde(
        rename = "vue/prop-name-casing",
        skip_serializing_if = "Option::is_none"
    )]
    prop_name_casing: Option<PropNameCasingOptions>,
    /// Options for `vue/no-mutating-props`.
    #[serde(rename = "vue/no-mutating-props")]
    no_mutating_props: Option<NoMutatingPropsOptions>,
    /// Options for `vue/sfc-element-order`.
    #[serde(rename = "vue/sfc-element-order")]
    sfc_element_order: Option<SfcElementOrderOptions>,
    /// Options for `vue/html-self-closing`.
    #[serde(rename = "vue/html-self-closing")]
    html_self_closing: Option<HtmlSelfClosingOptions>,
    /// Options for `vue/html-quotes`.
    #[serde(rename = "vue/html-quotes")]
    html_quotes: Option<HtmlQuotesConfig>,
    /// Options for `vue/mustache-interpolation-spacing`.
    #[serde(rename = "vue/mustache-interpolation-spacing")]
    mustache_interpolation_spacing: Option<MustacheInterpolationSpacingStyle>,
    /// Options for `vue/v-on-event-hyphenation`.
    #[serde(rename = "vue/v-on-event-hyphenation")]
    v_on_event_hyphenation: Option<VOnEventHyphenationConfig>,
    /// Options for `vue/v-bind-style`.
    #[serde(rename = "vue/v-bind-style")]
    v_bind_style: Option<VBindStyle>,
    /// Options for `vue/v-on-style`.
    #[serde(rename = "vue/v-on-style")]
    v_on_style: Option<VOnStyle>,
    /// Options for `vue/v-slot-style`.
    #[serde(rename = "vue/v-slot-style")]
    v_slot_style: Option<VSlotStyle>,
    /// Options for `vue/attribute-hyphenation`.
    #[serde(rename = "vue/attribute-hyphenation")]
    attribute_hyphenation: Option<AttributeHyphenationConfig>,
    #[serde(rename = "vue/valid-v-on", skip_serializing_if = "Option::is_none")]
    valid_v_on: Option<valid_v_on::ValidVOnOptions>,
    #[serde(rename = "vue/valid-v-slot", skip_serializing_if = "Option::is_none")]
    valid_v_slot: Option<valid_v_slot::ValidVSlotOptions>,
    /// Options for `musea/prefer-design-tokens`.
    #[serde(rename = "musea/prefer-design-tokens")]
    musea_prefer_design_tokens: Option<MuseaPreferDesignTokensOptions>,
}

impl ConfigLintRuleOptions {
    /// Build full config options from the stable public subset.
    #[inline]
    pub fn from_stable_options(stable: LintRuleOptions) -> Self {
        Self {
            stable,
            ..Self::default()
        }
    }

    /// Configured allowances; options alone do not enable the rule.
    pub fn strict_boolean_expressions(&self) -> Option<StrictBooleanExpressionsOptions> {
        self.strict_boolean_expressions
    }

    /// Stable subset exposed by the original `load_linter_rule_options` API.
    #[inline]
    pub fn stable_options(&self) -> &LintRuleOptions {
        &self.stable
    }

    /// Whether no rule options are configured.
    #[inline]
    pub fn is_empty(&self) -> bool {
        self.strict_boolean_expressions.is_none()
            && self.no_empty_palpable_content.is_none()
            && self.stable.is_empty()
            && self.define_props_destructuring.is_none()
            && self.define_macros_order.is_none()
            && self.component_name_in_template_casing.is_none()
            && self.custom_event_name_casing.is_none()
            && self.prop_name_casing.is_none()
            && self.no_mutating_props.is_none()
            && self.sfc_element_order.is_none()
            && self.html_self_closing.is_none()
            && self.html_quotes.is_none()
            && self.mustache_interpolation_spacing.is_none()
            && self.v_on_event_hyphenation.is_none()
            && self.v_bind_style.is_none()
            && self.v_on_style.is_none()
            && self.v_slot_style.is_none()
            && self.attribute_hyphenation.is_none()
            && self.valid_v_on.is_none()
            && self.valid_v_slot.is_none()
            && self.musea_prefer_design_tokens.is_none()
            && self.require_component_registration.is_none()
    }

    /// Globally registered components permitted by the registration rule.
    pub fn component_registration_globals(&self) -> Option<&[String]> {
        self.require_component_registration
            .as_ref()
            .map(|options| options.globals.as_slice())
    }

    /// Configured deny list for `script/no-restricted-globals`.
    #[inline]
    pub fn restricted_globals(&self) -> Vec<(String, Option<String>)> {
        self.stable.restricted_globals()
    }

    /// Exact bare directive names that supply an element's visible content.
    pub fn palpable_content_directives(&self) -> Option<&[String]> {
        self.no_empty_palpable_content
            .as_ref()
            .map(|options| options.content_directives.as_slice())
    }

    /// Configured deny list for `script/no-restricted-members`.
    #[inline]
    pub fn restricted_members(&self) -> Vec<(String, String, Option<String>)> {
        self.stable.restricted_members()
    }

    /// Configured style for `script/define-props-destructuring`.
    #[inline]
    pub fn define_props_destructuring(&self) -> Option<PropsDestructureMode> {
        self.define_props_destructuring
            .map(|options| options.destructure)
    }

    /// Configured macro order for `script/define-macros-order`.
    #[inline]
    pub fn define_macros_order(&self) -> Option<DefineMacrosOrderOptions> {
        self.define_macros_order.clone()
    }

    /// Configured casing for `vue/component-name-in-template-casing`.
    #[inline]
    pub fn component_name_in_template_casing(&self) -> Option<TemplateComponentNameCasing> {
        self.component_name_in_template_casing
            .as_ref()
            .map(|options| options.casing)
    }

    /// Authored registration scope for component tag casing.
    pub fn component_name_in_template_casing_options(
        &self,
    ) -> Option<&ComponentNameInTemplateCasingOptions> {
        self.component_name_in_template_casing.as_ref()
    }

    /// Configured casing for `script/custom-event-name-casing`.
    #[inline]
    pub fn custom_event_name_casing(&self) -> Option<CustomEventNameCasing> {
        self.custom_event_name_casing
            .as_ref()
            .map(|options| options.casing)
    }

    /// Configured casing for the component's own prop declarations.
    pub fn prop_name_casing(&self) -> Option<PropNameCasingStyle> {
        self.prop_name_casing.map(|options| options.casing)
    }

    /// Configured options for `vue/no-mutating-props`.
    #[inline]
    pub fn no_mutating_props(&self) -> Option<NoMutatingPropsOptions> {
        self.no_mutating_props
    }

    /// Configured block order for `vue/sfc-element-order`.
    #[inline]
    pub fn sfc_element_order(&self) -> Option<SfcElementOrderOptions> {
        self.sfc_element_order.clone()
    }

    /// Configured self-closing style for `vue/html-self-closing`.
    #[inline]
    pub fn html_self_closing(&self) -> Option<HtmlSelfClosingOptions> {
        self.html_self_closing
    }

    /// Configured quote style and escaping policy for `vue/html-quotes`.
    #[inline]
    pub fn html_quotes(&self) -> Option<HtmlQuotesConfig> {
        self.html_quotes
    }

    /// Configured spacing inside Vue mustache interpolations.
    #[inline]
    pub fn mustache_interpolation_spacing(&self) -> Option<MustacheInterpolationSpacingStyle> {
        self.mustache_interpolation_spacing
    }

    /// Configured style for `vue/v-on-event-hyphenation`.
    #[inline]
    pub fn v_on_event_hyphenation(&self) -> Option<HyphenationStyle> {
        self.v_on_event_hyphenation
            .as_ref()
            .map(VOnEventHyphenationConfig::style)
    }

    /// Configured event-name style and literal substring exemptions.
    pub fn v_on_event_hyphenation_options(&self) -> Option<VOnEventHyphenationOptions> {
        self.v_on_event_hyphenation
            .as_ref()
            .map(VOnEventHyphenationConfig::options)
    }

    /// Configured spelling for `vue/v-bind-style`.
    #[inline]
    pub fn v_bind_style(&self) -> Option<VBindStyle> {
        self.v_bind_style
    }

    /// Configured spelling for `vue/v-on-style`.
    #[inline]
    pub fn v_on_style(&self) -> Option<VOnStyle> {
        self.v_on_style
    }

    /// Configured spelling policy for `vue/v-slot-style`.
    #[inline]
    pub fn v_slot_style(&self) -> Option<VSlotStyle> {
        self.v_slot_style
    }

    /// Configured style for `vue/attribute-hyphenation`.
    #[inline]
    pub fn attribute_hyphenation(&self) -> Option<HyphenationStyle> {
        self.attribute_hyphenation
            .as_ref()
            .map(AttributeHyphenationConfig::style)
    }

    /// Additional literal attribute-name substrings; an empty object resets the custom list.
    pub fn attribute_hyphenation_ignore(&self) -> Option<&[String]> {
        self.attribute_hyphenation
            .as_ref()
            .and_then(AttributeHyphenationConfig::ignore)
    }

    /// Exact authored tag exemptions; an empty object resets this custom list.
    pub fn attribute_hyphenation_ignore_tags(&self) -> Option<&[String]> {
        self.attribute_hyphenation
            .as_ref()
            .and_then(AttributeHyphenationConfig::ignore_tags)
    }

    /// Configured design-token primitive values for
    /// `musea/prefer-design-tokens` as `(value, path, tier)` tuples. Empty
    /// when unconfigured.
    pub fn musea_design_tokens(&self) -> Vec<(String, String, String)> {
        self.musea_prefer_design_tokens
            .as_ref()
            .map(|options| {
                options
                    .tokens
                    .iter()
                    .map(|token| (token.value.clone(), token.path.clone(), token.tier.clone()))
                    .collect()
            })
            .unwrap_or_default()
    }
}

#[cfg(test)]
mod tests;