1use super::*;
2
3#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
5#[cfg_attr(feature = "schemars", derive(JsonSchema))]
6#[serde(rename_all = "lowercase")]
7pub enum Plugins {
8 Eslint,
9 Import,
10 Jest,
11 Jsdoc,
12 #[serde(rename = "jsx-a11y")]
13 JsxA11y,
14 NextJs,
15 Node,
16 Oxc,
17 Promise,
18 React,
19 #[serde(rename = "react-perf")]
20 ReactPerf,
21 Regex,
22 Typescript,
23 Unicorn,
24 Vitest,
25 Vue,
26}
27
28impl Plugins {
29 pub const fn as_str(&self) -> &str {
30 match self {
31 Self::Eslint => "eslint",
32 Self::Import => "import",
33 Self::Jest => "jest",
34 Self::Jsdoc => "jsdoc",
35 Self::JsxA11y => "jsx-a11y",
36 Self::NextJs => "nextjs",
37 Self::Node => "node",
38 Self::Oxc => "oxc",
39 Self::Promise => "promise",
40 Self::React => "react",
41 Self::ReactPerf => "react-perf",
42 Self::Regex => "regex",
43 Self::Typescript => "typescript",
44 Self::Unicorn => "unicorn",
45 Self::Vitest => "vitest",
46 Self::Vue => "vue",
47 }
48 }
49}
50
51impl Plugin {
52 pub const fn as_str(&self) -> &str {
53 match self {
54 Self::Known(variant) => variant.as_str(),
55 Self::Custom(name) => name.as_str(),
56 }
57 }
58}
59
60impl PartialOrd for Plugin {
61 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
62 Some(self.cmp(other))
63 }
64}
65
66impl Ord for Plugin {
67 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
68 self.as_str().cmp(other.as_str())
69 }
70}
71
72#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
74#[cfg_attr(feature = "schemars", derive(JsonSchema))]
75#[serde(untagged)]
76pub enum Plugin {
77 Known(Plugins),
78 Custom(String),
79}
80
81#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
83#[cfg_attr(feature = "schemars", derive(JsonSchema))]
84#[serde(untagged, rename_all = "camelCase")]
85pub enum TagNamePreference {
86 String(String),
87 Data {
88 message: String,
89 replacement: String,
90 },
91 Message {
92 message: String,
93 },
94 Bool(bool),
95}
96
97#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
99#[cfg_attr(feature = "schemars", derive(JsonSchema))]
100#[serde(rename_all = "camelCase")]
101#[serde(default)]
102#[serde(deny_unknown_fields)]
103pub struct JsDocPluginSettings {
104 #[serde(skip_serializing_if = "Option::is_none")]
106 pub augments_extends_replaces_docs: Option<bool>,
107
108 #[serde(skip_serializing_if = "Option::is_none")]
110 pub exempt_destructured_roots_from_chekcs: Option<bool>,
111
112 #[serde(skip_serializing_if = "Option::is_none")]
114 pub ignore_internal: Option<bool>,
115
116 #[serde(skip_serializing_if = "Option::is_none")]
118 pub ignore_private: Option<bool>,
119
120 #[serde(skip_serializing_if = "Option::is_none")]
122 pub ignore_replaces_docs: Option<bool>,
123
124 #[serde(skip_serializing_if = "Option::is_none")]
126 pub implements_replaces_docs: Option<bool>,
127
128 #[serde(skip_serializing_if = "Option::is_none")]
130 pub override_replaces_docs: Option<bool>,
131
132 #[serde(skip_serializing_if = "Option::is_none")]
134 pub tag_name_preference: Option<BTreeMap<String, TagNamePreference>>,
135}
136
137#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
139#[cfg_attr(feature = "schemars", derive(JsonSchema))]
140#[serde(rename_all = "camelCase")]
141#[serde(default)]
142#[serde(deny_unknown_fields)]
143pub struct JsxA11yPluginSettings {
144 #[serde(skip_serializing_if = "Option::is_none")]
164 pub attributes: Option<BTreeMap<String, BTreeSet<String>>>,
165
166 #[serde(skip_serializing_if = "Option::is_none")]
182 pub components: Option<BTreeMap<String, String>>,
183
184 #[serde(skip_serializing_if = "Option::is_none")]
197 pub polymorphic_prop_name: Option<String>,
198}
199
200#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
202#[cfg_attr(feature = "schemars", derive(JsonSchema))]
203#[serde(rename_all = "camelCase")]
204#[serde(deny_unknown_fields)]
205pub struct NextPluginSettings {
206 #[serde(skip_serializing_if = "Option::is_none")]
223 pub root_dir: Option<OneOrManyStrings>,
224}
225
226#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
227#[cfg_attr(feature = "schemars", derive(JsonSchema))]
228#[serde(untagged)]
229pub enum OneOrManyStrings {
230 One(String),
231 Many(BTreeSet<String>),
232}
233
234#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
236#[cfg_attr(feature = "schemars", derive(JsonSchema))]
237#[serde(rename_all = "camelCase")]
238#[serde(deny_unknown_fields)]
239#[serde(default)]
240pub struct ReactPluginSettings {
241 #[serde(skip_serializing_if = "Option::is_none")]
261 pub form_components: Option<Vec<CustomComponent>>,
262
263 #[serde(skip_serializing_if = "Option::is_none")]
284 pub link_components: Option<Vec<CustomComponent>>,
285}
286
287#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
288#[cfg_attr(feature = "schemars", derive(JsonSchema))]
289#[serde(untagged)]
290pub enum CustomComponent {
291 NameOnly(String),
292 ObjectWithOneAttr {
293 name: String,
294 #[serde(alias = "formAttribute", alias = "linkAttribute")]
295 attribute: String,
296 },
297 ObjectWithManyAttrs {
298 name: String,
299 #[serde(alias = "formAttribute", alias = "linkAttribute")]
300 attributes: BTreeSet<String>,
301 },
302}