Skip to content

Commit

Permalink
Add eslint/editorconfig and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
danmactough committed Dec 26, 2016
1 parent e9932ee commit 3a742fb
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[{*.js,package.json,.travis.yml}]
charset = utf-8
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
27 changes: 27 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,27 @@
{
"env": {
"node": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-cond-assign": [
0
]
}
}
7 changes: 7 additions & 0 deletions bin/.eslintrc.json
@@ -0,0 +1,7 @@
{
"rules": {
"no-console": [
0
]
}
}
7 changes: 7 additions & 0 deletions examples/.eslintrc.json
@@ -0,0 +1,7 @@
{
"rules": {
"no-console": [
0
]
}
}
16 changes: 8 additions & 8 deletions main.js
Expand Up @@ -5,7 +5,7 @@
http://yabfog.com
**********************************************************************/
/*jshint sub:true, laxcomma:true */

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -254,12 +254,12 @@ FeedParser.prototype.handleCloseTag = function (el){

// Add xhtml data to the container element
n['#'] += this.xhtml['#'].trim();
// Clear xhtml nodes from the tree
for (var key in n) {
if (key != '@' && key != '#') {
delete n[key];
}
// Clear xhtml nodes from the tree
for (var key in n) {
if (key != '@' && key != '#') {
delete n[key];
}
}
this.xhtml = {};
this.in_xhtml = false;
} else { // Somewhere in the middle of the XHTML
Expand Down Expand Up @@ -609,7 +609,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
});
}
else if (category[name]['@'] && (_categoryValue = utils.safeTrim(utils.get(category[name]['@'], 'text')))) {
meta.categories.push(_category + '/' + _categoryValue);
meta.categories.push(_category + '/' + _categoryValue);
}
}
else if (_category) {
Expand Down Expand Up @@ -877,7 +877,7 @@ FeedParser.prototype.handleItem = function handleItem (node, type, options){
if (el.title && utils.get(el.title))
item.source['title'] = utils.get(el.title);
if (el.link && utils.get(el.link['@'], 'href'))
item.source['url'] = utils.get(el.link['@'], 'href');
item.source['url'] = utils.get(el.link['@'], 'href');
}
if (item.source['url'] && !this.meta.xmlurl) {
this.meta.xmlurl = this.meta.xmlUrl = item.source['url'];
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -33,6 +33,7 @@
"readable-stream": "~1.0.17"
},
"devDependencies": {
"eslint": "^2.11.1",
"iconv": "2.1.x",
"mocha": "~2.1.0",
"request": "2.27.x"
Expand Down
10 changes: 10 additions & 0 deletions test/.eslintrc.json
@@ -0,0 +1,10 @@
{
"env": {
"mocha": true
},
"globals": {
"assert": true,
"fs": true,
"FeedParser": true
}
}
2 changes: 1 addition & 1 deletion utils.js
Expand Up @@ -201,7 +201,7 @@ exports.reresolve = reresolve;
*/

function stripHtml (str) {
return str.replace(/<.*?>/g, '');
return str.replace(/<.*?>/g, '');
}

exports.stripHtml = stripHtml;

0 comments on commit 3a742fb

Please sign in to comment.