---
source: crates/oxc_linter/src/tester.rs
---
  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (!isFinite(foo)) {
 3 │                 throw new Error();
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (isNaN(foo) === false) {
 3 │                 throw new Error();
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (Array.isArray(foo)) {
 3 │                 throw new Error('foo is an Array');
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (foo instanceof bar) {
 3 │                 throw new Error(foobar);
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (_.isElement(foo)) {
 3 │                 throw new Error();
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (_.isElement(foo)) {
 3 │                 throw new Error;
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (wrapper._.isElement(foo)) {
 3 │                 throw new Error;
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  × Invalid Character `"`
   ╭─[prefer_type_error.tsx:5:11]
 4 │             }
 5 │         r#"
   ·           ─
 6 │             if (Number.isFinite(foo) && Number.isSafeInteger(foo) && Number.isInteger(foo)) {
   ╰────

  × Expected a semicolon or an implicit semicolon after a statement, but found none
   ╭─[prefer_type_error.tsx:5:10]
 4 │             }
 5 │         r#"
   ·          ▲
 6 │             if (Number.isFinite(foo) && Number.isSafeInteger(foo) && Number.isInteger(foo)) {
   ╰────
  help: Try insert a semicolon here

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (wrapper.n.isFinite(foo) && wrapper.n.isSafeInteger(foo) && wrapper.n.isInteger(foo)) {
 3 │                 throw new Error();
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:27]
 2 │             if (wrapper.f.g.n.isFinite(foo) && wrapper.g.n.isSafeInteger(foo) && wrapper.n.isInteger(foo)) {
 3 │                 throw new Error();
   ·                           ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`

  ⚠ eslint-plugin-unicorn(prefer-type-error): Prefer throwing a `TypeError` over a generic `Error` after a type checking if-statement
   ╭─[prefer_type_error.tsx:3:28]
 2 │             if (_.isElement(foo)) {
 3 │                 throw (new Error());
   ·                            ─────
 4 │             }
   ╰────
  help: Change to `throw new TypeError(...)`
