JSPM

@putout/plugin-add-missing-new

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q49049F
  • License MIT

🐊Putout plugin adds ability to add missing operator 'new'

Package Exports

  • @putout/plugin-add-missing-new
  • @putout/plugin-add-missing-new/lib/add-missing-new.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/plugin-add-missing-new) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/plugin-add-missing-new NPM version

The Set constructor lets you create Set objects that store unique values of any type, whether primitive values or object references.

(c) MDN

🐊Putout plugin adds ability to add missing operator new, since built-in objects:

  • Set;
  • WeakSet;
  • Map;
  • WeakMap;
  • Int8Array;
  • Uint8Array;
  • Uint8ClampedArray;
  • Int16Array;
  • Uint16Array;
  • Int32Array;
  • Uint32Array;
  • Float32Array;
  • Float64Array;
  • BigInt64Array;
  • BigUint64Array;

Produces TypeError when called without new like this:

Uncaught TypeError: Constructor Set requires 'new'

Part of @putout/plugin-new.

Install

npm i @putout/plugin-add-missing-new

Rule

{
    "rules": {
        "add-missing-new": "on"
    }
}

❌ Example of incorrect code

const map = Map();

βœ… Example of correct code

const map = new Map();

License

MIT