diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/es6-error | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/es6-error')
-rw-r--r-- | node_modules/es6-error/.editorconfig | 7 | ||||
-rw-r--r-- | node_modules/es6-error/.npmignore | 1 | ||||
-rw-r--r-- | node_modules/es6-error/.travis.yml | 7 | ||||
-rw-r--r-- | node_modules/es6-error/CHANGELOG.md | 26 | ||||
-rw-r--r-- | node_modules/es6-error/LICENSE.md | 21 | ||||
-rw-r--r-- | node_modules/es6-error/README.md | 55 | ||||
-rw-r--r-- | node_modules/es6-error/babel-config.js | 31 | ||||
-rw-r--r-- | node_modules/es6-error/bower.json | 22 | ||||
-rw-r--r-- | node_modules/es6-error/lib/index.d.ts | 1 | ||||
-rw-r--r-- | node_modules/es6-error/lib/index.js | 79 | ||||
-rw-r--r-- | node_modules/es6-error/lib/index.jsnext.js | 72 | ||||
-rw-r--r-- | node_modules/es6-error/lib/index.ts.js | 78 | ||||
-rw-r--r-- | node_modules/es6-error/package.json | 42 | ||||
-rw-r--r-- | node_modules/es6-error/src/index.js | 34 | ||||
-rw-r--r-- | node_modules/es6-error/test/index.js | 64 |
15 files changed, 540 insertions, 0 deletions
diff --git a/node_modules/es6-error/.editorconfig b/node_modules/es6-error/.editorconfig new file mode 100644 index 000000000..221883624 --- /dev/null +++ b/node_modules/es6-error/.editorconfig @@ -0,0 +1,7 @@ +[*] +insert_final_newline = true +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/node_modules/es6-error/.npmignore b/node_modules/es6-error/.npmignore new file mode 100644 index 000000000..166f3fa9f --- /dev/null +++ b/node_modules/es6-error/.npmignore @@ -0,0 +1 @@ +.babelrc
diff --git a/node_modules/es6-error/.travis.yml b/node_modules/es6-error/.travis.yml new file mode 100644 index 000000000..7994fafec --- /dev/null +++ b/node_modules/es6-error/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "stable" + - "4.1" + - "4.0" + - "0.10" + diff --git a/node_modules/es6-error/CHANGELOG.md b/node_modules/es6-error/CHANGELOG.md new file mode 100644 index 000000000..9e82c81bf --- /dev/null +++ b/node_modules/es6-error/CHANGELOG.md @@ -0,0 +1,26 @@ +# Change Log + +## [v4.0.1] - 2017-01-04 +### Fixed + - jsnext build uses `babel-plugin-transform-builtin-extend` (#27) + +## [v4.0.0] - 2016-10-03 +### Added + - jsnext build (#26) + +## [v3.2.0] - 2016-09-29 +### Added + - TypeScript definitions (#24) + +## [v3.1.0] - 2016-09-08 +### Changed + - Point jsnext build to transpiled code (#23) + +## [v3.0.1] - 2016-07-14 +### Changed + - Move Babel config to `.babelrc` (#20) + +## [v3.0.0] - 2016-05-18 +### Changed + - Upgrade to Babel 6 (#16) + - Make `message`, `name`, and `stack` properties configurable (to match built-in `Error`) (#17) diff --git a/node_modules/es6-error/LICENSE.md b/node_modules/es6-error/LICENSE.md new file mode 100644 index 000000000..4737fd103 --- /dev/null +++ b/node_modules/es6-error/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Ben Youngblood + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/es6-error/README.md b/node_modules/es6-error/README.md new file mode 100644 index 000000000..30c95dbbc --- /dev/null +++ b/node_modules/es6-error/README.md @@ -0,0 +1,55 @@ +# es6-error + +[](https://www.npmjs.com/package/es6-error) +[](https://travis-ci.org/bjyoungblood/es6-error) + +An easily-extendable error class for use with ES6 classes (or ES5, if you so +choose). + +Tested in Node 4.0, Chrome, and Firefox. + +## Why? + +I made this because I wanted to be able to extend Error for inheritance and type +checking, but can never remember to add +`Error.captureStackTrace(this, this.constructor.name)` to the constructor or how +to get the proper name to print from `console.log`. + +## ES6 Usage + +```javascript + +import ExtendableError from 'es6-error'; + +class MyError extends ExtendableError { + // constructor is optional; you should omit it if you just want a custom error + // type for inheritance and type checking + constructor(message = 'Default message') { + super(message); + } +} + +export default MyError; +``` + +## ES5 Usage + +```javascript + +var util = require('util'); +var ExtendableError = require('es6-error'); + +function MyError(message) { + message = message || 'Default message'; + ExtendableError.call(this, message); +} + +util.inherits(MyError, ExtendableError); + +module.exports = MyError; +``` + +#### Todo + +- Better browser compatibility +- Browser tests diff --git a/node_modules/es6-error/babel-config.js b/node_modules/es6-error/babel-config.js new file mode 100644 index 000000000..a932d5db9 --- /dev/null +++ b/node_modules/es6-error/babel-config.js @@ -0,0 +1,31 @@ +'use strict'; + +var plugins = [ + [ + "babel-plugin-transform-builtin-extend", + { + "globals": ["Error"], + "approximate": true + } + ] +]; + +var env = process.env.BABEL_ENV || process.env.NODE_ENV; + +var modules; + +if (env === 'es') { + modules = false; +} else if (env === 'ts') { + modules = 'commonjs'; +} else { + modules = 'commonjs'; + plugins.push('add-module-exports'); +} + +module.exports = { + "presets": [ + ["es2015", { modules: modules }] + ], + "plugins": plugins +}; diff --git a/node_modules/es6-error/bower.json b/node_modules/es6-error/bower.json new file mode 100644 index 000000000..9a6f0fa9b --- /dev/null +++ b/node_modules/es6-error/bower.json @@ -0,0 +1,22 @@ +{ + "name": "es6-error", + "description": "Easily-extendable error for use with ES6 classes", + "main": "dist/index.js", + "authors": [ + "Ben Youngblood" + ], + "license": "MIT", + "keywords": [ + "es6", + "error", + "babel" + ], + "homepage": "https://github.com/bjyoungblood/es6-error", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/node_modules/es6-error/lib/index.d.ts b/node_modules/es6-error/lib/index.d.ts new file mode 100644 index 000000000..c1b1f12f8 --- /dev/null +++ b/node_modules/es6-error/lib/index.d.ts @@ -0,0 +1 @@ +export default class ExtendableError extends Error { } diff --git a/node_modules/es6-error/lib/index.js b/node_modules/es6-error/lib/index.js new file mode 100644 index 000000000..617bef718 --- /dev/null +++ b/node_modules/es6-error/lib/index.js @@ -0,0 +1,79 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _extendableBuiltin(cls) { + function ExtendableBuiltin() { + cls.apply(this, arguments); + } + + ExtendableBuiltin.prototype = Object.create(cls.prototype, { + constructor: { + value: cls, + enumerable: false, + writable: true, + configurable: true + } + }); + + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ExtendableBuiltin, cls); + } else { + ExtendableBuiltin.__proto__ = cls; + } + + return ExtendableBuiltin; +} + +var ExtendableError = function (_extendableBuiltin2) { + _inherits(ExtendableError, _extendableBuiltin2); + + function ExtendableError() { + var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + _classCallCheck(this, ExtendableError); + + // extending Error is weird and does not propagate `message` + var _this = _possibleConstructorReturn(this, (ExtendableError.__proto__ || Object.getPrototypeOf(ExtendableError)).call(this, message)); + + Object.defineProperty(_this, 'message', { + configurable: true, + enumerable: false, + value: message, + writable: true + }); + + Object.defineProperty(_this, 'name', { + configurable: true, + enumerable: false, + value: _this.constructor.name, + writable: true + }); + + if (Error.hasOwnProperty('captureStackTrace')) { + Error.captureStackTrace(_this, _this.constructor); + return _possibleConstructorReturn(_this); + } + + Object.defineProperty(_this, 'stack', { + configurable: true, + enumerable: false, + value: new Error(message).stack, + writable: true + }); + return _this; + } + + return ExtendableError; +}(_extendableBuiltin(Error)); + +exports.default = ExtendableError; +module.exports = exports['default']; diff --git a/node_modules/es6-error/lib/index.jsnext.js b/node_modules/es6-error/lib/index.jsnext.js new file mode 100644 index 000000000..70fbfbcfd --- /dev/null +++ b/node_modules/es6-error/lib/index.jsnext.js @@ -0,0 +1,72 @@ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _extendableBuiltin(cls) { + function ExtendableBuiltin() { + cls.apply(this, arguments); + } + + ExtendableBuiltin.prototype = Object.create(cls.prototype, { + constructor: { + value: cls, + enumerable: false, + writable: true, + configurable: true + } + }); + + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ExtendableBuiltin, cls); + } else { + ExtendableBuiltin.__proto__ = cls; + } + + return ExtendableBuiltin; +} + +var ExtendableError = function (_extendableBuiltin2) { + _inherits(ExtendableError, _extendableBuiltin2); + + function ExtendableError() { + var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + _classCallCheck(this, ExtendableError); + + // extending Error is weird and does not propagate `message` + var _this = _possibleConstructorReturn(this, (ExtendableError.__proto__ || Object.getPrototypeOf(ExtendableError)).call(this, message)); + + Object.defineProperty(_this, 'message', { + configurable: true, + enumerable: false, + value: message, + writable: true + }); + + Object.defineProperty(_this, 'name', { + configurable: true, + enumerable: false, + value: _this.constructor.name, + writable: true + }); + + if (Error.hasOwnProperty('captureStackTrace')) { + Error.captureStackTrace(_this, _this.constructor); + return _possibleConstructorReturn(_this); + } + + Object.defineProperty(_this, 'stack', { + configurable: true, + enumerable: false, + value: new Error(message).stack, + writable: true + }); + return _this; + } + + return ExtendableError; +}(_extendableBuiltin(Error)); + +export default ExtendableError; diff --git a/node_modules/es6-error/lib/index.ts.js b/node_modules/es6-error/lib/index.ts.js new file mode 100644 index 000000000..ad1920c58 --- /dev/null +++ b/node_modules/es6-error/lib/index.ts.js @@ -0,0 +1,78 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _extendableBuiltin(cls) { + function ExtendableBuiltin() { + cls.apply(this, arguments); + } + + ExtendableBuiltin.prototype = Object.create(cls.prototype, { + constructor: { + value: cls, + enumerable: false, + writable: true, + configurable: true + } + }); + + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ExtendableBuiltin, cls); + } else { + ExtendableBuiltin.__proto__ = cls; + } + + return ExtendableBuiltin; +} + +var ExtendableError = function (_extendableBuiltin2) { + _inherits(ExtendableError, _extendableBuiltin2); + + function ExtendableError() { + var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + _classCallCheck(this, ExtendableError); + + // extending Error is weird and does not propagate `message` + var _this = _possibleConstructorReturn(this, (ExtendableError.__proto__ || Object.getPrototypeOf(ExtendableError)).call(this, message)); + + Object.defineProperty(_this, 'message', { + configurable: true, + enumerable: false, + value: message, + writable: true + }); + + Object.defineProperty(_this, 'name', { + configurable: true, + enumerable: false, + value: _this.constructor.name, + writable: true + }); + + if (Error.hasOwnProperty('captureStackTrace')) { + Error.captureStackTrace(_this, _this.constructor); + return _possibleConstructorReturn(_this); + } + + Object.defineProperty(_this, 'stack', { + configurable: true, + enumerable: false, + value: new Error(message).stack, + writable: true + }); + return _this; + } + + return ExtendableError; +}(_extendableBuiltin(Error)); + +exports.default = ExtendableError; diff --git a/node_modules/es6-error/package.json b/node_modules/es6-error/package.json new file mode 100644 index 000000000..72c306d92 --- /dev/null +++ b/node_modules/es6-error/package.json @@ -0,0 +1,42 @@ +{ + "name": "es6-error", + "version": "4.0.2", + "description": "Easily-extendable error for use with ES6 classes", + "main": "./lib/index", + "jsnext:main": "./lib/index.jsnext.js", + "typings": "./lib/index.d.ts", + "scripts": { + "test": "mocha --compilers js:babel-core/register --recursive", + "build": "npm run build:commonjs && npm run build:es && npm run build:ts", + "build:commonjs": "cross-env BABEL_ENV=commonjs babel src/index.js --out-file lib/index.js", + "build:es": "cross-env BABEL_ENV=es babel src/index.js --out-file lib/index.jsnext.js", + "build:ts": "cross-env BABEL_ENV=ts babel src/index.js --out-file lib/index.ts.js", + "prepublish": "npm run build && npm run test" + }, + "repository": { + "type": "git", + "url": "https://github.com/bjyoungblood/es6-error.git" + }, + "keywords": [ + "es6", + "error", + "babel" + ], + "author": "Ben Youngblood", + "license": "MIT", + "bugs": { + "url": "https://github.com/bjyoungblood/es6-error/issues" + }, + "homepage": "https://github.com/bjyoungblood/es6-error", + "devDependencies": { + "babel-cli": "^6.8.0", + "babel-core": "^6.8.0", + "babel-plugin-add-module-exports": "^0.1.4", + "babel-plugin-transform-builtin-extend": "^1.1.0", + "babel-preset-es2015": "^6.6.0", + "chai": "^3.2.0", + "cross-env": "^2.0.1", + "mocha": "^2.4.5" + }, + "dependencies": {} +} diff --git a/node_modules/es6-error/src/index.js b/node_modules/es6-error/src/index.js new file mode 100644 index 000000000..e52b1613c --- /dev/null +++ b/node_modules/es6-error/src/index.js @@ -0,0 +1,34 @@ +class ExtendableError extends Error { + constructor(message = '') { + super(message); + + // extending Error is weird and does not propagate `message` + Object.defineProperty(this, 'message', { + configurable: true, + enumerable : false, + value : message, + writable : true, + }); + + Object.defineProperty(this, 'name', { + configurable: true, + enumerable : false, + value : this.constructor.name, + writable : true, + }); + + if (Error.hasOwnProperty('captureStackTrace')) { + Error.captureStackTrace(this, this.constructor); + return; + } + + Object.defineProperty(this, 'stack', { + configurable: true, + enumerable : false, + value : (new Error(message)).stack, + writable : true, + }); + } +} + +export default ExtendableError; diff --git a/node_modules/es6-error/test/index.js b/node_modules/es6-error/test/index.js new file mode 100644 index 000000000..7e98e2de5 --- /dev/null +++ b/node_modules/es6-error/test/index.js @@ -0,0 +1,64 @@ +import { expect } from 'chai'; +import ExtendableError from '../src/index'; + +class TestError extends ExtendableError {} +class SubTestError extends TestError {} + +describe('ExtendableError', () => { + it('instance of', () => { + let err = new ExtendableError(); + expect(err).to.be.an.instanceof(Error); + expect(err).to.be.an.instanceof(ExtendableError); + + let err2 = new TestError(); + expect(err2).to.be.an.instanceof(Error); + expect(err2).to.be.an.instanceof(ExtendableError); + expect(err2).to.be.an.instanceof(TestError); + + let err3 = new SubTestError(); + expect(err3).to.be.an.instanceof(Error); + expect(err3).to.be.an.instanceof(ExtendableError); + expect(err3).to.be.an.instanceof(TestError); + expect(err3).to.be.an.instanceof(SubTestError); + }); + + it('.name', () => { + let err = new ExtendableError(); + expect(err.name).to.equal('ExtendableError'); + + let err2 = new TestError(); + expect(err2.name).to.equal('TestError'); + + let err3 = new SubTestError(); + expect(err3.name).to.equal('SubTestError'); + }); + + it('name is not enumerable', () => { + let err = new ExtendableError(); + expect(err.propertyIsEnumerable('name')).to.be.false; + }); + + it('.stack', () => { + let err = new ExtendableError(); + expect(err.stack).to.be.a('string'); + + let err2 = new TestError(); + expect(err2.stack).to.be.a('string'); + }); + + it('#toString', () => { + let err = new ExtendableError(); + expect(err.toString()).to.equal('ExtendableError'); + + let err2 = new TestError(); + expect(err2.toString()).to.equal('TestError'); + + let err3 = new SubTestError(); + expect(err3.toString()).to.equal('SubTestError'); + }); + + it('.message', () => { + let err = new ExtendableError('error occurred'); + expect(err.message).to.equal('error occurred'); + }) +}); |