This repository was archived by the owner on Sep 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Martin Skogevall edited this page Feb 1, 2022
·
9 revisions
KOLint is a type checker and lint tool for Knockout.JS views. TypeScript is used for type checking the Knockout view bindings when the viewmodel is defined in Typescript. The tool also checks for common mistakes in Knockout views.
NOTE! KOLint is named knockout-lint on npm. Not to be confused with the unrelated kolint package on npm. The CLI may be used with the alias kolint.
This simple example showcases three TypeScript errors. You can run kolint without any configuration with npx knockout-lint.
export default class {
// Should be a boolean
isVisible = 0
// Mispelled in view
myText = 'hello world'
// Should be a string (20px)
myWidth = 20
}<!-- ko-import vm from './viewmodel' -->
<!-- ko-viewmodel vm -->
<p data-bind="visible: isVisible, text: myTest, style: { width: myWidth }"></p>$ npx knockout-lint ./view.html
./view.html(3:23) error TS2345 Argument of type 'number' is not assignable to parameter of type 'MaybeReadonlyObservable<boolean>'.
./view.html(3:40) error TS2552 Cannot find name 'myText'. Did you mean 'myTest'?
./view.html(3:55) error TS2345 Argument of type '{ width: number; }' is not assignable to parameter of type 'MaybeReadonlyObservable<Record<string, MaybeReadonlyObservable<string>>>'.
✖ 3 problems (3 errors, 0 warnings)