Dropstone Docs

포매터

Dropstone은 언어별 포매터를 사용합니다.

Dropstone은 파일이 작성되거나 편집된 후 언어별 포매터를 사용하여 파일을 포맷할 수 있습니다. 포매터는 기본적으로 비활성화되어 있으며, Dropstone이 포매터를 실행하기 전에 설정에서 활성화해야 합니다.


내장 포매터

Dropstone은 인기 있는 언어 및 프레임워크를 위한 여러 내장 포매터와 함께 제공됩니다. 다음은 포매터, 지원되는 파일 확장자, 필요한 명령어 또는 설정 옵션의 목록입니다.

포매터확장자요구사항
air.Rair 명령어 사용 가능
biome.js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml, 및 더보기biome.json(c) 설정 파일
cargofmt.rscargo fmt 명령어 사용 가능
clang-format.c, .cpp, .h, .hpp, .ino, 및 더보기.clang-format 설정 파일
cljfmt.clj, .cljs, .cljc, .edncljfmt 명령어 사용 가능
dart.dartdart 명령어 사용 가능
dfmt.ddfmt 명령어 사용 가능
gleam.gleamgleam 명령어 사용 가능
gofmt.gogofmt 명령어 사용 가능
htmlbeautifier.erb, .html.erbhtmlbeautifier 명령어 사용 가능
ktlint.kt, .ktsktlint 명령어 사용 가능
mix.ex, .exs, .eex, .heex, .leex, .neex, .sfacemix 명령어 사용 가능
nixfmt.nixnixfmt 명령어 사용 가능
ocamlformat.ml, .mliocamlformat 명령어 사용 가능 및 .ocamlformat 설정 파일
ormolu.hsormolu 명령어 사용 가능
pint.phpcomposer.jsonlaravel/pint 의존성
prettier.js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml, 및 더보기package.jsonprettier 의존성
rubocop.rb, .rake, .gemspec, .rurubocop 명령어 사용 가능
ruff.py, .pyi설정과 함께 ruff 명령어 사용 가능
rustfmt.rsrustfmt 명령어 사용 가능
shfmt.sh, .bashshfmt 명령어 사용 가능
standardrb.rb, .rake, .gemspec, .rustandardrb 명령어 사용 가능
terraform.tf, .tfvarsterraform 명령어 사용 가능
uv.py, .pyiuv 명령어 사용 가능
zig.zig, .zonzig 명령어 사용 가능

포매터가 활성화되면, 프로젝트에 package.jsonprettier가 있는 경우 Dropstone은 일치하는 파일에 prettier를 사용합니다.


작동 방식

Dropstone이 파일을 작성하거나 편집하고 포매터가 활성화되면:

  1. 파일 확장자를 모든 활성화된 포매터와 비교합니다.
  2. 파일에 적절한 포매터 명령어를 실행합니다.
  3. 포매팅 변경사항을 적용합니다.

이 프로세스는 활성화된 포매터에 대해 백그라운드에서 발생합니다.


설정

Dropstone 설정의 formatter 섹션을 통해 포매터를 활성화하고 사용자 정의할 수 있습니다.

모든 내장 포매터를 활성화하려면 formattertrue로 설정합니다.

{
  "$schema": "https://dropstone.io/schema/config.json",
  "formatter": true
}

내장 포매터를 활성화된 상태로 유지하면서 재정의 또는 사용자 정의 포매터를 구성하려면 객체를 사용합니다.

{
  "$schema": "https://dropstone.io/schema/config.json",
  "formatter": {}
}

각 포매터 설정은 다음을 지원합니다:

속성타입설명
disabledboolean포매터를 비활성화하려면 이를 true로 설정합니다
commandstring[]포매팅을 실행할 명령어입니다. 사용자 정의 포매터의 경우 필수이며, 내장 포매터의 경우 선택사항입니다.
environmentobject포매터 실행 시 설정할 환경 변수
extensionsstring[]이 포매터가 처리해야 할 파일 확장자

몇 가지 예를 살펴보겠습니다.


포매터 비활성화

formatter를 생략하면 모든 포매터가 비활성화됩니다. 다른 설정이 활성화한 후 모든 포매터를 비활성화하려면 formatterfalse로 설정합니다:

{
  "$schema": "https://dropstone.io/schema/config.json",
  "formatter": false
}

특정 포매터를 비활성화하려면 disabledtrue로 설정합니다:

{
  "$schema": "https://dropstone.io/schema/config.json",
  "formatter": {
    "prettier": {
      "disabled": true
    }
  }
}

사용자 정의 포매터

environment 또는 extensions와 같은 옵션으로 내장 포매터를 구성할 수 있습니다. 사용자 정의 포매터를 추가하려면 commandextensions를 지정합니다:

{
  "$schema": "https://dropstone.io/schema/config.json",
  "formatter": {
    "prettier": {
      "command": ["npx", "prettier", "--write", "$FILE"],
      "environment": {
        "NODE_ENV": "development"
      },
      "extensions": [".js", ".ts", ".jsx", ".tsx"]
    },
    "custom-markdown-formatter": {
      "command": ["deno", "fmt", "$FILE"],
      "extensions": [".md"]
    }
  }
}

명령어의 $FILE 플레이스홀더는 포매팅되는 파일의 경로로 대체됩니다.

Ctrl+I