From 0fed147e738998e6581a91f310efcd3f91bd118d Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 14 Nov 2017 00:10:25 +0100 Subject: [PATCH] chore(project): remove grunt + jshint * use npm-run-all to execute build steps * use eslint for linting --- .eslintignore | 2 ++ .eslintrc | 30 +++++++++++++++++++++ .jshintrc | 24 ----------------- .npmignore | 1 - CONTRIBUTING.md | 4 +-- Gruntfile.js | 50 ----------------------------------- package.json | 16 +++++------ test/integration/configure.js | 2 +- test/runner.js | 10 ++++--- test/spec/browserifySpec.js | 1 - test/spec/integrationSpec.js | 2 +- test/spec/pluginSpec.js | 10 +++---- 12 files changed, 56 insertions(+), 96 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc delete mode 100644 .jshintrc delete mode 100644 Gruntfile.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..165a373 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +test/fixtures +test/integration \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..555e485 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,30 @@ +{ + "rules": { + "keyword-spacing": [ 2 ], + "object-curly-spacing": [ 2, "always"], + "space-before-blocks": [ 2, "always"], + "indent": [ 2, 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } ], + "no-unused-vars": [ 2, { "args": "none" } ], + "space-before-function-paren": [ 2, "never" ], + "quotes": [ 2, "single" ], + "semi": [ 2, "always" ], + "no-console": 0, + "mocha/no-exclusive-tests": 2 + }, + "env": { + "node": true + }, + "extends": "eslint:recommended", + "plugins": [ + "mocha" + ], + "globals": { + "expect": false, + "it": false, + "describe": false, + "beforeEach": true, + "afterEach": true, + "before": true, + "after": true + } +} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index ac7f9b1..0000000 --- a/.jshintrc +++ /dev/null @@ -1,24 +0,0 @@ -{ - "globals": { - "it": false, - "console": false, - "describe": false, - "expect": false, - "beforeEach": false, - "afterEach": false - }, - - "node" : true, - - "boss": true, - "node": true, - "strict": true, - "maxlen": 120, - "newcap": false, - "undef": true, - "unused": false, - "onecase": true, - "expr": true, - "lastsemic": true, - "indent": 2 -} \ No newline at end of file diff --git a/.npmignore b/.npmignore index e0555dd..5299f42 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,3 @@ **/.* test/ example/ -Gruntfile.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7428b7c..3255a60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ Some things that make it easier for us to accept your pull requests * single-quotes * ... * The code is tested -* The `grunt` build passes (executes tests + linting) +* The `npm run all` build passes (executes tests + linting) * The work is combined into a single commit * The commit messages adhere to our [guideline](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y) @@ -42,4 +42,4 @@ When merging, try to do it manually (rebase on current master). This avoids merg ### Release the project -To release execute `grunt release(:major|:minor|:patch)`. Respect [semantic versioning](http://semver.org/) and choose correct next version based on latest changes. +To release execute `npm run release`. Respect [semantic versioning](http://semver.org/) and choose correct next version based on latest changes. diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index b084ac3..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - -module.exports = function(grunt) { - - require('load-grunt-tasks')(grunt); - - - // project configuration - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - - jshint: { - all: [ - 'Gruntfile.js', - 'index.js', - 'lib/**/*.js', - 'test/spec/**/*.js' - ], - options: { - jshintrc: true - } - }, - - mochaTest: { - test: { - options: { - reporter: 'spec', - require: [ - './test/expect.js' - ] - }, - src: ['test/spec/**/*.js'] - } - }, - - release: { - options: { - commitMessage: 'chore(project): release v<%= version %>', - tagMessage: 'chore(project): tag v<%= version %>', - tagName: 'v<%= version %>', - npm: false - } - } - }); - - - grunt.registerTask('test', [ 'mochaTest' ]); - - grunt.registerTask('default', [ 'jshint', 'test' ]); -}; diff --git a/package.json b/package.json index 3547973..3e319cb 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,10 @@ ], "version": "5.1.1", "scripts": { - "all": "grunt", - "test": "grunt test" + "all": "run-s lint test", + "lint": "eslint .", + "test": "mocha --exit -r test/expect test/spec/*.js", + "release": "np --no-publish" }, "authors": [ "Nico Rehwaldt ", @@ -36,17 +38,15 @@ "browser-unpack": "^1.1.1", "browserify": "^14.5.0", "chai": "^4.1.2", - "grunt": "~1.0.1", - "grunt-cli": "^0.1.13", - "grunt-contrib-jshint": "^0.11.3", - "grunt-mocha-test": "^0.12.7", - "grunt-release": "^0.13.0", + "eslint": "^4.11.0", + "eslint-plugin-mocha": "^4.11.0", "jasmine-core": "^2.4.1", "karma": "^1.7.1", "karma-jasmine": "^1.1.0", "karma-phantomjs-launcher": "^1.0.4", - "load-grunt-tasks": "^3.4.0", "mocha": "^4.0.1", + "np": "^2.16.1", + "npm-run-all": "^4.1.2", "resolve": "^1.1.6", "sinon": "^4.1.2", "sinon-chai": "^2.14.0", diff --git a/test/integration/configure.js b/test/integration/configure.js index 305997a..6a84d4d 100644 --- a/test/integration/configure.js +++ b/test/integration/configure.js @@ -20,4 +20,4 @@ module.exports = function() { karma.set(opts); }; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/test/runner.js b/test/runner.js index 1b3d9af..3062b72 100644 --- a/test/runner.js +++ b/test/runner.js @@ -43,7 +43,7 @@ Runner.prototype.stop = function() { this.stopFn = null; }; -Runner.prototype.stopAfter = function (ms) { +Runner.prototype.stopAfter = function(ms) { if (this.stopTimeout) clearTimeout(this.stopTimeout); return this.stopTimeout = setTimeout(this.stop.bind(this), ms); }; @@ -75,7 +75,7 @@ Runner.prototype.configure = function(configFile, config) { }; Runner.prototype.plugin = function() { - return {'framework:runner': ['factory', this.factory()]}; + return { 'framework:runner': ['factory', this.factory()] }; }; Runner.prototype.factory = function() { @@ -86,8 +86,12 @@ Runner.prototype.factory = function() { this.reset(); done(); }.bind(this)); + emitter.once('run_start', function() { - this.stopFn = process.listeners('SIGINT')[0]; + // find karma runner SIGINT handler + this.stopFn = process.listeners('SIGINT').filter(function(fn, idx) { + return /disconnectBrowsers/.test(fn.toString()); + })[0]; }.bind(this)); for (var k in this.queuedListeners) this.listen(k); this.emit('framework'); diff --git a/test/spec/browserifySpec.js b/test/spec/browserifySpec.js index bc279bb..5c254ba 100644 --- a/test/spec/browserifySpec.js +++ b/test/spec/browserifySpec.js @@ -1,7 +1,6 @@ 'use strict'; var browserify = require('browserify'); -var path = require('path'); var vm = require('vm'); function delay(fn, time) { diff --git a/test/spec/integrationSpec.js b/test/spec/integrationSpec.js index 8a56385..d29f178 100644 --- a/test/spec/integrationSpec.js +++ b/test/spec/integrationSpec.js @@ -26,7 +26,7 @@ function triggerRun(configFile, done) { } -describe.only('karma-browserify', function() { +describe('karma-browserify', function() { var runner, watchSpy; diff --git a/test/spec/pluginSpec.js b/test/spec/pluginSpec.js index 1dea663..abcba47 100644 --- a/test/spec/pluginSpec.js +++ b/test/spec/pluginSpec.js @@ -530,7 +530,7 @@ describe('karma-browserify', function() { // then // bundle got created - expect(bundleFile.bundled).to.contain("module.exports.text = '<' + \"HALLO\" + '>'"); + expect(bundleFile.bundled).to.contain('module.exports.text = \'<\' + "HALLO" + \'>\''); done(); }); @@ -555,7 +555,7 @@ describe('karma-browserify', function() { // then // bundle got created - expect(bundleFile.bundled).to.contain("module.exports.text = '<' + \"HALLO\" + '>'"); + expect(bundleFile.bundled).to.contain('module.exports.text = \'<\' + "HALLO" + \'>\''); done(); }); @@ -656,7 +656,7 @@ describe('karma-browserify', function() { configure: function(bundle) { // after first bundle - bundle.once('bundled', function (err) { + bundle.once('bundled', function(err) { // fail if there was an error if (err) { @@ -669,7 +669,7 @@ describe('karma-browserify', function() { return done(err); } - expect(bundleFile.bundled).to.contain("module.exports.text = '<' + \"HALLO\" + '>'"); + expect(bundleFile.bundled).to.contain('module.exports.text = \'<\' + "HALLO" + \'>\''); done(); }); @@ -695,7 +695,7 @@ describe('karma-browserify', function() { // Hook into bundler/pipeline events for success/error configure: function(bundle) { // After first bundle - bundle.once('bundled', function (err) { + bundle.once('bundled', function(err) { // Fail if there was an error if (err) { return done(err);