Skip to content

Commit

Permalink
Merge pull request markedjs#1185 from UziTech/eslint-all-the-things
Browse files Browse the repository at this point in the history
Eslint all the things
  • Loading branch information
joshbruce authored Apr 4, 2018
2 parents c780159 + 5eeba0d commit cb0b639
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 72 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.min.js
30 changes: 15 additions & 15 deletions bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
if (err) throw err;
console.log(data);
});
Expand All @@ -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();
Expand Down Expand Up @@ -146,8 +146,8 @@ function main(argv, callback) {
*/

function getStdin(callback) {
var stdin = process.stdin
, buff = '';
var stdin = process.stdin,
buff = '';

stdin.setEncoding('utf8');

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"test:specs": "npm test -- test/specs/**/*-spec.js",
"test:integration": "npm test -- test/integration/**/*-spec.js",
"test:old": "node test",
"test:lint": "eslint lib/marked.js test/index.js",
"test:lint": "eslint bin/marked .",
"bench": "node test --bench",
"lint": "eslint --fix lib/marked.js test/index.js",
"lint": "eslint --fix bin/marked .",
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
},
Expand Down
2 changes: 1 addition & 1 deletion test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ app.get('/test.js', function(req, res, next) {
res.send(testScript);
});

app.use(express.static(path.join(__dirname, '/../../lib'))) ;
app.use(express.static(path.join(__dirname, '/../../lib')));
app.use(express.static(__dirname));

app.listen(8080);
100 changes: 51 additions & 49 deletions test/browser/test.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,66 @@
;(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;
console.log = function(text) {
var args = Array.prototype.slice.call(arguments, 1),
i = 0;

text = text.replace(/%\w/g, function() {
return args[i++] || '';
});
text = text.replace(/%\w/g, function() {
return args[i++] || '';
});

if (window.console) window.console.log(text);
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
};
if (window.console) window.console.log(text);
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
};

if (!Object.keys) {
Object.keys = function(obj) {
var out = []
, key;
if (!Object.keys) {
Object.keys = function(obj) {
var out = [],
key;

for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
out.push(key);
for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
out.push(key);
}
}
}

return out;
};
}

if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, context) {
for (var i = 0; i < this.length; i++) {
callback.call(context || null, this[i], i, obj);
}
};
}
return out;
};
}

if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
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, this);
}
};
}

function load() {
return files;
}
if (!String.prototype.trim) {
// eslint-disable-next-line no-extend-native
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}

function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
// eslint-disable-next-line no-unused-vars
function load() {
return files;
}

__LIBS__;
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}

(__MAIN__)();
__LIBS__; // eslint-disable-line no-undef, no-unused-expressions

(__MAIN__)(); // eslint-disable-line no-undef
}).call(this);
9 changes: 4 additions & 5 deletions test/integration/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit cb0b639

Please sign in to comment.