Skip to content
LogoLogo

Inline ignore comments

A comment in the source code can suppress violations. The summary of a run counts them as suppressed.

Comment forms

CommentEffect
// oxcruise-ignore-next-line [rules] -- reasonSuppresses the violations on the line after the comment. A blank line between the comment and the code stops it.
// oxcruise-ignore-line [rules] -- reasonSuppresses the violations on the same line.
// oxcruise-ignore-file [rules] -- reasonSuppresses the violations of the whole file.

The comment can be a line comment or a block comment. rules is a list of rule names, separated by commas or spaces. Without rule names, the comment applies to all rules. Text after -- is a reason. Oxcruise ignores it, but your colleagues can read it.

// oxcruise-ignore-next-line circular-dependencies -- the registry needs the plugin list
import { plugins } from "./plugins";
 
import legacy from "./legacy"; // oxcruise-ignore-line deprecated-dependencies

Violations of a module

Some violations belong to a module, not to a dependency. For example, orphan-modules reports a module that nothing imports. Only // oxcruise-ignore-file suppresses these violations. The ignore-line and ignore-next-line comments do not.

Violations of a folder or file

The folder-structure rule reports violations about files and folders. A // oxcruise-ignore-file comment suppresses a violation about the module that has the comment. A violation about a missing file, a folder or a file that is not a module has no place for a comment. Change the config file for these. See Folder structure.

Cycles

A cycle counts as suppressed when any one of its imports has the comment.

Merged dependencies

Oxcruise merges imports that have the same specifier, the same module system and the same type-only state. For example, import type and a value import of one module stay separate, and so do ./a and ./a.ts. A rule stays suppressed on a merged dependency only when every import suppresses it.

Unused code

  • To keep a module and the modules that it imports, put // oxcruise-ignore-file at the top. The unused-modules rule and the unused-exports rule then treat the module as an entry point.
  • To suppress one unused export, put // oxcruise-ignore-next-line unused-exports above it.
  • A violation of unused-packages is in a package.json. A comment cannot suppress it. Use the ignore option.

Plugin rules

The comments also apply to the rules of plugins. Use the full rule name, for example acme/max-fan-out.