dprint_plugin_json/configuration/
types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use dprint_core::configuration::*;
use dprint_core::generate_str_to_from;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum TrailingCommaKind {
  /// Always format with trailing commas. Beware: trailing commas can cause many JSON parsers to fail.
  Always,
  /// Use trailing commas in JSONC files and do not use trailing commas in JSON files. (Default)
  Jsonc,
  /// Keep the trailing comma if it exists.
  Maintain,
  /// Never format with trailing commas.
  Never,
}

generate_str_to_from![
  TrailingCommaKind,
  [Always, "always"],
  [Maintain, "maintain"],
  [Never, "never"],
  [Jsonc, "jsonc"]
];