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

@basenative/validate

v3.3.0

Published

Structured validation for BaseNative templates — machine-actionable errors a model can repair from the error object alone

Readme

@basenative/validate

Structured validation for BaseNative templates. Every diagnostic is designed to be repairable by a model from the error object alone, with no access to documentation.

import { validateTemplate } from '@basenative/validate';

validateTemplate('<div v-if="isAdmin">…</div>');
// {
//   valid: false,
//   diagnostics: [{
//     code: 'BN_E_FOREIGN_DIRECTIVE',
//     severity: 'error',
//     message: '"v-if" is Vue syntax; BaseNative does not support it — BaseNative puts
//               conditionals on a <template>, not on the element itself',
//     suggestion: '<template @if="isAdmin">',
//     span: { line: 1, col: 6 },
//     confidence: 'high'
//   }]
// }

Pass a context to also check references:

validateTemplate('<p>{{ itmes }}</p>', { context: { items: [] } });
// → BN_E_UNBOUND_REF, suggestion: 'Did you mean "items"? …'

Why this exists

BaseNative's syntax is a hybrid of four ecosystems: {{ }} from Vue/Angular, @for="item of items; track item.id" near-verbatim from Angular 17, :disabled from Vue, signal()/computed()/effect() from Solid. That familiarity makes it trivially readable — and makes the failure mode confident regression to the nearest neighbour. A model under load emits v-if, or Angular's block form, or $state, rather than inventing something novel.

Reading is not writing. This package measures the difference.

Diagnostic codes

| Code | Severity | Catches | |---|---|---| | BN_E_FOREIGN_DIRECTIVE | error | Vue / Angular / Svelte / Alpine syntax, with the BaseNative equivalent | | BN_E_CONTROL_FLOW_ON_ELEMENT | error | @if/@for/@switch on a non-<template> element | | BN_E_UNKNOWN_DIRECTIVE | error | An @-directive BaseNative does not define | | BN_E_EXPR_UNSUPPORTED | error | Expression outside the CSP-safe subset, or blocked prototype access | | BN_E_MALFORMED_FOR | error / warning | @for not matching item of items; missing track warns | | BN_E_ORPHAN_BRANCH | error | @else/@empty/@case/@default with no governing directive | | BN_E_UNBOUND_REF | warning | Reference absent from the supplied context |

BN_E_CONTROL_FLOW_ON_ELEMENT is the one that matters most

On a <template>, @if is control flow. On any other element, every @name attribute is registered as an event listener. So <div @if="admin"> silently binds an "if" event and never renders conditionally — with no runtime error at all. It is the one mistake in the language that is completely invisible without static validation.

Severity contract

valid is false only when at least one error-severity diagnostic is present.

The validator never reports as an error something the runtime accepts. @for without track renders fine (it forfeits keyed reconciliation), so it warns rather than fails — a validator that disagrees with the thing it validates is worse than no validator.

Design notes

Expression checking imports compileExpression from @basenative/runtime/shared/expression — the same parser the evaluator uses. A second, independent expression parser would drift from the runtime, which is precisely the class of bug this package exists to catch.

The markup scanner is deliberately not a DOM parser: a DOM parse discards byte offsets, normalises casing, and silently repairs malformed markup — which is exactly the input we are here to complain about.

License

Apache-2.0