Repository navigation
Setup
The package is hosted on NPM with the name 'knockout-lint'. Not to be confused with the unrelated 'kolint' package. The dependency should be saved as a dev-dependency, unless used in runtime code.
npm install --save-dev knockout-lint
The API can be used with the Node.js runtime. The below example showcases the different stages of compiling.
import * as kolint from 'knockout-lint';
// Creates a new program, can be used with multiple files.
const program = kolint.createProgram();
// Parses the provided document
const document = program.parse(/* document text */);
// Compiles the document with built-in ts compiler
const tsOut = program.compile(/* document path */, document);
// Obtains the diagnostics from program and built-in ts compiler
const diagnostics = program.diagnostics.concat(tsOut.getDiagnostics());NOTE! The CLI may be used with the alias 'kolint' not to be confused with the unrelated 'kolint' package on npm. See installation.
kolint views/**/*.htmlSee all the available argument flags and help by using:
kolint --help
Create a new file called .kolint.js (preferably), .kolint.json or .kolint.yml. The file will be automatically used by kolint. Use can specify a custom filename with the argument flag --config, or the shorthand -c or disable automatic config import by using --no-config.
module.exports = {
// Compiled ts code, usually set to false.
out: './build/debug',
// The output file extension, can be used to identify kolint code.
outExt: '.kolint.ts',
// Enables or disabled the generation of source maps.
sourceMap: true,
// Whether to NOT search for configs in parent directories.
root: true,
// Map with severity levels for different diagnostics.
severity: {
'TS1234': 'off',
'KO1234': 'warning',
'error-name': 'error'
},
}