Skip to content

Commit

Permalink
Fix throwing non-new Errors and literals (#1338)
Browse files Browse the repository at this point in the history
* Add linting to enforce `new Error()`
* Fix throwing non-new Errors and literals
  • Loading branch information
ddbeck committed Jul 12, 2024
1 parent 9ec0c3a commit 9189c4c
Show file tree
Hide file tree
Showing 10 changed files with 1,308 additions and 326 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Opt-ins
!GOVERNANCE.md
!eslint.config.js

!/features/*.yml
/features/*.yml.dist
Expand Down
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import newWithError from "eslint-plugin-new-with-error";
import tseslint from "typescript-eslint";

export default tseslint.config(tseslint.configs.base, {
plugins: { newWithError },
rules: {
"no-throw-literal": "error",
"newWithError/new-with-error": "error",
},
files: ["**/*.ts"],
});

// TODO: do linting more comprehensively, something like:
// import eslint from "@eslint/js";
// export default tseslint.config(
// eslint.configs.recommendedTypeChecked,
// ...tseslint.configs.recommended,
// {
// plugins: { newWithError },
// rules: {
// "no-throw-literal": "error",
// "newWithError/new-with-error": "error",
// },
// );
Loading

0 comments on commit 9189c4c

Please # to comment.