deno lint, linter
Command line usage
deno lint [OPTIONS] [files]...Lint JavaScript/TypeScript source code.
deno lint
deno lint myfile1.ts myfile2.js
Print result as JSON:
deno lint --json
Read from stdin:
cat file.ts | deno lint -
cat file.ts | deno lint --json -
List available rules:
deno lint --rules
To ignore specific diagnostics, you can write an ignore comment on the preceding line with a rule name (or multiple):
// deno-lint-ignore no-explicit-any
// deno-lint-ignore require-await no-empty
To ignore linting on an entire file, you can add an ignore comment at the top of the file:
// deno-lint-ignore-file
Linting options
--compact
Output lint result in compact format.
--fix
Fix any linting errors for rules that support it.
--ignore
Ignore linting particular source files.
--json
Output lint result in JSON format.
--rules
List available rules.
--rules-exclude
Exclude lint rules.
--rules-include
Include lint rules.
--rules-tags
Use set of rules with a tag.
Options
--config
Short flag: -c
Configure different aspects of deno including TypeScript, linting, and code formatting Typically the configuration file will be called deno.json or deno.jsonc and automatically detected; in that case this flag is not necessary.
--ext
Specify the file extension to lint when reading from stdin.For example, use jsx to lint JSX files or tsx for TSX files.This argument is necessary because stdin input does not automatically infer the file type.Example usage: cat file.jsx | deno lint - --ext=jsx.
--no-config
Disable automatic loading of the configuration file.
File watching options
--no-clear-screen
Do not clear terminal screen when under watch mode.
--watch
Watch for file changes and restart process automatically. Only local files from entry point module graph are watched.
--watch-exclude
Exclude provided files/patterns from watch mode.
Available rules
For a complete list of supported rules, visit the deno_lint rule documentation.
Ignore directives
Files
To ignore the whole file, a // deno-lint-ignore-file directive should placed at the top of the file:
// deno-lint-ignore-file
function foo(): any {
// ...
}
or
// deno-lint-ignore-file -- reason for ignoring
function foo(): any {
// ...
}
The ignore directive must be placed before the first statement 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 {
// ...
}
You can also ignore certain diagnostics in the whole file:
// deno-lint-ignore-file no-explicit-any no-empty
function foo(): any {
// ...
}
Diagnostics
To ignore certain diagnostics, the // deno-lint-ignore <rules...> directive should be placed before the targeted line. Specifying the 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) {
// ...
}
You can also specify the reason for ignoring the diagnostic:
// deno-lint-ignore no-explicit-any -- reason for ignoring
function foo(): any {
// ...
}
© 2018–2024 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/cli/linter