Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
⌘K
Up or down tonavigateEnter toselectEscape toclose
On this page

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 optionsJump to heading

--compactJump to heading

Output lint result in compact format.

--fixJump to heading

Fix any linting errors for rules that support it.

--ignoreJump to heading

Ignore linting particular source files.

--jsonJump to heading

Output lint result in JSON format.

--rulesJump to heading

List available rules.

--rules-excludeJump to heading

Exclude lint rules.

--rules-includeJump to heading

Include lint rules.

--rules-tagsJump to heading

Use set of rules with a tag.

OptionsJump to heading

--allow-importJump to heading

Short flag:-I

Allow importing from remote hosts. Optionally specify allowed IP addresses and host names, with ports as necessary. Default value: deno.land:443,jsr.io:443,esm.sh:443,cdn.jsdelivr.net:443,raw.githubusercontent.com:443,user.githubusercontent.com:443.

--configJump to heading

Short flag:-c

Configure different aspects of deno including TypeScript, linting, and code formatting.Typically the configuration file will be calleddeno.json ordeno.jsonc andautomatically detected; in that case this flag is not necessary.

--deny-importJump to heading

Deny importing from remote hosts. Optionally specify denied IP addresses and host names, with ports as necessary.

--extJump to heading

Specify the file extension to lint when reading from stdin.For example, usejsx to lint JSX files ortsx 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-configJump to heading

Disable automatic loading of the configuration file.

--permit-no-filesJump to heading

Don't return an error code if no files were found.

File watching optionsJump to heading

--no-clear-screenJump to heading

Do not clear terminal screen when under watch mode.

--watchJump to heading

Watch for file changes and restart process automatically.Only local files from entry point module graph are watched.

--watch-excludeJump to heading

Exclude provided files/patterns from watch mode.

Available rulesJump to heading

For a complete list of supported rules, visitList of rulesdocumentation page.

Ignore directivesJump to heading

File levelJump to heading

To ignore a whole file use// deno-lint-ignore-file at the top of the file:

// deno-lint-ignore-filefunctionfoo():any{// ...}

You can also specify the reason for ignoring the file:

// deno-lint-ignore-file -- reason for ignoringfunctionfoo():any{// ...}

The ignore directive must be placed before the first statement or declaration:

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license./** * Some JS doc */// deno-lint-ignore-fileimport{ bar}from"./bar.js";functionfoo():any{// ...}

You can also ignore certain diagnostics in the whole file:

// deno-lint-ignore-file no-explicit-any no-emptyfunctionfoo():any{// ...}

If there are multiple// deno-lint-ignore-file directives, all but the firstone are ignored:

// This is effective// deno-lint-ignore-file no-explicit-any no-empty// But this is NOT effective// deno-lint-ignore-file no-debuggerfunctionfoo():any{debugger;// not ignored!}

Line levelJump to heading

To ignore specific diagnostics use// deno-lint-ignore <codes...> on thepreceding line of the offending line.

// deno-lint-ignore no-explicit-anyfunctionfoo():any{// ...}// deno-lint-ignore no-explicit-any explicit-function-return-typefunctionbar(a:any){// ...}

You must specify the names of the rules to be ignored.

You can also specify the reason for ignoring the diagnostic:

// deno-lint-ignore no-explicit-any -- reason for ignoringfunctionfoo():any{// ...}

Ignoreban-unused-ignore itselfJump to heading

deno lint providesban-unused-ignore rule,which will detect ignore directives that don't ever suppress certaindiagnostics. This is useful when you want to discover ignore directives that areno longer necessary after refactoring the code.

In a few cases, however, you might want to ignoreban-unused-ignore ruleitself. One of the typical cases would be when working with auto-generatedfiles; it makes sense to add file-level ignore directives for some rules, andthere's almost no need for detecting unused directives viaban-unused-ignorein this case.

You can use// deno-lint-ignore-file ban-unused-ignore as always if you wantto suppress the rule for a whole file:

// deno-lint-ignore-file ban-unused-ignore no-explicit-any// `no-explicit-any` isn't used but you'll get no diagnostics because of ignoring// `ban-unused-ignore`console.log(42);

Do note that ignoringban-unused-ignore itself only works via file-levelignore directives. This means that per line directives, like// deno-lint-ignore ban-unused-ignore, don't work at all. If you want toignoreban-unused-ignore for some special reasons, make sure to add it as afile-level ignore directive.

More about linting and formattingJump to heading

For more information about linting and formating in Deno, and the differencesbetween these two utilities, visit theLinting and Formatting page inour Fundamentals section.

Did you find what you needed?

What can we do to improve this page?

If provided, you'll be @mentioned in the created GitHub issue

Privacy policy

[8]ページ先頭

©2009-2025 Movatter.jp