Skip to content

인라인 무시 주석

무시 주석은 규칙은 일반적으로 맞지만, 좁은 범위에서만 예외를 두고 싶을 때 쓰는 비상구입니다. 인라인 주석은 설정 파일보다 우선합니다.

Oxlint는 줄 주석(//)과 블록 주석(/* */)을 지원합니다. 주석은 아래 키워드 중 하나로 시작해야 합니다.

oxlint-disable

파일 끝까지, 또는 다시 켤 때까지 하나 이상의 규칙을 끕니다.

js
// Disable all Oxlint rules for the rest of the file
/* oxlint-disable */

// Disable a single rule in this file
/* oxlint-disable no-console */

// Disable multiple rules in this file
/* oxlint-disable no-console, typescript/no-floating-promises */

oxlint-enable

파일 끝까지, 또는 다시 끌 때까지 하나 이상의 규칙을 켭니다.

js
/* oxlint-enable no-console */

/* oxlint-enable no-console, no-alert */

oxlint-disable-line

현재 줄에서 하나 이상의 규칙을 끕니다.

js
console.log("Hello, world!"); // oxlint-disable-line no-console

console.log(x++); // oxlint-disable-line no-console, no-plusplus

oxlint-disable-next-line

바로 다음 줄에서만 규칙을 끄고, 그 다음 줄부터는 다시 적용됩니다.

js
// oxlint-disable-next-line no-console
console.log("Hello, world!"); // allowed because of the previous comment
console.log(x++); // not allowed because the previous comment only applied to the previous line

// oxlint-disable-next-line no-console, no-plusplus
console.log("Hello, world!"); // allowed

ESLint 호환

기존 ESLint 코드베이스와의 호환을 위해 oxlint 대신 eslint 키워드도 같습니다. 예: /* eslint-disable */, // eslint-disable-next-line.

가능하면 oxlint-* 형태를 권장합니다. 아직 Oxlint가 지원하지 않는 규칙이 있는 마이그레이션 중에는 eslint-*가 유용할 수 있습니다.

인라인에서 규칙 옵션은 바꿀 수 없음

무시 주석으로 규칙을 켜거나 끌 수는 있지만, 규칙 옵션은 바꿀 수 없습니다. 옵션은 설정 파일에 둡니다.

사용되지 않는 무시 주석 보고

기본값은 끄겨 있습니다. 켜면 // oxlint-disable-line처럼 그 줄에 실제 진단이 없을 때 보고합니다.

켜기:

bash
oxlint --report-unused-disable-directives

심각도 지정:

bash
oxlint --report-unused-disable-directives-severity error

두 옵션은 동시에 하나만 사용할 수 있습니다.

설정 파일에서도 지정할 수 있습니다.

jsonc
{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "options": {
    "reportUnusedDisableDirectives": "error", // or "off" or "warn"
  },
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  options: {
    reportUnusedDisableDirectives: "error", // or "off" or "warn"
  },
});