Skip to content

Commit 8404da4

Browse files
committed
refactor(linter): remove unused LintPluginOptions (#11919)
1 parent fe4006b commit 8404da4

File tree

1 file changed

+0
-199
lines changed

1 file changed

+0
-199
lines changed

crates/oxc_linter/src/config/plugins.rs

Lines changed: 0 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,6 @@ impl Default for LintPlugins {
4747
}
4848
}
4949

50-
impl From<LintPluginOptions> for LintPlugins {
51-
fn from(options: LintPluginOptions) -> Self {
52-
let mut plugins = LintPlugins::empty();
53-
plugins.set(LintPlugins::REACT, options.react);
54-
plugins.set(LintPlugins::UNICORN, options.unicorn);
55-
plugins.set(LintPlugins::TYPESCRIPT, options.typescript);
56-
plugins.set(LintPlugins::OXC, options.oxc);
57-
plugins.set(LintPlugins::IMPORT, options.import);
58-
plugins.set(LintPlugins::JSDOC, options.jsdoc);
59-
plugins.set(LintPlugins::JEST, options.jest);
60-
plugins.set(LintPlugins::VITEST, options.vitest);
61-
plugins.set(LintPlugins::JSX_A11Y, options.jsx_a11y);
62-
plugins.set(LintPlugins::NEXTJS, options.nextjs);
63-
plugins.set(LintPlugins::REACT_PERF, options.react_perf);
64-
plugins.set(LintPlugins::PROMISE, options.promise);
65-
plugins.set(LintPlugins::NODE, options.node);
66-
plugins
67-
}
68-
}
69-
7050
impl LintPlugins {
7151
/// Returns `true` if the Vitest plugin is enabled.
7252
#[inline]
@@ -241,182 +221,3 @@ impl JsonSchema for LintPlugins {
241221
r#gen.subschema_for::<Vec<LintPluginOptionsSchema>>()
242222
}
243223
}
244-
245-
#[derive(Debug)]
246-
#[non_exhaustive]
247-
pub struct LintPluginOptions {
248-
/// On by default.
249-
pub react: bool,
250-
/// On by default.
251-
pub unicorn: bool,
252-
/// On by default.
253-
pub typescript: bool,
254-
/// On by default.
255-
pub oxc: bool,
256-
pub import: bool,
257-
pub jsdoc: bool,
258-
pub jest: bool,
259-
pub vitest: bool,
260-
pub jsx_a11y: bool,
261-
pub nextjs: bool,
262-
pub react_perf: bool,
263-
pub promise: bool,
264-
pub node: bool,
265-
}
266-
267-
impl Default for LintPluginOptions {
268-
fn default() -> Self {
269-
Self {
270-
react: false,
271-
unicorn: true,
272-
typescript: true,
273-
oxc: true,
274-
import: false,
275-
jsdoc: false,
276-
jest: false,
277-
vitest: false,
278-
jsx_a11y: false,
279-
nextjs: false,
280-
react_perf: false,
281-
promise: false,
282-
node: false,
283-
}
284-
}
285-
}
286-
287-
impl LintPluginOptions {
288-
/// Create a new instance with all plugins disabled.
289-
#[must_use]
290-
pub fn none() -> Self {
291-
Self {
292-
react: false,
293-
unicorn: false,
294-
typescript: false,
295-
oxc: false,
296-
import: false,
297-
jsdoc: false,
298-
jest: false,
299-
vitest: false,
300-
jsx_a11y: false,
301-
nextjs: false,
302-
react_perf: false,
303-
promise: false,
304-
node: false,
305-
}
306-
}
307-
308-
/// Create a new instance with all plugins enabled.
309-
#[must_use]
310-
pub fn all() -> Self {
311-
Self {
312-
react: true,
313-
unicorn: true,
314-
typescript: true,
315-
oxc: true,
316-
import: true,
317-
jsdoc: true,
318-
jest: true,
319-
vitest: true,
320-
jsx_a11y: true,
321-
nextjs: true,
322-
react_perf: true,
323-
promise: true,
324-
node: true,
325-
}
326-
}
327-
}
328-
329-
impl<S: AsRef<str>> FromIterator<(S, bool)> for LintPluginOptions {
330-
fn from_iter<I: IntoIterator<Item = (S, bool)>>(iter: I) -> Self {
331-
let mut options = Self::none();
332-
for (s, enabled) in iter {
333-
let flags = LintPlugins::from(s.as_ref());
334-
match flags {
335-
LintPlugins::REACT => options.react = enabled,
336-
LintPlugins::UNICORN => options.unicorn = enabled,
337-
LintPlugins::TYPESCRIPT => options.typescript = enabled,
338-
LintPlugins::OXC => options.oxc = enabled,
339-
LintPlugins::IMPORT => options.import = enabled,
340-
LintPlugins::JSDOC => options.jsdoc = enabled,
341-
LintPlugins::JEST => options.jest = enabled,
342-
LintPlugins::VITEST => options.vitest = enabled,
343-
LintPlugins::JSX_A11Y => options.jsx_a11y = enabled,
344-
LintPlugins::NEXTJS => options.nextjs = enabled,
345-
LintPlugins::REACT_PERF => options.react_perf = enabled,
346-
LintPlugins::PROMISE => options.promise = enabled,
347-
LintPlugins::NODE => options.node = enabled,
348-
_ => {} // ignored
349-
}
350-
}
351-
352-
options
353-
}
354-
}
355-
356-
impl<'s> FromIterator<&'s str> for LintPluginOptions {
357-
fn from_iter<T: IntoIterator<Item = &'s str>>(iter: T) -> Self {
358-
iter.into_iter().map(|s| (s, true)).collect()
359-
}
360-
}
361-
362-
#[cfg(test)]
363-
mod test {
364-
use super::*;
365-
impl PartialEq for LintPluginOptions {
366-
fn eq(&self, other: &Self) -> bool {
367-
self.react == other.react
368-
&& self.unicorn == other.unicorn
369-
&& self.typescript == other.typescript
370-
&& self.oxc == other.oxc
371-
&& self.import == other.import
372-
&& self.jsdoc == other.jsdoc
373-
&& self.jest == other.jest
374-
&& self.vitest == other.vitest
375-
&& self.jsx_a11y == other.jsx_a11y
376-
&& self.nextjs == other.nextjs
377-
&& self.react_perf == other.react_perf
378-
&& self.promise == other.promise
379-
&& self.node == other.node
380-
}
381-
}
382-
383-
#[test]
384-
fn test_default_conversion() {
385-
let plugins = LintPlugins::default();
386-
let options = LintPluginOptions::default();
387-
assert_eq!(LintPlugins::from(options), plugins);
388-
}
389-
390-
#[test]
391-
fn test_collect_empty() {
392-
let empty: &[&str] = &[];
393-
let plugins: LintPluginOptions = empty.iter().copied().collect();
394-
assert_eq!(plugins, LintPluginOptions::none());
395-
396-
let empty: Vec<(String, bool)> = vec![];
397-
let plugins: LintPluginOptions = empty.into_iter().collect();
398-
assert_eq!(plugins, LintPluginOptions::none());
399-
}
400-
401-
#[test]
402-
fn test_collect_strings() {
403-
let enabled = vec!["react", "typescript", "jest"];
404-
let plugins: LintPluginOptions = enabled.into_iter().collect();
405-
let expected = LintPluginOptions {
406-
react: true,
407-
unicorn: false,
408-
typescript: true,
409-
oxc: false,
410-
import: false,
411-
jsdoc: false,
412-
jest: true,
413-
vitest: false,
414-
jsx_a11y: false,
415-
nextjs: false,
416-
react_perf: false,
417-
promise: false,
418-
node: false,
419-
};
420-
assert_eq!(plugins, expected);
421-
}
422-
}

0 commit comments

Comments
 (0)