Skip to main content

Crate vize_patina

Crate vize_patina 

Source
Expand description

§vize_patina

Patina - The quality checker for Vize. Linter for Vue.js Single File Components.

§Name Origin

Patina (/ˈpætɪnə/) refers to the greenish layer that forms on copper, bronze, and similar metals through oxidation over time. In art and antiques, patina is highly valued as it indicates authenticity, age, and quality. vize_patina examines Vue SFC code to ensure its quality and authenticity.

§Features

  • Rich diagnostic output with code snippets and suggestions (like oxlint)
  • eslint-plugin-vue compatible rules
  • LSP-ready design for integration with vize_maestro

§Usage

use vize_patina::{Linter, OutputFormat, format_results};

let linter = Linter::new();
let source = r#"<template><div v-for="item in items">{{ item }}</div></template>"#;
let result = linter.lint_template(source, "test.vue");

if result.has_errors() {
    // Format and display errors
    let output = format_results(&[result], &[(filename.to_string(), source.to_string())], OutputFormat::Text);
    println!("{}", output);
}

§Rules

Currently implemented rules (eslint-plugin-vue compatible):

§Essential Rules

  • vue/require-v-for-key - Require v-bind:key with v-for directives
  • vue/valid-v-for - Enforce valid v-for directives
  • vue/valid-v-if - Enforce valid v-if directives
  • vue/valid-v-else - Enforce valid v-else directives
  • vue/valid-v-bind - Enforce valid v-bind directives
  • vue/valid-v-on - Enforce valid v-on directives
  • vue/valid-v-model - Enforce valid v-model directives
  • vue/valid-v-show - Enforce valid v-show directives
  • vue/no-use-v-if-with-v-for - Disallow using v-if on the same element as v-for
  • vue/no-unused-vars - Disallow unused variable definitions in v-for directives
  • vue/no-duplicate-attributes - Disallow duplicate attributes
  • vue/no-template-key - Disallow key attribute on <template>
  • vue/no-textarea-mustache - Disallow mustache interpolation in <textarea>
  • vue/no-dupe-v-else-if - Disallow duplicate conditions in v-if chains
  • vue/no-reserved-component-names - Disallow reserved component names
  • vue/no-template-shadow - Disallow variable shadowing in v-for
  • vue/no-multi-spaces - Disallow multiple consecutive spaces
  • vue/v-bind-style - Enforce v-bind directive style (shorthand or longform)
  • vue/v-on-style - Enforce v-on directive style (shorthand or longform)

§Vapor Migration Rules (based on Vue 3.6.0-beta.1)

Template rules:

  • vapor/no-vue-lifecycle-events - Disallow @vue:xxx per-element lifecycle events
  • vapor/no-suspense - Warn about Suspense in Vapor-only apps
  • vapor/prefer-static-class - Prefer static class over dynamic binding
  • vapor/no-inline-template - Disallow deprecated inline-template

Script rules (enabled by opinionated / nuxt presets, or opt-in manually):

  • script/no-options-api - Disallow Options API patterns (Vapor is Composition-only)
  • script/no-get-current-instance - Disallow getCurrentInstance() (returns null in Vapor)
  • script/no-next-tick - Disallow nextTick() scheduling in Vapor-oriented code

§Musea Rules (for *.art.vue files)

  • musea/require-title - Require title attribute in <art> block
  • musea/require-component - Require component attribute in <art> block
  • musea/valid-variant - Require name attribute in <variant> blocks
  • musea/no-empty-variant - Disallow empty variant blocks
  • musea/unique-variant-names - Require unique variant names
  • musea/prefer-design-tokens - Prefer design token CSS variables over hardcoded primitive values

§Script Rules (manual opt-in, default off unless a built-in preset enables them)

  • script/prefer-import-from-vue - Prefer importing from ‘vue’ instead of internal packages
  • script/no-internal-imports - Disallow importing from Vue internal modules

Re-exports§

pub use output::format_results;
pub use output::format_summary;
pub use output::OutputFormat;
pub use telegraph::Emitter;
pub use telegraph::JsonEmitter;
pub use telegraph::LspDiagnostic;
pub use telegraph::LspEmitter;
pub use telegraph::Telegraph;
pub use telegraph::TextEmitter;

Modules§

output
Output formatters for lint diagnostics.
rules
Lint rules for Vue.js SFC files.
telegraph
Telegraph - The message delivery system for lint results.

Structs§

BuiltinScriptRuleMeta
Fix
A fix for a diagnostic, containing one or more text edits.
LintContext
Lint context provides utilities for rules during execution.
LintDiagnostic
A lint diagnostic with rich information for display.
LintResult
Lint result for a single file.
LintSummary
Summary of lint results.
Linter
Main linter struct.
RuleMeta
Rule metadata
RuleRegistry
Registry holding all enabled lint rules
TextEdit
A text edit for auto-fixing a diagnostic.

Enums§

HelpLevel
Help display level for diagnostics.
HelpRenderTarget
Render target for help text conversion at output boundaries.
LintPreset
Named lint presets exposed across Rust, CLI, and bindings.
Locale
Supported locales
RuleCategory
Rule category for organization
Severity
Lint diagnostic severity.

Traits§

Rule
Rule trait for implementing lint rules

Functions§

builtin_script_rules
lint
Lint a Vue template source with default rules
render_help
Render help text (raw markdown) for the given target.