Skip to content

Silenced checks: @ts-ignore, any, blanket # type: ignore or # noqa, eslint-disable without a rule, #[allow(dead_code)], //nolint without a reason ​

Errors and checks hidden: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as suppression.

What makes silenced checks a bad practice? ​

The standards that call it a bad practice: Clean Code G4 Overridden Safeties; typescript-eslint ban-ts-comment and no-explicit-any; eslint-comments no-unlimited-disable; ruff PGH003, PGH004; golangci-lint nolintlint.

What does lessloc do about silenced checks? ​

lessloc catches it as suppression.

  • suppression (tier 1): A blanket suppression: @ts-ignore, any, # type: ignore or # noqa without a code, eslint-disable without a rule, nolint without a linter and a reason, allow(dead_code).

Examples ​

Caught as suppression:

ts
export const n: number = JSON.parse("1");
// @ts-ignore
export const m = n.foo;

Written well:

ts
export const n = 1;
// @ts-expect-error: the vendored typings miss foo (upstream issue 12)
export const m = n.foo;

Caught as suppression:

js
/* eslint-disable */
export const x = 1;

Written well:

js
// eslint-disable-next-line no-console -- the CLI prints
console.log(1);

Caught as suppression:

python
import os  # noqa
x = os.sep  # type: ignore

Written well:

python
import os  # noqa: F401 re-exported for plugins
x = os.sep  # type: ignore[attr-defined]

Caught as suppression:

rust
#[allow(dead_code)]
fn helper() -> u8 {
    1
}

Written well:

rust
#[allow(clippy::too_many_arguments)]
fn helper() -> u8 {
    1
}

Caught as suppression:

ts
export function parse(s: string) {
  const data: any = JSON.parse(s);
  return data.id as any;
}

Written well:

ts
export function parse(s: string): { id: string } {
  return JSON.parse(s) as { id: string };
}

The other patterns in Errors and checks hidden:

Released under the Apache-2.0 license. · llms.txt