lint all js files

This commit is contained in:
Tony Brix 2018-03-29 13:00:59 -05:00
parent ec463419c3
commit ada4a1d8c0
4 changed files with 71 additions and 70 deletions

View File

@ -5,9 +5,9 @@
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
*/
var fs = require('fs')
, util = require('util')
, marked = require('../');
var fs = require('fs'),
path = require('path'),
marked = require('../');
/**
* Man Page
@ -23,9 +23,9 @@ function help() {
customFds: [0, 1, 2]
};
spawn('man', [__dirname + '/../man/marked.1'], options)
.on('error', function(err) {
fs.readFile(__dirname + '/../man/marked.1.txt', 'utf8', function(err, data) {
spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
.on('error', function(err) { // eslint-disable-line handle-callback-err
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
if (err) throw err;
console.log(data);
});
@ -37,13 +37,13 @@ function help() {
*/
function main(argv, callback) {
var files = []
, options = {}
, input
, output
, arg
, tokens
, opt;
var files = [],
options = {},
input,
output,
arg,
tokens,
opt;
function getarg() {
var arg = argv.shift();
@ -146,8 +146,8 @@ function main(argv, callback) {
*/
function getStdin(callback) {
var stdin = process.stdin
, buff = '';
var stdin = process.stdin,
buff = '';
stdin.setEncoding('utf8');

View File

@ -1,11 +1,11 @@
;(function() {
var console = {}
, files = __TESTS__;
;(function() {
var console = {},
files = __TESTS__; // eslint-disable-line no-undef
console.log = function(text) {
var args = Array.prototype.slice.call(arguments, 1)
, i = 0;
var args = Array.prototype.slice.call(arguments, 1),
i = 0;
text = text.replace(/%\w/g, function() {
return args[i++] || '';
@ -17,8 +17,8 @@ console.log = function(text) {
if (!Object.keys) {
Object.keys = function(obj) {
var out = []
, key;
var out = [],
key;
for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
@ -31,19 +31,22 @@ if (!Object.keys) {
}
if (!Array.prototype.forEach) {
// eslint-disable-next-line no-extend-native
Array.prototype.forEach = function(callback, context) {
for (var i = 0; i < this.length; i++) {
callback.call(context || null, this[i], i, obj);
callback.call(context || null, this[i], i, this);
}
};
}
if (!String.prototype.trim) {
// eslint-disable-next-line no-extend-native
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
// eslint-disable-next-line no-unused-vars
function load() {
return files;
}
@ -57,8 +60,7 @@ function escape(html, encode) {
.replace(/'/g, '&#39;');
}
__LIBS__;
(__MAIN__)();
__LIBS__; // eslint-disable-line no-undef, no-unused-expressions
(__MAIN__)(); // eslint-disable-line no-undef
}).call(this);

View File

@ -6,13 +6,12 @@ it('should run the test', function () {
// http://spec.commonmark.org/0.28/#example-230
it('should start an ordered list at 0 when requested', function () {
expect(
marked('0. ok')).
toBe("<ol start=\"0\">\n<li>ok</li>\n</ol>\n")
expect(marked('0. ok'))
.toBe('<ol start="0">\n<li>ok</li>\n</ol>\n')
});
// http://spec.commonmark.org/0.28/#example-234
it('indents code within an explicitly-started ordered list', function () {
expect(marked(" 10. foo\n\n bar")).
toBe("<ol start=\"10\">\n<li><p>foo</p>\n<pre><code>bar\n</code></pre></li>\n</ol>\n");
expect(marked(' 10. foo\n\n bar'))
.toBe('<ol start="10">\n<li><p>foo</p>\n<pre><code>bar\n</code></pre></li>\n</ol>\n');
});