diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..9b34534 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules/ +.eslintrc.json \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..4242bca --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,146 @@ +{ + "env": { // http://eslint.org/docs/user-guide/configuring.html#specifying-environments + "node": true // browser global variables + }, + "root": true, + "rules": { + /** + * Strict mode + */ + // babel inserts "use strict"; for us + "strict": [2], // http://eslint.org/docs/rules/strict + + /** + * Variables + */ + "no-shadow": 2, // http://eslint.org/docs/rules/no-shadow + "no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names + "no-unused-vars": [2, { // http://eslint.org/docs/rules/no-unused-vars + "vars": "local", + "args": "after-used" + }], + "no-use-before-define": 2, // http://eslint.org/docs/rules/no-use-before-define + + /** + * Possible errors + */ + "comma-dangle": [2, "never"], // http://eslint.org/docs/rules/comma-dangle + "no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign + "no-console": 0, // http://eslint.org/docs/rules/no-console + "no-debugger": 1, // http://eslint.org/docs/rules/no-debugger + "no-alert": 1, // http://eslint.org/docs/rules/no-alert + "no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition + "no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys + "no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case + "no-empty": 2, // http://eslint.org/docs/rules/no-empty + "no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign + "no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast + "no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi + "no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign + "no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations + "no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp + "no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace + "no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls + "no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays + "no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable + "use-isnan": 2, // http://eslint.org/docs/rules/use-isnan + "block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var + + /** + * Best practices + */ + "consistent-return": 2, // http://eslint.org/docs/rules/consistent-return + "curly": [2, "all"], // http://eslint.org/docs/rules/curly + "default-case": 2, // http://eslint.org/docs/rules/default-case + "dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation + "allowKeywords": true + }], + "eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq + "guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in + "no-caller": 2, // http://eslint.org/docs/rules/no-caller + "no-else-return": 2, // http://eslint.org/docs/rules/no-else-return + "no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null + "no-eval": 2, // http://eslint.org/docs/rules/no-eval + "no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native + "no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind + "no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough + "no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal + "no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval + "no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks + "no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func + "no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str + "no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign + "no-new": 2, // http://eslint.org/docs/rules/no-new + "no-new-func": 2, // http://eslint.org/docs/rules/no-new-func + "no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers + "no-octal": 2, // http://eslint.org/docs/rules/no-octal + "no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape + "no-param-reassign": 2, // http://eslint.org/docs/rules/no-param-reassign + "no-proto": 2, // http://eslint.org/docs/rules/no-proto + "no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare + "no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign + "no-script-url": 2, // http://eslint.org/docs/rules/no-script-url + "no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare + "no-sequences": 2, // http://eslint.org/docs/rules/no-sequences + "no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal + "no-with": 2, // http://eslint.org/docs/rules/no-with + "radix": 2, // http://eslint.org/docs/rules/radix + "vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top + "wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife + "yoda": 2, // http://eslint.org/docs/rules/yoda + + /** + * Style + */ + "indent": [2, 4], // http://eslint.org/docs/rules/indent + "brace-style": [2, // http://eslint.org/docs/rules/brace-style + "1tbs", { + "allowSingleLine": true + }], + "quotes": [ + 2, "single", "avoid-escape" // http://eslint.org/docs/rules/quotes + ], + "camelcase": [2, { // http://eslint.org/docs/rules/camelcase + "properties": "always" + }], + "comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing + "before": false, + "after": true + }], + "comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style + "eol-last": 0, // http://eslint.org/docs/rules/eol-last + "func-names": 1, // http://eslint.org/docs/rules/func-names + "key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing + "beforeColon": false, + "afterColon": true + }], + "new-cap": [2, { // http://eslint.org/docs/rules/new-cap + "newIsCap": true + }], + "no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines + "max": 3 + }], + "no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary + "no-new-object": 2, // http://eslint.org/docs/rules/no-new-object + "no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func + "no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces + "no-extra-parens": [2, "functions"], // http://eslint.org/docs/rules/no-extra-parens + "no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle + "one-var": [2, { + "var": "always", // Exactly one var declaration per function + "let": "always", // Exactly one let declaration per block + "const": "never" // Exactly one declarator per const declaration per block + }], // http://eslint.org/docs/rules/one-var + "padded-blocks": 0, // http://eslint.org/docs/rules/padded-blocks + "semi": [2, "always"], // http://eslint.org/docs/rules/semi + "semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing + "before": false, + "after": true + }], + "keyword-spacing": 2, // http://eslint.org/docs/rules/keyword-spacing + "space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks + "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}], // http://eslint.org/docs/rules/space-before-function-paren + "space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops + "spaced-comment": 0 + } +} \ No newline at end of file diff --git a/.jsbeautifyrc b/.jsbeautifyrc deleted file mode 100644 index f94e790..0000000 --- a/.jsbeautifyrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "indent_with_tabs": false, - "preserve_newlines": true, - "max_preserve_newlines": 4, - "space_in_paren": false, - "jslint_happy": false, - "brace_style": "collapse", - "keep_array_indentation": false, - "keep_function_indentation": false, - "eval_code": false, - "unescape_strings": false, - "break_chained_methods": false, - "e4x": false, - "wrap_line_length": 0 -} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f57a8ff..0000000 --- a/.jshintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "sub": true, - "undef": true, - "boss": true, - "eqnull": true, - "node": true -} diff --git a/Gruntfile.js b/Gruntfile.js index c61df29..7a91c42 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,111 +8,121 @@ 'use strict'; -module.exports = function(grunt) { - - // Project configuration. - grunt.initConfig({ - - paths: { - fixtures: 'test/fixtures' - }, - - jshint: { - all: [ - 'Gruntfile.js', - 'tasks/*.js', - '<%= nodeunit.tests %>' - ], - options: { - jshintrc: '.jshintrc' - } - }, - - // Before generating any new files, remove any previously-created files. - clean: { - tests: ['tmp'] - }, - - // Configuration to be run (and then tested). - premailer: { - html: { - options: { - }, - files: { - 'tmp/email.html': ['<%= paths.fixtures %>/email.html'] - } - }, - multiple: { - files: { - 'tmp/email.html': ['<%= paths.fixtures %>/inexistant.html', '<%= paths.fixtures %>/email.html', '<%= paths.fixtures %>/email-not-tobe-included.html'], - 'tmp/email-2.html': ['<%= paths.fixtures %>/email-2.html'] - } - }, - txt: { - options: { - mode: 'txt' +/* eslint-disable func-names */ +module.exports = function (grunt) { + + // Project configuration. + grunt.initConfig({ + + paths: { + fixtures: 'test/fixtures' }, - files: { - 'tmp/email.txt': ['<%= paths.fixtures %>/email.html'] - } - }, - full: { - options: { - baseUrl: 'http://www.mydomain.com/', - queryString: 'foo=bar', - css: ['<%= paths.fixtures %>/css/*.css'], - removeClasses: true, - removeScripts: true, - preserveStyles: true, - verbose: true + + // jshint: { + // all: [ + // 'Gruntfile.js', + // 'tasks/*.js', + // '<%= nodeunit.tests %>' + // ], + // options: { + // jshintrc: '.jshintrc' + // } + // }, + + eslint: { + src: [ + 'Gruntfile.js', + 'tasks/*.js', + '<%= nodeunit.tests %>' + ] }, - files: { - 'tmp/email-full.html': ['<%= paths.fixtures %>/email-full.html'] - } - }, - verbose: { - files: { - 'tmp/email-verbose.html': ['<%= paths.fixtures %>/email-verbose.html'] - } - }, + // Before generating any new files, remove any previously-created files. + clean: { + tests: ['tmp'] + }, - mediaq: { - options: { - css: ['<%= paths.fixtures %>/css/external-mq.css'] + // Configuration to be run (and then tested). + premailer: { + html: { + options: { + }, + files: { + 'tmp/email.html': ['<%= paths.fixtures %>/email.html'] + } + }, + multiple: { + files: { + 'tmp/email.html': ['<%= paths.fixtures %>/inexistant.html', '<%= paths.fixtures %>/email.html', '<%= paths.fixtures %>/email-not-tobe-included.html'], + 'tmp/email-2.html': ['<%= paths.fixtures %>/email-2.html'] + } + }, + txt: { + options: { + mode: 'txt' + }, + files: { + 'tmp/email.txt': ['<%= paths.fixtures %>/email.html'] + } + }, + full: { + options: { + baseUrl: 'http://www.mydomain.com/', + queryString: 'foo=bar', + css: ['<%= paths.fixtures %>/css/*.css'], + removeClasses: true, + removeScripts: true, + preserveStyles: true, + verbose: true + }, + files: { + 'tmp/email-full.html': ['<%= paths.fixtures %>/email-full.html'] + } + }, + + verbose: { + files: { + 'tmp/email-verbose.html': ['<%= paths.fixtures %>/email-verbose.html'] + } + }, + + mediaq: { + options: { + css: ['<%= paths.fixtures %>/css/external-mq.css'] + }, + files: { + 'tmp/email-mq.html': ['<%= paths.fixtures %>/email-mq.html'] + } + }, + + overwrite: { + files: { + '<%= paths.fixtures %>/email-overwrite.html': ['<%= paths.fixtures %>/email-overwrite.html'] + } + } }, - files: { - 'tmp/email-mq.html': ['<%= paths.fixtures %>/email-mq.html'] - } - }, - overwrite: { - files: { - '<%= paths.fixtures %>/email-overwrite.html': ['<%= paths.fixtures %>/email-overwrite.html'] + // Unit tests. + nodeunit: { + tests: ['test/*_test.js'] } - } - }, - - // Unit tests. - nodeunit: { - tests: ['test/*_test.js'] - } - }); + }); - // Actually load this plugin's task(s). - grunt.loadTasks('tasks'); + // Actually load this plugin's task(s). + grunt.loadTasks('tasks'); - // These plugins provide necessary tasks. - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); + // These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-eslint'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-nodeunit'); - // Whenever the "test" task is run, first clean the "tmp" dir, then run this - // plugin's task(s), then test the result. - grunt.registerTask('test', ['clean', 'premailer', 'nodeunit']); + // Whenever the "test" task is run, first clean the "tmp" dir, then run this + // plugin's task(s), then test the result. + grunt.registerTask('test', ['clean', 'premailer', 'nodeunit']); - // By default, lint and run all tests. - grunt.registerTask('default', ['jshint', 'test']); + // By default, lint and run all tests. + grunt.registerTask('default', ['eslint', 'test']); }; +/* eslint-enable func-names */ \ No newline at end of file diff --git a/LICENSE-MIT b/LICENSE-MIT index 7677c3c..5ce6f91 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2013 Marco Solazzi +Copyright (c) 2013-2016 Marco Solazzi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 394d304..fad4f80 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ This plugin is a [Grunt](http://gruntjs.com/) wrapper around the [Premailer](https://github.com/alexdunae/premailer/) Ruby gem developed by Alex Dunae. In order to run it you will need the following packages installed on your system: -* Node.js >= 0.10.0 ([install wiki](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)) +* Node.js >= 0.12.0 ([install wiki](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)) * Grunt-cli >= 0.1.7 and Grunt >=0.4.2 (`npm install grunt-cli -g`) * Ruby >= 1.9.3 ([installers](http://www.ruby-lang.org/en/downloads/)) -* Premailer >= 1.8.0 (`gem install premailer` and, most of the time, `gem install hpricot`) +* Premailer >= 1.8.0 (`gem install premailer` and, most of the time, `gem install nokogiri`) ## Getting Started -This plugin requires Grunt `~0.4.2` +This plugin is compatible with Grunt 1.x but requires Grunt `>=0.4.2` If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: @@ -181,6 +181,8 @@ In lieu of a formal styleguide, take care to maintain the existing coding style. ## Release History +1.0.0 Updated dependency and Grunt 1.x ready + 0.2.13 Added option `warnLevel` and `removeIds` 0.2.12 Dependencies updated. Fixing a bug when source and destination files are the same (#25) diff --git a/lib/postinstall.js b/lib/postinstall.js index d746a6b..cce2f4a 100644 --- a/lib/postinstall.js +++ b/lib/postinstall.js @@ -1,23 +1,26 @@ 'use strict'; -var exec = require('child_process').exec; -var chalk = require('chalk'); -var semver = require('semver'); -var version = '1.8.0'; +var exec = require('child_process').exec, + chalk = require('chalk'), + semver = require('semver'), + version = '1.8.0'; + +exec('gem list premailer -a', function execCb(error, stdout/*, stderr*/) { + var premailer, + versionMatch; -exec('gem list premailer -a', function (error, stdout, stderr) { if (error !== null) { console.log(chalk.red('ERROR: Unable to check for Premailer gem version...')); } else { - var premailer = stdout.toString().split('\n').filter(function (l) { + premailer = stdout.toString().split('\n').filter(function filterCb(l) { return (/^premailer\s/).test(l); }).pop(); if (premailer) { - var versionMatch = premailer + versionMatch = premailer .replace(/[^\d\.,]/g, '') .split(',') - .some(function (v) { + .some(function versionIterator(v) { return semver.gte(v, version); }); if (versionMatch) { diff --git a/package.json b/package.json index 12bd75e..df3c501 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-premailer", "description": "Grunt wrapper task for premailer", - "version": "0.2.13", + "version": "1.0.0", "homepage": "https://github.com/dwightjack/grunt-premailer", "author": { "name": "Marco Solazzi", @@ -27,26 +27,27 @@ }, "scripts": { "test": "grunt test", + "grunt": "grunt", "postinstall": "node lib/postinstall.js" }, "devDependencies": { - "grunt-contrib-jshint": "~0.11.0", - "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-nodeunit": "~0.4.1", - "grunt": "~0.4.5" + "grunt": ">=0.4.0", + "grunt-contrib-clean": "1.0.0", + "grunt-contrib-nodeunit": "1.0.0", + "grunt-eslint": "18.1.0" }, "peerDependencies": { - "grunt": "~0.4.5" + "grunt": ">=0.4.0" }, "keywords": [ "gruntplugin" ], "dependencies": { - "async": "~0.9.0", - "chalk": "~1.0.0", - "dargs": "~4.0.0", - "is-utf8": "^0.2.0", - "lodash": "~3.5.0", - "semver": "~4.3.1" + "async": "1.5.2", + "chalk": "1.1.3", + "dargs": "4.1.0", + "is-utf8": "0.2.1", + "lodash": "4.13.1", + "semver": "5.1.0" } } diff --git a/tasks/premailer.js b/tasks/premailer.js index 8115660..69ba8bf 100644 --- a/tasks/premailer.js +++ b/tasks/premailer.js @@ -2,13 +2,13 @@ * grunt-premailer * https://github.com/dwightjack/grunt-premailer * - * Copyright (c) 2013 Marco Solazzi + * Copyright (c) 2013-2016 Marco Solazzi * Licensed under the MIT license. */ 'use strict'; -module.exports = function(grunt) { +module.exports = function gruntPremailer(grunt) { var dargs = require('dargs'), path = require('path'), @@ -25,11 +25,10 @@ module.exports = function(grunt) { risky: 3 }; - grunt.registerMultiTask('premailer', 'Grunt wrapper task for premailer', function() { + grunt.registerMultiTask('premailer', 'Grunt wrapper task for premailer', function taskRegistration() { // Merge task-specific and/or target-specific options with these defaults. var args = {}, done = this.async(), - series = [], options = this.options({ baseUrl: null, bundleExec: false, @@ -47,15 +46,17 @@ module.exports = function(grunt) { removeIds: false, replaceHtmlEntities: false, escapeUrlAttributes: true - }); + }), + keys, + cmd; - var keys = Object.keys(options); + keys = Object.keys(options); // Remove bundleExec from arguments keys.splice(keys.indexOf('bundleExec'), 1); //clean-up falsy options and parse template-like values - keys.forEach(function(key) { + keys.forEach(function keyIterator(key) { var val = options[key]; if (typeof val === 'string') { @@ -73,12 +74,12 @@ module.exports = function(grunt) { //also manage properly the css option if (_.has(args, 'css') && Array.isArray(args.css)) { args.css = _(args.css) - .map(function (csspath) { + .map(function mapFn(csspath) { return grunt.config.process(csspath); }) - .reduce(function (paths, csspath) { + .reduce(function reduceFn(paths, csspath) { var expanded = grunt.file.expand({ - filter: function (src) { + filter: function expandFilterFn(src) { return grunt.file.isFile(src) && (path.extname(src) === '.css'); } }, csspath); @@ -96,7 +97,6 @@ module.exports = function(grunt) { // Command to run - var cmd; if (options.bundleExec) { cmd = 'bundle'; @@ -107,18 +107,18 @@ module.exports = function(grunt) { // Asynchronously iterate over all specified file groups. - async.eachLimit(this.files, 10, function(f, next) { + async.eachLimit(this.files, 10, function asyncIterator(f, next) { // Concat specified files. var srcFile, batchArgs, premailer, tmpFile; - srcFile = f.src.filter(function (f) { - return grunt.file.isFile(f); + srcFile = f.src.filter(function filterFn(sFile) { + return grunt.file.isFile(sFile); }).shift(); - if(!srcFile) { + if (!srcFile) { //skip! grunt.log.writeln('Input file not found'); next(null); @@ -145,7 +145,7 @@ module.exports = function(grunt) { premailer = grunt.util.spawn({ cmd: cmd, args: batchArgs - }, function(err, result, code) { + }, function premailerCb(err/*, result, code*/) { if (err) { grunt.fail.fatal(err); } diff --git a/test/premailer_test.js b/test/premailer_test.js index b7cd318..f7bbe53 100644 --- a/test/premailer_test.js +++ b/test/premailer_test.js @@ -21,89 +21,92 @@ var grunt = require('grunt'); test.doesNotThrow(block, [error], [message]) test.ifError(value) */ - +/* eslint-disable func-names, vars-on-top, quotes, one-var */ exports.premailer = { - setUp: function(done) { - // setup here if necessary - done(); - }, + setUp: function (done) { + // setup here if necessary + done(); + }, + + html: function (test) { + test.expect(1); + + var actual = grunt.file.read('tmp/email.html'); + test.ok(actual.indexOf('<body style="color: red') !== -1, 'Test CSS style is inline.'); - html: function(test) { - test.expect(1); + test.done(); + }, - var actual = grunt.file.read('tmp/email.html'); - test.ok(actual.indexOf('<body style="color: red') !== -1, 'Test CSS style is inline.'); + multiple: function (test) { + test.expect(2); - test.done(); - }, + var first = grunt.file.read('tmp/email.html'), + second = grunt.file.read('tmp/email-2.html'); - multiple: function(test) { - test.expect(2); + test.notStrictEqual(first, second, 'Multiple file targets are processed independently.'); + test.strictEqual(first.indexOf('dont-include-me'), -1, 'On multiple src, include only the first existing file'); + test.done(); + }, - var first = grunt.file.read('tmp/email.html'); - var second = grunt.file.read('tmp/email-2.html'); - test.notStrictEqual(first, second, 'Multiple file targets are processed independently.'); - test.strictEqual(first.indexOf('dont-include-me'), -1, 'On multiple src, include only the first existing file'); - test.done(); - }, + txt: function (test) { + test.expect(1); - txt: function(test) { - test.expect(1); + var actual = grunt.file.read('tmp/email.txt').replace(/\n+/, ''), + expected = grunt.file.read('test/expected/email.txt').replace("\n", ''); - var actual = grunt.file.read('tmp/email.txt').replace(/\n+/,''); - var expected = grunt.file.read('test/expected/email.txt').replace("\n",''); - test.equal(actual, expected + "\n", 'Email converted from HTML to plain text'); + test.equal(actual, expected + "\n", 'Email converted from HTML to plain text'); - test.done(); - }, + test.done(); + }, - full: function(test) { - test.expect(6); + full: function (test) { + test.expect(6); - var actual = grunt.file.read('tmp/email-full.html'); + var actual = grunt.file.read('tmp/email-full.html'); - var bodyClassRegex = /class=("|')[^'"]*body\-class/; + var bodyClassRegex = /class=("|')[^'"]*body\-class/; - var externalCSSRegex = /<body style="[^"]*color: red/; - var externalCSSRegex2 = /<body style="[^"]*width: 10px/; + var externalCSSRegex = /<body style="[^"]*color: red/; + var externalCSSRegex2 = /<body style="[^"]*width: 10px/; - test.equal(bodyClassRegex.test(actual), false, "Class attributes removed"); - test.ok(externalCSSRegex.test(actual), "External CSS applied"); - test.ok(externalCSSRegex2.test(actual), "Second External CSS applied"); - test.ok(actual.indexOf('<a href="http://www.mydomain.com/link.php?foo=bar">') !== -1, "Base URL and query string applied"); - test.equal(actual.indexOf('<script'), -1, "Script tags removed"); - test.ok(actual.indexOf('<style') !== -1, "Style tags are kept in source"); + test.equal(bodyClassRegex.test(actual), false, "Class attributes removed"); + test.ok(externalCSSRegex.test(actual), "External CSS applied"); + test.ok(externalCSSRegex2.test(actual), "Second External CSS applied"); + test.ok(actual.indexOf('<a href="http://www.mydomain.com/link.php?foo=bar">') !== -1, "Base URL and query string applied"); + test.equal(actual.indexOf('<script'), -1, "Script tags removed"); + test.ok(actual.indexOf('<style') !== -1, "Style tags are kept in source"); - test.done(); - }, + test.done(); + }, - verbose: function (test) { - test.expect(1); + verbose: function (test) { + test.expect(1); - var actual = grunt.file.read('tmp/email-verbose.html'); + var actual = grunt.file.read('tmp/email-verbose.html'); - test.ok(actual.indexOf('</html>') > 0, "Long email got completely parsed"); - test.done(); + test.ok(actual.indexOf('</html>') > 0, "Long email got completely parsed"); + test.done(); - }, + }, - mediaq: function (test) { - test.expect(2); + mediaq: function (test) { + test.expect(2); - var actual = grunt.file.read('tmp/email-mq.html'); + var actual = grunt.file.read('tmp/email-mq.html'); - test.ok(actual.indexOf('@media only screen and (max-width: 600px)') > 0, "Media Queries are preserved"); - test.ok(actual.indexOf('@media only screen and (min-width: 400px)') > 0, "Media Queries from external files are preserved"); - test.done(); - }, + test.ok(actual.indexOf('@media only screen and (max-width: 600px)') > 0, "Media Queries are preserved"); + test.ok(actual.indexOf('@media only screen and (min-width: 400px)') > 0, "Media Queries from external files are preserved"); + test.done(); + }, - overwrite: function(test) { - test.expect(1); + overwrite: function (test) { + test.expect(1); - var actual = grunt.file.read('test/fixtures/email-overwrite.html'); - test.ok(actual.indexOf('<body style="color: red') !== -1, 'Content is preserved.'); + var actual = grunt.file.read('test/fixtures/email-overwrite.html'); + test.ok(actual.indexOf('<body style="color: red') !== -1, 'Content is preserved.'); - test.done(); - } + test.done(); + } }; +/* eslint-enable func-names, vars-on-top, quotes, one-var */ \ No newline at end of file