KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

린트 기준

표준 작성하기

표준 파일에는 name, description, extends, lint, format가 들어 있어요. 주석과 끝에 붙는 쉼표를 쓸 수 있어요:

JSON
// ../shared/acme/kscript-standard.json
{
  "$schema": "https://raw.githubusercontent.com/kylepantall/kscript/master/editors/vscode/schemas/kscript-standard.schema.json",
  "name": "acme",
  "description": "Acme house style.",
  "extends": "kscript:recommended",
  "lint": {
    "rules": { "KS6*": "error" },
    "warnings_as_errors": true
  },
  "format": { "indent": 4, "max_blank_lines": 2 }
}

lint는 rules(각 코드 또는 접두사별 심각도: off, hint, info, warning 또는 error)와 warnings_as_errors를 받아요. format는 모든 서식 설정을 받아요: indent, tab_width, print_width, max_blank_lines, end_of_line, preserve, rules 및 enabled(서식 참고).

어떤 파일을 검사하고 포맷할지(include와 exclude)는 각 프로젝트의 폴더에 따라 달라지므로, 그 설정은 kscript.json에 둡니다. 이 값을 설정한 표준에는 경고가 표시되며, 해당 값은 무시됩니다. serve, test, app, packages도 마찬가지로 무시됩니다.

표준 파일 이름은 kscript-standard.json처럼 지정하면 프로젝트가 폴더 이름을 정할 수 있고, 또는 something.kscript-standard.json처럼 지정할 수도 있어요. VS Code 확장 기능이 두 이름을 모두 검증하고 자동 완성하며, 다른 이름도 사용할 수 있어요.

설정은 snake_case로 작성해요(warnings_as_errors, print_width). 예전 camelCase 이름(warningsAsErrors, printWidth)은 오류이며 새 이름을 알려줘요. 알 수 없는 설정은 경고로 표시돼요.

표준이 존재할 수 있는 곳

"standard"가 kscript.json에 있을 때, 그리고 표준의 "extends"는 내장 이름, 경로 또는 그 목록을 받습니다:

JSON
"standard": "kscript:recommended"                           // built in
"standard": "./standards/team.kscript-standard.json"        // a file, relative to the file that names it
"standard": "../shared/acme"                                // a folder holding kscript-standard.json
"standard": "~/kscript/standard.json"                       // a file in your home folder
"standard": ["kscript:recommended", "./team.json", "./this-repo.json"]   // several, applied in order

extends 경로는 표준 기준으로 상대 경로입니다. 따라서 표준을 함께 옮길 수 있습니다. 폴더 하나로 표준을 Git 서브모듈, 공유 폴더, 또는 팀이 프로젝트 옆에 체크아웃하는 패키지 형태로 쉽게 공유할 수 있습니다.

찾을 수 없거나, 올바른 JSON이 아니거나, (직접 또는 다른 표준을 통해) 자기 자신을 확장하는 표준은 오류이며, kscript check은(는) 종료 코드 2로 중지됩니다.