From c01de42ecc83effffa383ff2151f19202ba22311 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:35:11 +0100 Subject: [PATCH 01/17] Bring in modern lint setup. --- .editorconfig | 12 ++++ .eslintignore | 1 + .eslintrc | 16 ++++++ .jshintignore | 3 - .jshintrc | 154 -------------------------------------------------- package.json | 11 +++- 6 files changed, 38 insertions(+), 159 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc delete mode 100644 .jshintignore delete mode 100644 .jshintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2973317 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true +indent_size = 4 +indent_style = space + +[*.{json,yml}] +indent_size = 2 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ca1cc78 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +magicpen.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..43ecbeb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,16 @@ +{ + "extends": ["standard", "prettier", "prettier/standard"], + "plugins": ["import", "mocha"], + "env": { + "mocha": true + }, + "rules": { + "camelcase": "off", + "dot-notation": "off", + "no-useless-escape": "off", + "spaced-comment": "off", + "mocha/no-exclusive-tests": "error", + "mocha/no-nested-tests": "error", + "mocha/no-identical-title": "error" + } +} diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index fe58669..0000000 --- a/.jshintignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -coverage -magicpen.js diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 23a5ed2..0000000 --- a/.jshintrc +++ /dev/null @@ -1,154 +0,0 @@ -// Defaults as of jshint edition 2011-04-16 - -{ - // If the scan should stop on first error. - "passfail": false, - // Maximum errors before stopping. - "maxerr": 50, - - - // Predefined globals - - // If the standard browser globals should be predefined. - "browser": false, - // If the Node.js environment globals should be predefined. - "node": false, - // If the Rhino environment globals should be predefined. - "rhino": false, - // If CouchDB globals should be predefined. - "couch": false, - // If the Windows Scripting Host environment globals should be predefined. - "wsh": false, - - // If jQuery globals should be predefined. - "jquery": false, - // If Prototype and Scriptaculous globals should be predefined. - "prototypejs": false, - // If MooTools globals should be predefined. - "mootools": false, - // If Dojo Toolkit globals should be predefined. - "dojo": false, - - // Custom predefined globals. - "predef": ["process", "module", "exports", "require", "Buffer", "define"], - - // Development - - // If debugger statements should be allowed. - "debug": false, - // If logging globals should be predefined (console, alert, etc.). - "devel": false, - - - // Legacy JS environments - - // If we should warn about reserved words as property names etc - "es3": true, - - - // ECMAScript 5 - - // If ES5 syntax should be allowed. - "es5": false, - // Require the "use strict"; pragma. - "strict": false, - // If global "use strict"; should be allowed (also enables strict). - "globalstrict": false, - - - // The Good Parts - - // If automatic semicolon insertion should be tolerated. - "asi": false, - // If line breaks should not be checked, e.g. `return [\n] x`. - "laxbreak": false, - // If bitwise operators (&, |, ^, etc.) should not be allowed. - "bitwise": false, - // If assignments inside if, for and while should be allowed. Usually - // conditions and loops are for comparison, not assignments. - "boss": false, - // If curly braces around all blocks should be required. - "curly": false, - // If === should be required. - "eqeqeq": true, - // If == null comparisons should be tolerated. - "eqnull": false, - // If eval should be allowed. - "evil": false, - // If ExpressionStatement should be allowed as Programs. - "expr": false, - // If `for in` loops must filter with `hasOwnPrototype`. - "forin": false, - // If immediate invocations must be wrapped in parens, e.g. - // `( function(){}() );`. - "immed": true, - // If use before define should not be tolerated. - "latedef": false, - // If functions should be allowed to be defined within loops. - "loopfunc": true, - // If arguments.caller and arguments.callee should be disallowed. - "noarg": false, - // If the . should not be allowed in regexp literals. - "regexp": false, - // If unescaped first/last dash (-) inside brackets should be tolerated. - "regexdash": false, - // If script-targeted URLs should be tolerated. - "scripturl": false, - // If variable shadowing should be tolerated. - "shadow": false, - // If `new function () { ... };` and `new Object;` should be tolerated. - "supernew": false, - // If variables should be declared before used. - "undef": true, - // If variables defined but not used are checked. - "unused": "vars", - // If `this` inside a non-constructor function is valid. - "validthis": false, - // If smarttabs should be tolerated - // (http://www.emacswiki.org/emacs/SmartTabs). - "smarttabs": false, - // If the `__proto__` property should be allowed. - "proto": false, - // If one case switch statements should be allowed. - "onecase": false, - // If non-standard (but widely adopted) globals should be predefined. - "nonstandard": false, - // Allow multiline strings. - "multistr": false, - // If line breaks should not be checked around commas. - "laxcomma": false, - // If semicolons may be ommitted for the trailing statements inside of a - // one-line blocks. - "lastsemic": false, - // If the `__iterator__` property should be allowed. - "iterator": false, - // If only function scope should be used for scope tests. - "funcscope": false, - // If es.next specific syntax should be allowed. - "esnext": false, - - - // Style preferences - - // If constructor names must be capitalized. - "newcap": true, - // If empty blocks should be disallowed. - "noempty": false, - // If using `new` for side-effects should be disallowed. - "nonew": false, - // If names should be checked for leading or trailing underscores - // (object._attribute would be disallowed). - "nomen": false, - // If only one var statement per function should be allowed. - "onevar": false, - // If increment and decrement (`++` and `--`) should not be allowed. - "plusplus": true, - // If square bracket syntax for property access is tolerated. - "sub": true, - // If trailing whitespace rules apply. - "trailing": true, - // If strict whitespace rules apply. - "white": true, - // Specify indentation. - "indent": 4 -} diff --git a/package.json b/package.json index 8a4e210..caaac83 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/sunesimonsen/magicpen.git" }, "scripts": { - "lint": "jshint .", + "lint": "eslint .", "test": "npm run lint && mocha -R spec", "travis": "npm test && npm run coverage && ( magicpen.js", @@ -23,8 +23,15 @@ "bundle-collapser": "1.1.1", "coveralls": "2.11.1", "del": "0.1.1", + "eslint": "^6.0.0", + "eslint-config-prettier": "^6.0.0", + "eslint-config-standard": "^14.0.1", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-mocha": "^6.0.0", + "eslint-plugin-node": "^10.0.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.0", "istanbul": "0.3.17", - "jshint": "*", "mocha": "1.20.1", "sinon": "1.9.1", "unexpected": "9.5.0", From d8f803718cb3be3534ff22d0deda79bb68752ee3 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:37:09 +0100 Subject: [PATCH 02/17] Avoid void 0 where the variable needs initializing as undefined. --- lib/supportsColor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/supportsColor.js b/lib/supportsColor.js index e768a58..d234aa1 100644 --- a/lib/supportsColor.js +++ b/lib/supportsColor.js @@ -12,7 +12,7 @@ var hasFlag = function hasFlag(flag, argv) { // Fork from https://github.com/chalk/supports-color var env = platform.env; -var forceColor = void 0; +var forceColor; if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) { forceColor = 0; } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { From c1ebb458dc2de2664ba57409b9b7137758cedb07 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:42:18 +0100 Subject: [PATCH 03/17] Avoid hasOwnProperty() in a test file. --- test/magicpen.spec.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/magicpen.spec.js b/test/magicpen.spec.js index 3004e22..3df179a 100644 --- a/test/magicpen.spec.js +++ b/test/magicpen.spec.js @@ -1330,12 +1330,7 @@ describe('magicpen', function () { if (obj && typeof obj === 'object') { this.text('{').nl() .indentLines(); - var keys = []; - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - keys.push(prop); - } - } + var keys = Object.keys(obj); for (var i = 0; i < keys.length; i += 1) { var key = keys[i]; this.i().cyan(key).text(': ').object(obj[key]); From 088129acf473e043b1dc59cd498830930a6228a8 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:40:42 +0100 Subject: [PATCH 04/17] Fix a couple of lint failures of the "yoda" rule. --- lib/MagicPen.js | 4 ++-- lib/themeMapper.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/MagicPen.js b/lib/MagicPen.js index c3fa5cb..210db65 100644 --- a/lib/MagicPen.js +++ b/lib/MagicPen.js @@ -428,7 +428,7 @@ MagicPen.prototype.prependLinesWith = function () { var output = this.clone(); output.block(function () { for (var i = 0; i < height; i += 1) { - if (0 < i) { + if (i > 0) { this.nl(); } this.append(pen); @@ -563,7 +563,7 @@ MagicPen.prototype.installPlugin = MagicPen.prototype.use; // Legacy alias function replaceText(output, outputArray, regexp, cb) { var replacedOutput = output; outputArray.forEach(function (line, i) { - if (0 < i) { + if (i > 0) { replacedOutput.nl(); } diff --git a/lib/themeMapper.js b/lib/themeMapper.js index 5f67072..6cf7f2d 100644 --- a/lib/themeMapper.js +++ b/lib/themeMapper.js @@ -7,7 +7,7 @@ module.exports = function (theme, styles) { while(typeof themeMapping === 'string' && themeStyles[themeMapping]) { themeMapping = themeStyles[themeMapping]; count += 1; - if (100 < count) { + if (count > 100) { var index = stack.indexOf(themeMapping); stack.push(themeMapping); if (index !== -1) { From 6471bb01b148a29e063db255c443b8478d5a02c7 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:46:56 +0100 Subject: [PATCH 05/17] Bump mocha to latest version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index caaac83..470c029 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "istanbul": "0.3.17", - "mocha": "1.20.1", + "mocha": "^6.0.2", "sinon": "1.9.1", "unexpected": "9.5.0", "unexpected-sinon": "6.4.2" From fa7896a5baffebcf63e30d9a9ecb9de18455dc35 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:50:27 +0100 Subject: [PATCH 06/17] Switch to nyc for coverage. --- .gitignore | 1 + package.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bc20196..c8a2ce0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules/ +/.nyc_output/ /coverage/ magicpen.js diff --git a/package.json b/package.json index 470c029..41b08d0 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,11 @@ "url": "https://github.com/sunesimonsen/magicpen.git" }, "scripts": { + "coverage": "nyc --reporter=lcov --reporter=text npm test", "lint": "eslint .", "test": "npm run lint && mocha -R spec", "travis": "npm test && npm run coverage && ( magicpen.js", - "coverage": "NODE_ENV=development istanbul cover _mocha --report text --report lcov -- --reporter dot && echo google-chrome coverage/lcov-report/index.html" + "prepublish": "(echo '/*!' && magicpen.js" }, "author": "Sune Simonsen", "devDependencies": { @@ -31,8 +31,8 @@ "eslint-plugin-node": "^10.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", - "istanbul": "0.3.17", "mocha": "^6.0.2", + "nyc": "^14.1.1", "sinon": "1.9.1", "unexpected": "9.5.0", "unexpected-sinon": "6.4.2" From 0acaacb369debd17baab71a8f558a76ef72050ab Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 13:52:39 +0100 Subject: [PATCH 07/17] Submit coverage via after_success on Travis CI. --- .travis.yml | 3 ++- package.json | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d95e06..98634e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ node_js: - "9" - "10" -script: "npm run-script travis" +script: "npm run coverage" +after_success: ' magicpen.js" }, "author": "Sune Simonsen", "devDependencies": { "browserify": "8.1.0", "bundle-collapser": "1.1.1", - "coveralls": "2.11.1", + "coveralls": "^3.0.9", "del": "0.1.1", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", From c1ba53ecc3dfc660ea5df7571cec8ec2fa21bccf Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 14:22:18 +0100 Subject: [PATCH 08/17] Add headless browser testing. --- karma.conf.js | 34 ++++++++++++++++++++++++++++++++++ package.json | 9 +++++++-- test/common/browser.js | 3 +++ test/common/node.js | 5 +++++ test/magicpen.spec.js | 7 ++----- test/mocha.opts | 1 + 6 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 karma.conf.js create mode 100644 test/common/browser.js create mode 100644 test/common/node.js create mode 100644 test/mocha.opts diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..9e17705 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,34 @@ +module.exports = function(config) { + config.set({ + frameworks: ["mocha"], + + files: [ + "./node_modules/unexpected/unexpected.js", + "./node_modules/unexpected-sinon/lib/unexpected-sinon.js", + "./node_modules/sinon/pkg/sinon.js", + "./magicpen.js", + "./test/common/browser.js", + "./test/magicpen.spec.js" + ], + + client: { + mocha: { + reporter: "html", + timeout: 60000 + } + }, + + browserStack: { + video: false, + project: + process.env.TRAVIS_BRANCH === "master" && + !process.env.TRAVIS_PULL_REQUEST_BRANCH // Catch Travis "PR" builds + ? "unexpected-sinon" + : "unexpected-sinon-dev" + }, + + browsers: ["ChromeHeadless"], + + reporters: ["dots"] + }); +}; diff --git a/package.json b/package.json index 5aa967f..830bd6e 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,11 @@ "url": "https://github.com/sunesimonsen/magicpen.git" }, "scripts": { - "coverage": "nyc --reporter=lcov --reporter=text npm test", + "coverage": "nyc --reporter=lcov --reporter=text npm run test-node", "lint": "eslint .", - "test": "npm run lint && mocha -R spec", + "test": "npm run lint && npm run test-node && npm run test-browser", + "test-browser": "npm run prepublish && karma start --single-run --browsers ${BROWSER:-ChromeHeadless}", + "test-node": "mocha", "prepublish": "(echo '/*!' && magicpen.js" }, "author": "Sune Simonsen", @@ -30,6 +32,9 @@ "eslint-plugin-node": "^10.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", + "karma": "^4.1.0", + "karma-chrome-launcher": "^3.0.0", + "karma-mocha": "^1.3.0", "mocha": "^6.0.2", "nyc": "^14.1.1", "sinon": "1.9.1", diff --git a/test/common/browser.js b/test/common/browser.js new file mode 100644 index 0000000..84920ba --- /dev/null +++ b/test/common/browser.js @@ -0,0 +1,3 @@ +/* global expect: true */ +expect = window.weknowhow.expect.clone(); +expect.use(window.weknowhow.unexpectedSinon); diff --git a/test/common/node.js b/test/common/node.js new file mode 100644 index 0000000..a044490 --- /dev/null +++ b/test/common/node.js @@ -0,0 +1,5 @@ +/* global expect: true, sinon: true */ +/* eslint no-unused-vars: "off" */ +expect = require('unexpected'); +expect.use(require('unexpected-sinon')); +sinon = require('sinon'); diff --git a/test/magicpen.spec.js b/test/magicpen.spec.js index 3df179a..5af9170 100644 --- a/test/magicpen.spec.js +++ b/test/magicpen.spec.js @@ -1,8 +1,5 @@ -/*global describe, it, beforeEach*/ -var magicpen = require('..'); -var expect = require('unexpected'); -var sinon = require('sinon'); -expect.use(require('unexpected-sinon')); +/*global describe, it, beforeEach, expect:false, sinon: false, weknowhow:false*/ +var magicpen = typeof weknowhow !== 'undefined' ? weknowhow.MagicPen : require('../lib/MagicPen'); describe('magicpen', function () { var pen; diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..448bc35 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--require ./test/common/node.js From e97337e33cb9a2dedf787c3482811dad0d0347db Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 14:25:08 +0100 Subject: [PATCH 09/17] Wire browser testing into a build matrix on CI. --- .travis.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98634e8..4c8f27e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: node_js + +env: + - TARGET=test-node + node_js: - "6" - "7" @@ -6,5 +10,21 @@ node_js: - "9" - "10" -script: "npm run coverage" +matrix: + include: + - name: Lint + node_js: '8.4.0' + env: + - TARGET=lint + - name: Coverage + node_js: '8.4.0' + env: + - TARGET=coverage + - name: Chrome headless + node_js: '8.4.0' + env: + - TARGET=test-browser + - BROWSER=ChromeHeadless + +script: "npm run $TARGET" after_success: ' Date: Sun, 15 Dec 2019 14:30:51 +0100 Subject: [PATCH 10/17] Update badges to SVG. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2054cec..5389264 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ Create composable extensible styled text in both consoles and browsers. -[![NPM version](https://badge.fury.io/js/magicpen.png)](http://badge.fury.io/js/magicpen) -[![Build Status](https://travis-ci.org/sunesimonsen/magicpen.png)](https://travis-ci.org/sunesimonsen/magicpen) -[![Coverage Status](https://coveralls.io/repos/sunesimonsen/magicpen/badge.png)](https://coveralls.io/r/sunesimonsen/magicpen) -[![Dependency Status](https://david-dm.org/sunesimonsen/magicpen.png)](https://david-dm.org/sunesimonsen/magicpen) +[![NPM version](https://img.shields.io/npm/v/magicpen.svg)](https://www.npmjs.com/package/magicpen) +[![Build Status](https://img.shields.io/travis/sunesimonsen/magicpen/master.svg)](https://travis-ci.org/sunesimonsen/magicpen) +[![Coverage Status](https://img.shields.io/coveralls/sunesimonsen/magicpen.svg)](https://coveralls.io/r/sunesimonsen/magicpen) +[![Dependency Status](https://david-dm.org/sunesimonsen/magicpen.svg)](https://david-dm.org/sunesimonsen/magicpen) ## Installation From e360c5f03442ee8c1809850f787a1bef436f21ab Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 15:04:34 +0100 Subject: [PATCH 11/17] Convert to rollup and add ESM build. --- .eslintignore | 1 + .gitignore | 2 ++ package.json | 6 +++++- rollup.config.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 rollup.config.js diff --git a/.eslintignore b/.eslintignore index ca1cc78..063acc4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ magicpen.js +magicpen.esm.js diff --git a/.gitignore b/.gitignore index c8a2ce0..b0ced6f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /.nyc_output/ /coverage/ magicpen.js +magicpen.esm.js +magicpen.esm.js.map diff --git a/package.json b/package.json index 830bd6e..0a9f928 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test": "npm run lint && npm run test-node && npm run test-browser", "test-browser": "npm run prepublish && karma start --single-run --browsers ${BROWSER:-ChromeHeadless}", "test-node": "mocha", - "prepublish": "(echo '/*!' && magicpen.js" + "prepublish": "rollup -c" }, "author": "Sune Simonsen", "devDependencies": { @@ -37,6 +37,10 @@ "karma-mocha": "^1.3.0", "mocha": "^6.0.2", "nyc": "^14.1.1", + "rollup": "^1.0.2", + "rollup-plugin-commonjs": "^10.0.0", + "rollup-plugin-node-globals": "^1.4.0", + "rollup-plugin-node-resolve": "^5.0.0", "sinon": "1.9.1", "unexpected": "9.5.0", "unexpected-sinon": "6.4.2" diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..d620cdf --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,49 @@ +const fs = require('fs'); +const path = require('path'); + +const commonjs = require('rollup-plugin-commonjs'); +const nodeResolve = require('rollup-plugin-node-resolve'); +const nodeGlobals = require('rollup-plugin-node-globals'); + +const plugins = [ + commonjs({ ignore: ['os'] }), + nodeResolve({ preferBuiltins: true }), + nodeGlobals() +]; + +const banner = + '/*!\n' + + fs + .readFileSync(path.resolve(__dirname, 'LICENSE'), 'utf-8') + .replace(/^/gm, ' * ') + .replace(/\s+$/g, '') + + '/\n'; + +module.exports = [ + { + input: 'lib/MagicPen.js', + output: { + banner, + file: 'magicpen.js', + name: 'weknowhow.MagicPen', + exports: 'default', + format: 'umd', + esModule: false, + sourcemap: false, + strict: false + }, + plugins + }, + { + input: 'lib/MagicPen.js', + output: { + banner, + file: 'magicpen.esm.js', + exports: 'default', + format: 'esm', + sourcemap: true, + strict: false + }, + plugins + } +]; From 3c4730de5f1706b88ce09fcb55a05ceeee02095a Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 15:15:39 +0100 Subject: [PATCH 12/17] Bump default version of node to 8.10 for eslint compatibility. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c8f27e..ba1fc1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,22 +6,22 @@ env: node_js: - "6" - "7" - - "8.4.0" + - "8.10.0" - "9" - "10" matrix: include: - name: Lint - node_js: '8.4.0' + node_js: '8.10.0' env: - TARGET=lint - name: Coverage - node_js: '8.4.0' + node_js: '8.10.0' env: - TARGET=coverage - name: Chrome headless - node_js: '8.4.0' + node_js: '8.10.0' env: - TARGET=test-browser - BROWSER=ChromeHeadless From 38bf681221c97737b03a1fd34c9b6cdb7bd00780 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 15:23:00 +0100 Subject: [PATCH 13/17] Remove browserify leftovers after e360c5f. --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 0a9f928..83963fa 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,6 @@ }, "author": "Sune Simonsen", "devDependencies": { - "browserify": "8.1.0", - "bundle-collapser": "1.1.1", "coveralls": "^3.0.9", "del": "0.1.1", "eslint": "^6.0.0", From 7a56448068d30fe0b549c591cec273cef5b20e2b Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 22:55:19 +0100 Subject: [PATCH 14/17] Revert "Add headless browser testing." It was agreed that this was a little overkill given that the library does not make use of any browser APIs. This reverts commit c1ba53ecc3dfc660ea5df7571cec8ec2fa21bccf. --- karma.conf.js | 34 ---------------------------------- package.json | 7 ++----- test/common/browser.js | 3 --- test/common/node.js | 5 ----- test/magicpen.spec.js | 7 +++++-- test/mocha.opts | 1 - 6 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 karma.conf.js delete mode 100644 test/common/browser.js delete mode 100644 test/common/node.js delete mode 100644 test/mocha.opts diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 9e17705..0000000 --- a/karma.conf.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = function(config) { - config.set({ - frameworks: ["mocha"], - - files: [ - "./node_modules/unexpected/unexpected.js", - "./node_modules/unexpected-sinon/lib/unexpected-sinon.js", - "./node_modules/sinon/pkg/sinon.js", - "./magicpen.js", - "./test/common/browser.js", - "./test/magicpen.spec.js" - ], - - client: { - mocha: { - reporter: "html", - timeout: 60000 - } - }, - - browserStack: { - video: false, - project: - process.env.TRAVIS_BRANCH === "master" && - !process.env.TRAVIS_PULL_REQUEST_BRANCH // Catch Travis "PR" builds - ? "unexpected-sinon" - : "unexpected-sinon-dev" - }, - - browsers: ["ChromeHeadless"], - - reporters: ["dots"] - }); -}; diff --git a/package.json b/package.json index 83963fa..75a9fb5 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "url": "https://github.com/sunesimonsen/magicpen.git" }, "scripts": { - "coverage": "nyc --reporter=lcov --reporter=text npm run test-node", + "coverage": "nyc --reporter=lcov --reporter=text npm test", "lint": "eslint .", "test": "npm run lint && npm run test-node && npm run test-browser", - "test-browser": "npm run prepublish && karma start --single-run --browsers ${BROWSER:-ChromeHeadless}", + "test-browser": "npm run prepublish && true", "test-node": "mocha", "prepublish": "rollup -c" }, @@ -30,9 +30,6 @@ "eslint-plugin-node": "^10.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", - "karma": "^4.1.0", - "karma-chrome-launcher": "^3.0.0", - "karma-mocha": "^1.3.0", "mocha": "^6.0.2", "nyc": "^14.1.1", "rollup": "^1.0.2", diff --git a/test/common/browser.js b/test/common/browser.js deleted file mode 100644 index 84920ba..0000000 --- a/test/common/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -/* global expect: true */ -expect = window.weknowhow.expect.clone(); -expect.use(window.weknowhow.unexpectedSinon); diff --git a/test/common/node.js b/test/common/node.js deleted file mode 100644 index a044490..0000000 --- a/test/common/node.js +++ /dev/null @@ -1,5 +0,0 @@ -/* global expect: true, sinon: true */ -/* eslint no-unused-vars: "off" */ -expect = require('unexpected'); -expect.use(require('unexpected-sinon')); -sinon = require('sinon'); diff --git a/test/magicpen.spec.js b/test/magicpen.spec.js index 5af9170..3df179a 100644 --- a/test/magicpen.spec.js +++ b/test/magicpen.spec.js @@ -1,5 +1,8 @@ -/*global describe, it, beforeEach, expect:false, sinon: false, weknowhow:false*/ -var magicpen = typeof weknowhow !== 'undefined' ? weknowhow.MagicPen : require('../lib/MagicPen'); +/*global describe, it, beforeEach*/ +var magicpen = require('..'); +var expect = require('unexpected'); +var sinon = require('sinon'); +expect.use(require('unexpected-sinon')); describe('magicpen', function () { var pen; diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 448bc35..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ ---require ./test/common/node.js From 78369fb9c2065087472894700c01f854c76e9215 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 23:12:40 +0100 Subject: [PATCH 15/17] Wire the browser test to execute the tests against the build library. This should act as a cheap smoke test that the build was functional. --- .travis.yml | 3 +-- package.json | 2 +- test/magicpen.spec.js | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba1fc1c..b3faf83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,10 @@ matrix: node_js: '8.10.0' env: - TARGET=coverage - - name: Chrome headless + - name: Pseudo Browser node_js: '8.10.0' env: - TARGET=test-browser - - BROWSER=ChromeHeadless script: "npm run $TARGET" after_success: ' Date: Sun, 15 Dec 2019 23:15:04 +0100 Subject: [PATCH 16/17] Remove unused del dependency. --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 78b7105..6b59473 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "author": "Sune Simonsen", "devDependencies": { "coveralls": "^3.0.9", - "del": "0.1.1", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", "eslint-config-standard": "^14.0.1", From c5d8e13a65bbe859c35397e22072df79401844d3 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Sun, 15 Dec 2019 23:18:38 +0100 Subject: [PATCH 17/17] Run coverage over the unbundled node library only. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b59473..4d028c1 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/sunesimonsen/magicpen.git" }, "scripts": { - "coverage": "nyc --reporter=lcov --reporter=text npm test", + "coverage": "nyc --reporter=lcov --reporter=text npm run test-node", "lint": "eslint .", "test": "npm run lint && npm run test-node && npm run test-browser", "test-browser": "npm run prepublish && PSEUDO_BROWSER=yes mocha",