Skip to content

Commit 3f6b2c8

Browse files
authored
Merge pull request #1185 from UziTech/eslint-all-the-things
Eslint all the things
2 parents 373fbd4 + a5eb9c0 commit 3f6b2c8

File tree

6 files changed

+74
-72
lines changed

6 files changed

+74
-72
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.min.js

bin/marked

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
66
*/
77

8-
var fs = require('fs')
9-
, util = require('util')
10-
, marked = require('../');
8+
var fs = require('fs'),
9+
path = require('path'),
10+
marked = require('../');
1111

1212
/**
1313
* Man Page
@@ -23,9 +23,9 @@ function help() {
2323
customFds: [0, 1, 2]
2424
};
2525

26-
spawn('man', [__dirname + '/../man/marked.1'], options)
27-
.on('error', function(err) {
28-
fs.readFile(__dirname + '/../man/marked.1.txt', 'utf8', function(err, data) {
26+
spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
27+
.on('error', function() {
28+
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
2929
if (err) throw err;
3030
console.log(data);
3131
});
@@ -37,13 +37,13 @@ function help() {
3737
*/
3838

3939
function main(argv, callback) {
40-
var files = []
41-
, options = {}
42-
, input
43-
, output
44-
, arg
45-
, tokens
46-
, opt;
40+
var files = [],
41+
options = {},
42+
input,
43+
output,
44+
arg,
45+
tokens,
46+
opt;
4747

4848
function getarg() {
4949
var arg = argv.shift();
@@ -146,8 +146,8 @@ function main(argv, callback) {
146146
*/
147147

148148
function getStdin(callback) {
149-
var stdin = process.stdin
150-
, buff = '';
149+
var stdin = process.stdin,
150+
buff = '';
151151

152152
stdin.setEncoding('utf8');
153153

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"test:specs": "npm test -- test/specs/**/*-spec.js",
4444
"test:integration": "npm test -- test/integration/**/*-spec.js",
4545
"test:old": "node test",
46-
"test:lint": "eslint lib/marked.js test/index.js",
46+
"test:lint": "eslint bin/marked .",
4747
"bench": "node test --bench",
48-
"lint": "eslint --fix lib/marked.js test/index.js",
48+
"lint": "eslint --fix bin/marked .",
4949
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
5050
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
5151
},

test/browser/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ app.get('/test.js', function(req, res, next) {
3333
res.send(testScript);
3434
});
3535

36-
app.use(express.static(path.join(__dirname, '/../../lib'))) ;
36+
app.use(express.static(path.join(__dirname, '/../../lib')));
3737
app.use(express.static(__dirname));
3838

3939
app.listen(8080);

test/browser/test.js

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
1-
;(function() {
21

3-
var console = {}
4-
, files = __TESTS__;
2+
;(function() {
3+
var console = {},
4+
files = __TESTS__; // eslint-disable-line no-undef
55

6-
console.log = function(text) {
7-
var args = Array.prototype.slice.call(arguments, 1)
8-
, i = 0;
6+
console.log = function(text) {
7+
var args = Array.prototype.slice.call(arguments, 1),
8+
i = 0;
99

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

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

18-
if (!Object.keys) {
19-
Object.keys = function(obj) {
20-
var out = []
21-
, key;
18+
if (!Object.keys) {
19+
Object.keys = function(obj) {
20+
var out = [],
21+
key;
2222

23-
for (key in obj) {
24-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
25-
out.push(key);
23+
for (key in obj) {
24+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
25+
out.push(key);
26+
}
2627
}
27-
}
28-
29-
return out;
30-
};
31-
}
3228

33-
if (!Array.prototype.forEach) {
34-
Array.prototype.forEach = function(callback, context) {
35-
for (var i = 0; i < this.length; i++) {
36-
callback.call(context || null, this[i], i, obj);
37-
}
38-
};
39-
}
29+
return out;
30+
};
31+
}
4032

41-
if (!String.prototype.trim) {
42-
String.prototype.trim = function() {
43-
return this.replace(/^\s+|\s+$/g, '');
44-
};
45-
}
33+
if (!Array.prototype.forEach) {
34+
// eslint-disable-next-line no-extend-native
35+
Array.prototype.forEach = function(callback, context) {
36+
for (var i = 0; i < this.length; i++) {
37+
callback.call(context || null, this[i], i, this);
38+
}
39+
};
40+
}
4641

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

51-
function escape(html, encode) {
52-
return html
53-
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
54-
.replace(/</g, '&lt;')
55-
.replace(/>/g, '&gt;')
56-
.replace(/"/g, '&quot;')
57-
.replace(/'/g, '&#39;');
58-
}
49+
// eslint-disable-next-line no-unused-vars
50+
function load() {
51+
return files;
52+
}
5953

60-
__LIBS__;
54+
function escape(html, encode) {
55+
return html
56+
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
57+
.replace(/</g, '&lt;')
58+
.replace(/>/g, '&gt;')
59+
.replace(/"/g, '&quot;')
60+
.replace(/'/g, '&#39;');
61+
}
6162

62-
(__MAIN__)();
63+
__LIBS__; // eslint-disable-line no-undef, no-unused-expressions
6364

65+
(__MAIN__)(); // eslint-disable-line no-undef
6466
}).call(this);

test/integration/marked-spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ it('should run the test', function () {
66

77
// http://spec.commonmark.org/0.28/#example-230
88
it('should start an ordered list at 0 when requested', function () {
9-
expect(
10-
marked('0. ok')).
11-
toBe("<ol start=\"0\">\n<li>ok</li>\n</ol>\n")
9+
expect(marked('0. ok'))
10+
.toBe('<ol start="0">\n<li>ok</li>\n</ol>\n')
1211
});
1312

1413
// http://spec.commonmark.org/0.28/#example-234
1514
it('indents code within an explicitly-started ordered list', function () {
16-
expect(marked(" 10. foo\n\n bar")).
17-
toBe("<ol start=\"10\">\n<li><p>foo</p>\n<pre><code>bar\n</code></pre></li>\n</ol>\n");
15+
expect(marked(' 10. foo\n\n bar'))
16+
.toBe('<ol start="10">\n<li><p>foo</p>\n<pre><code>bar\n</code></pre></li>\n</ol>\n');
1817
});

0 commit comments

Comments
 (0)