开发者社区> 镜像站> NPM> @babel/plugin-check-constants
@babel/plugin-check-constants
Compile ES2015 constants to ES5
Last updated 3 years ago by hzoo .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @babel/plugin-check-constants 
SYNC missed versions from official npm registry.

@babel/plugin-check-constants

Validate ES2015 constants (prevents reassignment of const variables).

Example

In

const a = 1;
a = 2;

Out

repl: "a" is read-only
  1 | const a = 1;
> 2 | a = 2;
    | ^

Installation

npm install --save-dev @babel/plugin-check-constants

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@babel/check-constants"]
}

Via CLI

babel --plugins @babel/check-constants script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/check-constants"]
});

Note

This check will only validate consts. If you need it to compile down to var then you must also install and enable @babel/plugin-transform-block-scoping.

Current Tags

  • 7.0.0-beta.38                                ...           latest (3 years ago)

10 Versions

  • 7.0.0-beta.38                                ...           3 years ago
  • 7.0.0-beta.37                                ...           3 years ago
  • 7.0.0-beta.36                                ...           3 years ago
  • 7.0.0-beta.35                                ...           3 years ago
  • 7.0.0-beta.34                                ...           3 years ago
  • 7.0.0-beta.33                                ...           3 years ago
  • 7.0.0-beta.32                                ...           3 years ago
  • 7.0.0-beta.31                                ...           3 years ago
  • 7.0.0-beta.5                                ...           3 years ago
  • 7.0.0-beta.4                                ...           3 years ago