Registry / testing / knockout-lint

knockout-lint

JSON →
library0.3.5jsnpmunverified

Type checker and linter for Knockout.js view bindings. Version 0.3.5 enables type-checking Knockout data-bind attributes against TypeScript viewmodel definitions. It detects common mistakes in Knockout views (e.g., misspelled bindings, wrong observable usage) and integrates via CLI or build tools. Unlike generic HTML linting, it understands Knockout-specific syntax and viewmodel types. Maintained by the kolint team.

npm install knockout-lint
INSTALL
IMPORT
SIG · KNOCKOUT-LINT
K
knockout-lint
testingjavascriptv0.3.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

knockout-lint CLI
npx knockout-lint view.html
knockout-lint view.html (without npx if not installed globally)
Prefer npx to avoid global install.

Shows how to annotate an HTML view with a TypeScript viewmodel and run the linter via npx.

<!-- view.html --> <!-- ko-import ViewModel from './viewmodel' --> <!-- ko-viewmodel ViewModel --> <div data-bind="text: name"></div> // Run: npx knockout-lint view.html // Expected output (if no errors): // No lint errors found. // If errors: // view.html:3:18 - Binding 'text' expects observable but got string // view.html:4:10 - Unknown binding 'visible'
Debug
Known issues
gotchaThe <!-- ko-import --> and <!-- ko-viewmodel --> comments must be exactly as shown; whitespace matters.
fix
Use the exact syntax: <!-- ko-import ViewModel from './viewmodel' --> and <!-- ko-viewmodel ViewModel -->
affects: >=0.1.0
gotchaThe viewmodel file must be a TypeScript file (.ts) and export the viewmodel type as default.
fix
Export default class or interface in the referenced module.
affects: >=0.1.0
gotchaOnly works with Knockout 3.x bindings; some custom bindings may not be recognized.
fix
Ensure bindings are standard Knockout bindings or update the tool's pattern list.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module './viewmodel'
The path in ko-import is relative but the file does not exist or has wrong extension.
fix
Ensure the viewmodel file exists and the import path is correct (e.g., './viewmodel' for viewmodel.ts).
Error: No default export found in module
The viewmodel module does not have a default export (e.g., export default class ViewModel).
fix
Add a default export to your viewmodel file.
Upgrade
Version history
0.3.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
knockout-lint — npm install knockout-lint · libregistry