diff options
Diffstat (limited to 'node_modules/babel-plugin-check-es2015-constants')
4 files changed, 153 insertions, 0 deletions
diff --git a/node_modules/babel-plugin-check-es2015-constants/.npmignore b/node_modules/babel-plugin-check-es2015-constants/.npmignore new file mode 100644 index 0000000..3185290 --- /dev/null +++ b/node_modules/babel-plugin-check-es2015-constants/.npmignore @@ -0,0 +1,4 @@ +node_modules +*.log +src +test diff --git a/node_modules/babel-plugin-check-es2015-constants/README.md b/node_modules/babel-plugin-check-es2015-constants/README.md new file mode 100644 index 0000000..608891b --- /dev/null +++ b/node_modules/babel-plugin-check-es2015-constants/README.md @@ -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/). diff --git a/node_modules/babel-plugin-check-es2015-constants/lib/index.js b/node_modules/babel-plugin-check-es2015-constants/lib/index.js new file mode 100644 index 0000000..f4a43ea --- /dev/null +++ b/node_modules/babel-plugin-check-es2015-constants/lib/index.js @@ -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"];
\ No newline at end of file diff --git a/node_modules/babel-plugin-check-es2015-constants/package.json b/node_modules/babel-plugin-check-es2015-constants/package.json new file mode 100644 index 0000000..f6bd847 --- /dev/null +++ b/node_modules/babel-plugin-check-es2015-constants/package.json @@ -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-es2015" + ], + "_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/pruss/Dev/3-minute-website/node_modules/babel-preset-es2015", + "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" +} |