KOLint
Search…
Introduction
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.
KOLint is named knockout-lint on npm. Not to be confused with the unrealted kolint package on npm.

Example usage

This simple example showcases three TypeScript errors.
1
export default class {
2
// Should be a boolean
3
isVisible = 0
4
// Mispelled in view
5
myText = 'hello world'
6
// Should be a string (20px)
7
myWidth = 20
8
}
Copied!
1
<!-- ko-import vm from './viewmodel' -->
2
<!-- ko-viewmodel vm -->
3
<p data-bind="visible: isVisible, text: myTest, style: { width: myWidth }"></p>
Copied!
1
$ kolint ./view.html
2
3
./view.html(3:23) error TS2345 Argument of type 'number' is not assignable to parameter of type 'MaybeReadonlyObservable<boolean>'.
4
./view.html(3:40) error TS2552 Cannot find name 'myText'. Did you mean 'myTest'?
5
./view.html(3:55) error TS2345 Argument of type '{ width: number; }' is not assignable to parameter of type 'MaybeReadonlyObservable<Record<string, MaybeReadonlyObservable<string>>>'.
6
7
✖ 3 problems (3 errors, 0 warnings)
Copied!
Last modified 4mo ago
Copy link