question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Rule: `no-new-bigint`

See original GitHub issue

Rule details

Restricts calling BigInt with new like no-new-symbol

Related ECMAScript feature

BigInt

What type of rule is this?

Warns about a potential problem

Example code

// valid
const a = BigInt(9007199254740991);

// invalid
const b = new BigInt(9007199254740991);

Why should this rule be in the core instead of a plugin?

BigInt is a core feature of ECMAScript, also ESLint have no-new-symbol already.

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Sep 24, 2022

I’m not sure it’s valuable to start going down the path of creating a new rule for each function that looks like a constructor.

I agree. If we want to warn on new BigInt, then it might be better to add a rule that would warn on all ES globals that start with an uppercase letter but are not constructors (except those that are not functions, because they are included in no-obj-calls). It would include new Symbol, so the no-new-symbol rule would be deprecated.

0reactions
sosukesuzukicommented, Sep 30, 2022

I prefer no-new-nonconstructor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rule Request: Disallow native bigint operations on polyfilled ...
The only feasible solution here is to have a lint rule to not use the native bigint operations. Essentially changing the meaning of...
Read more >
BigInt - JavaScript - MDN Web Docs
BigInt values represent numeric values which are too large to be represented by the number primitive.
Read more >
The Essential Guide To JavaScript's Newest Data Type: BigInt
BigInt is a new data type intended for use when integer values are larger than the range supported by the Number data type....
Read more >
jsonc/no-bigint-literals | eslint-plugin-jsonc
This rule reports the use of BigInt literals. JSON, JSONC and JSON5 do not allow BigInt literals. 1. 2.
Read more >
18 Bigints – arbitrary-precision integers [ES2020] (advanced)
Bigint is a new primitive data type for integers. ... The reason for this rule is that there is no general way of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found