# why - to enforce best practices in error handling by requiring the cause of a given error to be included in the error that gets thrown # what changed - added the `preserve-caught-error` lint rule - updated calls that were not preserving caught errors - also bumped eslint version & typescript eslint for compatibility with the new rule <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds an ESLint rule to require preserving the original error when rethrowing, updates code to pass error causes, and fixes related linting issues. This improves debugging by linking errors via the cause option. - **Dependencies** - ESLint → 10.0.2 - @eslint/js → 10.0.1 - typescript-eslint → 8.56.1 <sup>Written for commit b4cd5039b34b8156a1b55a88196d9aabc97c51d7. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1745">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. -->
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
import globals from "globals";
|
|
import pluginJs from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import security from "eslint-plugin-security";
|
|
|
|
/** @type {import('eslint').Linter.Config[]} */
|
|
export default [
|
|
{ files: ["**/*.{js,mjs,cjs,ts}"] },
|
|
{ languageOptions: { globals: globals.browser } },
|
|
{
|
|
files: ["packages/core/scripts/**/*.{js,cjs,mjs}"],
|
|
languageOptions: { globals: globals.node },
|
|
},
|
|
{
|
|
files: ["packages/server/scripts/**/*.{js,cjs,mjs,ts}"],
|
|
languageOptions: { globals: globals.node },
|
|
},
|
|
{
|
|
ignores: [
|
|
"**/dist/**",
|
|
"**/node_modules/**",
|
|
"packages/core/lib/dom/build/**",
|
|
"packages/core/lib/v3/dom/build/**",
|
|
"packages/core/scripts/prepare.js",
|
|
"**/*.config.js",
|
|
"**/*.config.mjs",
|
|
".browserbase/**",
|
|
"**/.browserbase/**",
|
|
"**/*.json",
|
|
"stainless.yml",
|
|
"packages/server/openapi.v3.yaml",
|
|
],
|
|
},
|
|
pluginJs.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
{
|
|
plugins: {
|
|
security,
|
|
},
|
|
rules: {
|
|
"no-eval": "error",
|
|
"no-implied-eval": "error",
|
|
"no-new-func": "error",
|
|
"security/detect-eval-with-expression": "error",
|
|
"preserve-caught-error": "error",
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
{
|
|
selector: "CallExpression[callee.name='Function']",
|
|
message: "Dynamic function construction is prohibited.",
|
|
},
|
|
{
|
|
selector: "NewExpression[callee.name='Function']",
|
|
message: "Dynamic function construction is prohibited.",
|
|
},
|
|
{
|
|
selector:
|
|
"CallExpression[callee.object.name='window'][callee.property.name='Function']",
|
|
message:
|
|
"Dynamic function construction via window.Function is prohibited.",
|
|
},
|
|
{
|
|
selector:
|
|
"CallExpression[callee.object.name='globalThis'][callee.property.name='Function']",
|
|
message:
|
|
"Dynamic function construction via globalThis.Function is prohibited.",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
];
|