Linter
Deno ships with a built in code linter for JavaScript and TypeScript.
Note: linter is a new feature and still unstable thus it requires --unstable
flag
# lint all JS/TS files in the current directory and subdirectories
deno lint --unstable
# lint specific files
deno lint --unstable myfile1.ts myfile2.ts
Available rules
ban-ts-commentban-untagged-ignoreconstructor-superfor-directiongetter-returnno-array-constructorno-async-promise-executorno-case-declarationsno-class-assignno-compare-neg-zerono-cond-assignno-debuggerno-delete-varno-dupe-argsno-dupe-keysno-duplicate-caseno-empty-character-classno-empty-interfaceno-empty-patternno-emptyno-ex-assignno-explicit-anyno-func-assignno-misused-newno-namespaceno-new-symbolno-obj-callno-octalno-prototype-builtinsno-regex-spacesno-setter-returnno-this-aliasno-this-before-superno-unsafe-finallyno-unsafe-negationno-withprefer-as-constprefer-namespace-keywordrequire-yieldtriple-slash-referenceuse-isnanvalid-typeof
Ignore directives
Files
To ignore whole file // deno-lint-ignore-file directive should placed at the
top of the file.
// deno-lint-ignore-file
function foo(): any {
// ...
}
Ignore directive must be placed before first stament or declaration:
// Copyright 2020 the Deno authors. All rights reserved. MIT license.
/**
* Some JS doc
**/
// deno-lint-ignore-file
import { bar } from "./bar.js";
function foo(): any {
// ...
}
Diagnostics
To ignore certain diagnostic // deno-lint-ignore <codes...> directive should
be placed before offending line. Specifying ignored rule name is required.
// deno-lint-ignore no-explicit-any
function foo(): any {
// ...
}
// deno-lint-ignore no-explicit-any explicit-function-return-type
function bar(a: any) {
// ...
}
To provide some compatibility with ESLint deno lint also supports
// eslint-ignore-next-line directive. Just like in // deno-lint-ignore it's
required to specify ignored rule name is required.
// eslint-ignore-next-line no-empty
while (true) {}
// eslint-ignore-next-line @typescript-eslint/no-explicit-any
function bar(a: any) {
// ...
}