Linter
새 규칙 기여
Oxlint에 새 규칙을 추가하는 방법은 규칙 추가 가이드를 참고하세요.
개발
./test.ts를 만든 뒤:
bash
just watch "cargo run --bin oxlint -- test.ts"또는 규칙 이름으로 필터해 테스트:
bash
just watch "cargo test -p oxc_linter -- rule-name"전체 코드베이스에 대해 oxlint 테스트
큰 JavaScript/TypeScript 프로젝트로 변경을 검증하려면 oxlint CLI를 빌드한 뒤 해당 코드베이스에서 실행합니다.
bash
# oxc 저장소에서 oxlint cli 빌드
just oxlint-node
# 테스트할 코드베이스 디렉터리에서 node로 oxlint 실행:
node <path-to-oxc-repo>/apps/oxlint/dist/cli.js
# 특정 규칙을 켜려면 -D, 기본 플러그인을 끄려면 --disable-x-plugin 등:
node <path-to-oxc-repo>/apps/oxlint/dist/cli.js -D rulename --disable-unicorn-plugin --disable-oxc-plugin --disable-typescript-plugin스냅샷 테스트
cargo insta로 스냅샷 테스트를 합니다.
cargo test -p oxc_linter를 실행하고 Tester::new(RULE::NAME, pass, fail).test_and_snapshot()가 호출되면 새 rule.snap.new 파일이 생깁니다.
스냅샷 변경을 모두 받으려면 cargo insta accept를 실행합니다.
규칙 카테고리
- correctness — 명백히 잘못되었거나 쓸모없는 코드
- suspicious — 대개 잘못되었거나 쓸모없을 가능성이 큰 코드
- pedantic — 다소 엄격하거나 가끔 오탐이 있는 린트
- perf — 더 빠르게 쓸 수 있는 코드
- style — 관용적으로 더 잘 쓸 수 있는 코드
- restriction — 케이스별로 켜기 전에 검토할 린트
- nursery — 아직 개발 중인 새 린트