GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: disallow constructing an Error without using it · nodejs/node@622bc2e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/error
    • error.js
  • test/parallel
    • test-errors-systemerror.js
  • tools/eslint
    • eslint.config_utils.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/error/error.js‎

Copy file name to clipboardExpand all lines: benchmark/error/error.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const bench = common.createBenchmark(main, {
99
function main({ n }) {
1010
bench.start();
1111
for (let i = 0; i < n; ++i)
12+
// eslint-disable-next-line no-restricted-syntax
1213
new Error('test');
1314
bench.end(n);
1415
}
Collapse file

‎test/parallel/test-errors-systemerror.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-errors-systemerror.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { E, SystemError, codes, kIsNodeError } = require('internal/errors');
77
const { inspect } = require('internal/util/inspect');
88

99
assert.throws(
10+
// eslint-disable-next-line no-restricted-syntax
1011
() => { new SystemError(); },
1112
{
1213
name: 'TypeError',
Collapse file

‎tools/eslint/eslint.config_utils.mjs‎

Copy file name to clipboardExpand all lines: tools/eslint/eslint.config_utils.mjs
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export const noRestrictedSyntaxCommonAll = [
1616
selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]',
1717
message: 'Use `new` keyword when throwing an `Error`.',
1818
},
19+
{
20+
selector: 'ExpressionStatement > NewExpression[callee.name=/Error$/]',
21+
message: 'Throw, return, or assign the `Error`; constructing it alone does nothing.',
22+
},
1923
{
2024
selector: "CallExpression[callee.property.name='substr']",
2125
message: 'Use String.prototype.slice() or String.prototype.substring() instead of String.prototype.substr()',

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.