npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-model-contract-checker

v0.2.0

Published

Statically analyze Vue codebase to enforce v-model contract (no regular props for model props)

Readme

vue-model-contract-checker

Statically analyze a Vue codebase to ensure v-model contract compliance: any component prop that is part of a v-model contract is used only via v-model / v-model:prop, and never passed as a regular prop.

Inspired by vue-unused-components-checker: whole-project analysis, framework-aware, simple CLI.

Goal

  • Components define a two-way binding contract via defineModel(), or props + emits (update:*).
  • Consumers must use v-model / v-model:prop for those props, not :prop="value".

Installation (monorepo)

From the monorepo root:

yarn install   # if the package was just added (may require lockfile update)

No need to install the package separately; it’s part of the workspace.

Usage (monorepo)

From the monorepo root:

# Check the webapp package only (recommended)
yarn check-vmodel

# Check the whole repo (all packages with .vue files)
yarn check-vmodel:all

From the checker package (paths relative to that package):

cd packages/vue-model-contract-checker
yarn build
yarn test                                      # run tests (fixtures in test/fixtures/)
yarn exec node dist/index.js ../webapp        # webapp only
yarn exec node dist/index.js ../..           # whole repo

CLI options:

yarn check-vmodel -- --output-json           # JSON output
yarn check-vmodel -- --stats                  # component/violation counts
yarn check-vmodel -- --debug                  # print component graph
yarn check-vmodel -- --no-fail-on-error       # don’t exit 1 on violations
yarn check-vmodel -- --show-unresolved        # list each unresolved import (default: only the count)

Configuration

Optional config file at project root: vue-model-contract-checker.config.json

{
  "include": ["src/**/*.vue"],
  "exclude": ["**/node_modules/**", "**/dist/**"],
  "extensions": [".vue"],
  "failOnError": true
}

Alias resolution (TypeScript paths + Vite)

Import aliases are resolved so that component paths match your project:

  1. TypeScript / JavaScript – The checker looks for tsconfig.json or jsconfig.json in the project root. If the root has no compilerOptions.paths, it tries each entry in references until one has paths. Path mappings and baseUrl are used to resolve non-relative .vue imports. JSONC comments are stripped before parsing.

  2. Vite – The checker also reads resolve.alias from vite.config.ts / vite.config.js (or .mjs / .cjs). It parses the config file as text and supports:

    • Object form: alias: { '@': path.join(__dirname, 'src'), '@ds': '@dilitrust/design-system/src' }
    • Array form: alias: [ { find: '@', replacement: '...' } ]
    • Replacement values: string literals, path.resolve/join(__dirname, '...'), fileURLToPath(new URL('...', import.meta.url)), and package-like strings (resolved from node_modules).

Resolution order: relative path → tsconfig paths → Vite alias. Non-relative .vue imports that cannot be resolved are reported as errors.

Violation example

Invalid (prop is a v-model contract):

<MyComp :modelValue="foo" />
<MyComp :title="foo" />

Valid:

<MyComp v-model="foo" />
<MyComp v-model:title="foo" />

To suppress checks for the next component opening (the line immediately below the comment), add a comment that contains vue-model-contract-checker-disable-next-component in the template:

  • Disable all model props for that usage (default):
    <!-- vue-model-contract-checker-disable-next-component -->
  • Disable only listed props (comma-separated, camelCase or kebab-case):
    <!-- vue-model-contract-checker-disable-next-component:visible,title -->

Place the comment on the line directly above the component’s opening tag (multi-line tags are supported).

Output format

CLI:

[vue-model-contract-checker]

src/components/Parent.vue:12:10
❌ MyComp → prop "title" is a v-model contract
   Use "v-model:title" instead of ":title"

JSON (--output-json): object with violations and unresolvedImports arrays. Unresolved alias imports (no tsconfig path mapping) appear in unresolvedImports.

Architecture

  • File Scanner – discovers .vue files (include/exclude globs).
  • SFC Parser@vue/compiler-sfc to extract template and script.
  • Model extraction – from defineModel(), defineModel('name'), defineEmits(['update:...']).
  • Component Registry – path → ComponentInfo (imports, modelProps).
  • Template Analyzer@vue/compiler-dom to parse template; for each component usage, flag :prop when prop is in modelProps.
  • Reporter – CLI and optional JSON output.

Scope (MVP)

  • Component resolution via relative imports and via TypeScript paths (tsconfig/jsconfig paths + baseUrl).
  • Unknown components (e.g. from node_modules) are ignored.

Optional features (future)

  • --fix: rewrite :prop="x" to v-model:prop="x" where safe.
  • More emit patterns (e.g. Options API emits: ['update:modelValue']).

License

MIT