Merge pull request #1185 from UziTech/eslint-all-the-things
Eslint all the things
This commit is contained in:
commit
3f6b2c817d
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.min.js
|
30
bin/marked
30
bin/marked
@ -5,9 +5,9 @@
|
|||||||
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs')
|
var fs = require('fs'),
|
||||||
, util = require('util')
|
path = require('path'),
|
||||||
, marked = require('../');
|
marked = require('../');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Man Page
|
* Man Page
|
||||||
@ -23,9 +23,9 @@ function help() {
|
|||||||
customFds: [0, 1, 2]
|
customFds: [0, 1, 2]
|
||||||
};
|
};
|
||||||
|
|
||||||
spawn('man', [__dirname + '/../man/marked.1'], options)
|
spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
|
||||||
.on('error', function(err) {
|
.on('error', function() {
|
||||||
fs.readFile(__dirname + '/../man/marked.1.txt', 'utf8', function(err, data) {
|
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
@ -37,13 +37,13 @@ function help() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function main(argv, callback) {
|
function main(argv, callback) {
|
||||||
var files = []
|
var files = [],
|
||||||
, options = {}
|
options = {},
|
||||||
, input
|
input,
|
||||||
, output
|
output,
|
||||||
, arg
|
arg,
|
||||||
, tokens
|
tokens,
|
||||||
, opt;
|
opt;
|
||||||
|
|
||||||
function getarg() {
|
function getarg() {
|
||||||
var arg = argv.shift();
|
var arg = argv.shift();
|
||||||
@ -146,8 +146,8 @@ function main(argv, callback) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function getStdin(callback) {
|
function getStdin(callback) {
|
||||||
var stdin = process.stdin
|
var stdin = process.stdin,
|
||||||
, buff = '';
|
buff = '';
|
||||||
|
|
||||||
stdin.setEncoding('utf8');
|
stdin.setEncoding('utf8');
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@
|
|||||||
"test:specs": "npm test -- test/specs/**/*-spec.js",
|
"test:specs": "npm test -- test/specs/**/*-spec.js",
|
||||||
"test:integration": "npm test -- test/integration/**/*-spec.js",
|
"test:integration": "npm test -- test/integration/**/*-spec.js",
|
||||||
"test:old": "node test",
|
"test:old": "node test",
|
||||||
"test:lint": "eslint lib/marked.js test/index.js",
|
"test:lint": "eslint bin/marked .",
|
||||||
"bench": "node test --bench",
|
"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",
|
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
|
||||||
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
|
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ app.get('/test.js', function(req, res, next) {
|
|||||||
res.send(testScript);
|
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.use(express.static(__dirname));
|
||||||
|
|
||||||
app.listen(8080);
|
app.listen(8080);
|
||||||
|
@ -1,64 +1,66 @@
|
|||||||
|
|
||||||
;(function() {
|
;(function() {
|
||||||
|
var console = {},
|
||||||
|
files = __TESTS__; // eslint-disable-line no-undef
|
||||||
|
|
||||||
var console = {}
|
console.log = function(text) {
|
||||||
, files = __TESTS__;
|
var args = Array.prototype.slice.call(arguments, 1),
|
||||||
|
i = 0;
|
||||||
|
|
||||||
console.log = function(text) {
|
text = text.replace(/%\w/g, function() {
|
||||||
var args = Array.prototype.slice.call(arguments, 1)
|
return args[i++] || '';
|
||||||
, i = 0;
|
});
|
||||||
|
|
||||||
text = text.replace(/%\w/g, function() {
|
if (window.console) window.console.log(text);
|
||||||
return args[i++] || '';
|
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
|
||||||
});
|
};
|
||||||
|
|
||||||
if (window.console) window.console.log(text);
|
if (!Object.keys) {
|
||||||
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
|
Object.keys = function(obj) {
|
||||||
};
|
var out = [],
|
||||||
|
key;
|
||||||
|
|
||||||
if (!Object.keys) {
|
for (key in obj) {
|
||||||
Object.keys = function(obj) {
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||||
var out = []
|
out.push(key);
|
||||||
, key;
|
}
|
||||||
|
|
||||||
for (key in obj) {
|
|
||||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
||||||
out.push(key);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.forEach) {
|
if (!Array.prototype.forEach) {
|
||||||
Array.prototype.forEach = function(callback, context) {
|
// eslint-disable-next-line no-extend-native
|
||||||
for (var i = 0; i < this.length; i++) {
|
Array.prototype.forEach = function(callback, context) {
|
||||||
callback.call(context || null, this[i], i, obj);
|
for (var i = 0; i < this.length; i++) {
|
||||||
}
|
callback.call(context || null, this[i], i, this);
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!String.prototype.trim) {
|
if (!String.prototype.trim) {
|
||||||
String.prototype.trim = function() {
|
// eslint-disable-next-line no-extend-native
|
||||||
return this.replace(/^\s+|\s+$/g, '');
|
String.prototype.trim = function() {
|
||||||
};
|
return this.replace(/^\s+|\s+$/g, '');
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function load() {
|
// eslint-disable-next-line no-unused-vars
|
||||||
return files;
|
function load() {
|
||||||
}
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
function escape(html, encode) {
|
function escape(html, encode) {
|
||||||
return html
|
return html
|
||||||
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
.replace(/"/g, '"')
|
.replace(/"/g, '"')
|
||||||
.replace(/'/g, ''');
|
.replace(/'/g, ''');
|
||||||
}
|
}
|
||||||
|
|
||||||
__LIBS__;
|
__LIBS__; // eslint-disable-line no-undef, no-unused-expressions
|
||||||
|
|
||||||
(__MAIN__)();
|
|
||||||
|
|
||||||
|
(__MAIN__)(); // eslint-disable-line no-undef
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -6,13 +6,12 @@ it('should run the test', function () {
|
|||||||
|
|
||||||
// http://spec.commonmark.org/0.28/#example-230
|
// http://spec.commonmark.org/0.28/#example-230
|
||||||
it('should start an ordered list at 0 when requested', function () {
|
it('should start an ordered list at 0 when requested', function () {
|
||||||
expect(
|
expect(marked('0. ok'))
|
||||||
marked('0. ok')).
|
.toBe('<ol start="0">\n<li>ok</li>\n</ol>\n')
|
||||||
toBe("<ol start=\"0\">\n<li>ok</li>\n</ol>\n")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// http://spec.commonmark.org/0.28/#example-234
|
// http://spec.commonmark.org/0.28/#example-234
|
||||||
it('indents code within an explicitly-started ordered list', function () {
|
it('indents code within an explicitly-started ordered list', function () {
|
||||||
expect(marked(" 10. foo\n\n bar")).
|
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");
|
.toBe('<ol start="10">\n<li><p>foo</p>\n<pre><code>bar\n</code></pre></li>\n</ol>\n');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user