Skip to content

JS 플러그인

Oxlint는 커스텀 JS 플러그인과 npm 패키지 형태의 플러그인을 지원합니다.

Oxlint의 플러그인 API는 ESLint v9+와 호환되므로, 대부분의 기존 ESLint 플러그인을 추가 설정 없이 사용할 수 있습니다.

ESLint 플러그인 API는 거의 전부 구현되어 있습니다(아래 참고).

INFO

JS 플러그인은 현재 알파이며 활발히 개발 중입니다.

동작은 ESLint와 같아야 합니다. 차이가 있으면 버그이니 이슈로 알려 주세요.

JS 플러그인 사용

  1. .oxlintrc.jsonjsPlugins에 플러그인 경로를 추가합니다.
  2. rules에 해당 플러그인 규칙을 추가합니다.

경로는 ./plugin.js, eslint-plugin-foo, @foo/eslint-plugin 등 유효한 import 스펙이면 됩니다. 경로는 설정 파일 기준으로 해석됩니다.

jsonc
{
  "jsPlugins": ["./path/to/my-plugin.js", "eslint-plugin-whatever", "@foobar/eslint-plugin"],
  "rules": {
    "my-plugin/rule1": "error",
    "my-plugin/rule2": "warn",
    "whatever/rule1": "error",
    "whatever/rule2": "warn",
    "@foobar/rule1": "error",
  },
  // ... other config ...
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  jsPlugins: ["./path/to/my-plugin.js", "eslint-plugin-whatever", "@foobar/eslint-plugin"],
  rules: {
    "my-plugin/rule1": "error",
    "my-plugin/rule2": "warn",
    "whatever/rule1": "error",
    "whatever/rule2": "warn",
    "@foobar/rule1": "error",
  },
  // ... other config ...
});

플러그인 별칭

플러그인에 다른 이름(별칭)을 줄 수 있습니다. 다음에 유용합니다.

  • 기본 이름이 네이티브 Oxlint 플러그인 이름과 겹칠 때(jsdoc, react 등).
  • 기본 이름이 매우 길 때.
  • 네이티브로 지원하지만 필요한 규칙이 아직 없을 때 JS 버전을 쓰고 싶을 때.
jsonc
{
  "jsPlugins": [
    // `jsdoc` is a reserved name, as Oxlint supports it natively
    {
      "name": "jsdoc-js",
      "specifier": "eslint-plugin-jsdoc",
    },
    // Shorten name
    {
      "name": "short",
      "specifier": "eslint-plugin-with-name-so-very-very-long",
    },
    // List plugins you don't want to alias as just specifiers
    "eslint-plugin-whatever",
  ],
  "rules": {
    "jsdoc-js/check-alignment": "error",
    "short/rule1": "error",
    "whatever/rule2": "error",
  },
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  jsPlugins: [
    // `jsdoc` is a reserved name, as Oxlint supports it natively
    {
      name: "jsdoc-js",
      specifier: "eslint-plugin-jsdoc",
    },
    // Shorten name
    {
      name: "short",
      specifier: "eslint-plugin-with-name-so-very-very-long",
    },
    // List plugins you don't want to alias as just specifiers
    "eslint-plugin-whatever",
  ],
  rules: {
    "jsdoc-js/check-alignment": "error",
    "short/rule1": "error",
    "whatever/rule2": "error",
  },
});

직접 플러그인을 만들고 사용자 규칙을 추가하는 방법은 JS 플러그인 작성을 보세요.

검증된 ESLint 플러그인

인기 있는 여러 ESLint 플러그인에 대해 적합성 테스트를 돌립니다. 예:

  • eslint-plugin-cypress (결과)
  • @e18e/eslint-plugin (결과)
  • eslint-plugin-mocha (결과)
  • eslint-plugin-playwright (결과): 일부 규칙은 Oxlint 네이티브에도 있으므로 가능하면 네이티브를 쓰는 것이 좋습니다
  • eslint-plugin-react-hooks (결과)
  • eslint-plugin-regexp (결과)
  • eslint-plugin-sonarjs (결과)
  • eslint-plugin-storybook (결과)
  • @stylistic/eslint-plugin (결과)
  • eslint-plugin-testing-library (결과)

위 목록이 전부는 아니며, 다른 많은 ESLint 플러그인도 Oxlint에서 동작합니다. 위는 명시적으로 테스트한 일부입니다.

동작이 확인된 플러그인에 대한 추가 정보는 GitHub Discussion을 보세요.

API 지원

Oxlint는 ESLint API 표면의 거의 전부를 지원합니다.

  • AST 순회
  • AST 탐색(node.parent, context.sourceCode.getAncestors)
  • 수정(fix)
  • 규칙 옵션
  • 셀렉터(ESLint 문서)
  • SourceCode API(예: context.sourceCode.getText(node))
  • SourceCode 토큰 API(예: context.sourceCode.getTokens(node))
  • 스코프 분석
  • 제어 흐름 분석(code path)
  • 인라인 비활성 지시문(// oxlint-disable)
  • 언어 서버(IDE) + 제안(인라인 진단·퀵 픽스)

아직 없는 것:

  • 사용자 정의 파일 형식·파서(예: Svelte, Vue, Angular)
  • TypeScript 타입 인지에 의존하는 린트 규칙

ESLint v9 이전에 제거된 ESLint API는 대부분 구현하지 않습니다. 플러그인이 ESLint v9용으로 갱신되지 않았다면 직접 수정하거나 대안을 찾아야 할 수 있습니다.

남은 기능은 향후 몇 달 안에 구현해 ESLint 플러그인 API 전부를 지원하는 것을 목표로 합니다.