Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,59 @@
# babel-plugin-check-es2015-constants
Validate ES2015 constants (prevents reassignment of const variables).
## Example
**In**
```js
const a = 1;
a = 2;
```
**Out**
```bash
repl: "a" is read-only
1 | const a = 1;
> 2 | a = 2;
| ^
```
[Try in REPL](http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015&experimental=false&loose=false&spec=false&code=const%20a%20%3D%201%3B%0Aa%20%3D%202%3B&playground=true)
## Installation
```sh
npm install --save-dev babel-plugin-check-es2015-constants
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["check-es2015-constants"]
}
```
### Via CLI
```sh
babel --plugins check-es2015-constants script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["check-es2015-constants"]
});
```
## Note
This check will only validate consts. If you need it to compile down to `var` then you must also install and enable [`transform-es2015-block-scoping`](http://babeljs.io/docs/plugins/transform-es2015-block-scoping/).

View File

@ -0,0 +1,45 @@
"use strict";
exports.__esModule = true;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.default = function (_ref) {
var messages = _ref.messages;
return {
visitor: {
Scope: function Scope(_ref2) {
var scope = _ref2.scope;
for (var name in scope.bindings) {
var binding = scope.bindings[name];
if (binding.kind !== "const" && binding.kind !== "module") continue;
for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref3;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref3 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref3 = _i.value;
}
var violation = _ref3;
throw violation.buildCodeFrameError(messages.get("readOnly", name));
}
}
}
}
};
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports["default"];

View File

@ -0,0 +1,45 @@
{
"_from": "babel-plugin-check-es2015-constants@^6.22.0",
"_id": "babel-plugin-check-es2015-constants@6.22.0",
"_inBundle": false,
"_integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=",
"_location": "/babel-plugin-check-es2015-constants",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "babel-plugin-check-es2015-constants@^6.22.0",
"name": "babel-plugin-check-es2015-constants",
"escapedName": "babel-plugin-check-es2015-constants",
"rawSpec": "^6.22.0",
"saveSpec": null,
"fetchSpec": "^6.22.0"
},
"_requiredBy": [
"/babel-preset-env"
],
"_resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz",
"_shasum": "35157b101426fd2ffd3da3f75c7d1e91835bbf8a",
"_spec": "babel-plugin-check-es2015-constants@^6.22.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/babel-preset-env",
"bundleDependencies": false,
"dependencies": {
"babel-runtime": "^6.22.0"
},
"deprecated": false,
"description": "Compile ES2015 constants to ES5",
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.22.0"
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "babel-plugin-check-es2015-constants",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-check-es2015-constants"
},
"version": "6.22.0"
}