Skip to content

Commit

Permalink
chore(linter) convert catch error name to a warning (oxc-project#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 authored Dec 16, 2023
1 parent c61ea76 commit f4f0bdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions crates/oxc_linter/src/rules/unicorn/catch_error_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};

#[derive(Debug, Error, Diagnostic)]
#[error("eslint-plugin-unicorn(catch-error-name): The catch parameter {0:?} should be named {1:?}")]
#[diagnostic(severity(warning))]
struct CatchErrorNameDiagnostic(Atom, Atom, #[label] pub Span);

#[derive(Debug, Clone)]
Expand Down
30 changes: 15 additions & 15 deletions crates/oxc_linter/src/snapshots/catch_error_name.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,91 @@
source: crates/oxc_linter/src/tester.rs
expression: catch_error_name
---
× eslint-plugin-unicorn(catch-error-name): The catch parameter "descriptiveError" should be named "exception"
eslint-plugin-unicorn(catch-error-name): The catch parameter "descriptiveError" should be named "exception"
╭─[catch_error_name.tsx:1:1]
1try { } catch (descriptiveError) { }
· ────────────────
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "has_space_after "
eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "has_space_after "
╭─[catch_error_name.tsx:1:1]
1try { } catch (e) { }
· ─
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "1_start_with_a_number"
eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "1_start_with_a_number"
╭─[catch_error_name.tsx:1:1]
1try { } catch (e) { }
· ─
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "_){ } evilCode; if(false"
eslint-plugin-unicorn(catch-error-name): The catch parameter "e" should be named "_){ } evilCode; if(false"
╭─[catch_error_name.tsx:1:1]
1try { } catch (e) { }
· ─
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
╭─[catch_error_name.tsx:1:1]
1try { } catch (notMatching) { }
· ───────────
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
╭─[catch_error_name.tsx:1:1]
1try { } catch (notMatching) { }
· ───────────
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
╭─[catch_error_name.tsx:1:1]
1try { } catch (notMatching) { }
· ───────────
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "_" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "_" should be named "error"
╭─[catch_error_name.tsx:1:1]
1try { } catch (_) { console.log(_) }
· ─
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "notMatching" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.catch(notMatching => { })
· ───────────
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.catch((foo) => { })
· ───
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.catch(function (foo) { })
· ───
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.catch((function (foo) { }))
· ───
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.then(function (foo) { }).catch((foo) => { })
· ───
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.then(undefined, function (foo) { })
· ───
╰────

× eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
eslint-plugin-unicorn(catch-error-name): The catch parameter "foo" should be named "error"
╭─[catch_error_name.tsx:1:1]
1promise.then(undefined, (foo) => { })
· ───
Expand Down

0 comments on commit f4f0bdf

Please sign in to comment.