Skip to content

Commit

Permalink
feat: add dprint plugin schema
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Aug 11, 2023
1 parent b2df188 commit 08f9b13
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
50 changes: 50 additions & 0 deletions crates/ruff_fmt_dprint/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://plugins.dprint.dev/wasm-fmt/ruff_fmt/0.0.0/schema.json",
"type": "object",
"properties": {
"indentStyle": {
"description": "Specifies the indent style:\n* Either a tab\n* or a specific amount of spaces",
"default": 4,
"oneOf": [
{
"type": "number"
},
{
"const": "tab"
}
],
"examples": [
2,
4,
8,
"tab"
]
},
"lineWidth": {
"description": "The preferred line width at which the formatter should wrap lines.",
"default": 88,
"type": "number"
},
"quoteStyle": {
"description": "The preferred line width at which the formatter should wrap lines.",
"default": "double",
"type": "string",
"enum": [
"double",
"single",
"\"",
"'"
]
},
"magicTrailingComma": {
"description": "Whether to expand lists or elements if they have a trailing comma such as `(a, b,)`",
"default": "respect",
"type": "string",
"enum": [
"respect",
"ignore"
]
}
}
}
15 changes: 11 additions & 4 deletions crates/ruff_fmt_dprint/src/wasm_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ impl SyncPluginHandler<Configuration> for RuffFmtWasmPlugin {
}

fn plugin_info(&mut self) -> SyncPluginInfo {
let version = env!("CARGO_PKG_VERSION").to_string();
let config_schema_url =
format!("https://plugins.dprint.dev/wasm-fmt/ruff_fmt/{}/schema.json", version);


SyncPluginInfo {
info: PluginInfo {
name: "ruff_fmt".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
version,
config_key: "python".to_string(),
help_url: env!("CARGO_PKG_HOMEPAGE").to_string(),
config_schema_url: "".to_string(),
update_url: None,
help_url: format!("{}/issues", env!("CARGO_PKG_REPOSITORY")),
config_schema_url,
update_url: Some(
"https://plugins.dprint.dev/wasm-fmt/ruff_fmt/latest.json".to_string(),
),
},
file_matching: FileMatchingInfo {
file_extensions: vec!["py".to_string()],
Expand Down

0 comments on commit 08f9b13

Please sign in to comment.