Skip to content

docs(eslint-plugin): [no-throw-literal] fix typo in example #8006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions packages/eslint-plugin/docs/rules/no-throw-literal.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ This rule is aimed at maintaining consistency when throwing exception by disallo
### ❌ Incorrect

```ts
/*eslint @typescript-eslint/no-throw-literal: "error"*/

throw 'error';

throw 0;
Expand Down Expand Up @@ -53,19 +51,17 @@ throw foo.bar;
### ✅ Correct

```ts
/*eslint @typescript-eslint/no-throw-literal: "error"*/

throw new Error();

throw new Error("error");
throw new Error('error');

const e = new Error("error");
const e = new Error('error');
throw e;

try {
throw new Error("error");
throw new Error('error');
} catch (e) {
throw e;
throw e;
}

const err = new Error();
Expand All @@ -77,13 +73,13 @@ function err() {
throw err();

const foo = {
bar: new Error();
}
bar: new Error(),
};
throw foo.bar;

class CustomError extends Error {
// ...
};
}
throw new CustomError();
```

Expand Down