Fix eslint issues identified in m-c

pull/270/head
Gijs Kruitbosch 8 years ago
parent dffa760c04
commit e830ac9dd8

@ -0,0 +1,194 @@
{
"rules": {
// Braces only needed for multi-line arrow function blocks
// "arrow-body-style": [2, "as-needed"],
// Require spacing around =>
// "arrow-spacing": 2,
// Always require spacing around a single line block
// "block-spacing": 1,
// No newline before open brace for a block
// "brace-style": 2,
// No space before always a space after a comma
// "comma-spacing": [2, {"before": false, "after": true}],
// Commas at the end of the line not the start
// "comma-style": 2,
// Don't require spaces around computed properties
// "computed-property-spacing": [2, "never"],
// Functions must always return something or nothing
"consistent-return": 2,
// Require braces around blocks that start a new line
// Note that this rule is likely to be overridden on a per-directory basis
// very frequently.
// "curly": [2, "multi-line"],
// Always require a trailing EOL
"eol-last": 2,
// Require function* name()
// "generator-star-spacing": [2, {"before": false, "after": true}],
// Two space indent
// "indent": [2, 2, { "SwitchCase": 1 }],
// Space after colon not before in property declarations
// "key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
// Unix linebreaks
"linebreak-style": [2, "unix"],
// Always require parenthesis for new calls
// "new-parens": 2,
// Use [] instead of Array()
// "no-array-constructor": 2,
// No duplicate arguments in function declarations
"no-dupe-args": 2,
// No duplicate keys in object declarations
"no-dupe-keys": 2,
// No duplicate cases in switch statements
"no-duplicate-case": 2,
// No labels
"no-labels": 2,
// If an if block ends with a return no need for an else block
// "no-else-return": 2,
// No empty statements
// "no-empty": 2,
// No empty character classes in regex
"no-empty-character-class": 2,
// Disallow empty destructuring
"no-empty-pattern": 2,
// No assiging to exception variable
// "no-ex-assign": 2,
// No using !! where casting to boolean is already happening
// "no-extra-boolean-cast": 2,
// No double semicolon
"no-extra-semi": 2,
// No overwriting defined functions
"no-func-assign": 2,
// No invalid regular expresions
"no-invalid-regexp": 2,
// No odd whitespace characters
"no-irregular-whitespace": 2,
// No single if block inside an else block
// "no-lonely-if": 2,
// No mixing spaces and tabs in indent
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
// No unnecessary spacing
// "no-multi-spaces": [2, { exceptions: { "AssignmentExpression": true, "VariableDeclarator": true, "ArrayExpression": true, "ObjectExpression": true } }],
// No reassigning native JS objects
"no-native-reassign": 2,
// No (!foo in bar)
"no-negated-in-lhs": 2,
// Nested ternary statements are confusing
"no-nested-ternary": 2,
// Use {} instead of new Object()
// "no-new-object": 2,
// No Math() or JSON()
"no-obj-calls": 2,
// No octal literals
"no-octal": 2,
// No redeclaring variables
"no-redeclare": 2,
// No unnecessary comparisons
"no-self-compare": 2,
// No declaring variables from an outer scope
// "no-shadow": 2,
// No declaring variables that hide things like arguments
// "no-shadow-restricted-names": 2,
// No spaces between function name and parentheses
// "no-spaced-func": 2,
// No trailing whitespace
"no-trailing-spaces": 2,
// No using undeclared variables
// "no-undef": 2,
// Error on newline where a semicolon is needed
"no-unexpected-multiline": 2,
// No unreachable statements
// "no-unreachable": 2,
// No expressions where a statement is expected
// "no-unused-expressions": 2,
// No declaring variables that are never used
// "no-unused-vars": [2, {"vars": "all", "args": "none"}],
// No using variables before defined
// "no-use-before-define": [2, "nofunc"],
// No using with
"no-with": 2,
// Always require semicolon at end of statement
// "semi": [2, "always"],
// Require space after keywords
// "space-after-keywords": 2,
// Require space before blocks
// "space-before-blocks": 2,
// Never use spaces before function parentheses
// "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }],
// Require spaces before finally, catch, etc.
// "space-before-keywords": [2, "always"],
// No space padding in parentheses
// "space-in-parens": [2, "never"],
// Require spaces around operators
// "space-infix-ops": 2,
// Require spaces after return, throw and case
// "space-return-throw-case": 2,
// ++ and -- should not need spacing
// "space-unary-ops": [2, { "words": true, "nonwords": false }],
// No comparisons to NaN
"use-isnan": 2,
// Only check typeof against valid results
"valid-typeof": 2,
},
}

@ -1,3 +1,4 @@
/*eslint-env es6:false*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -691,12 +692,13 @@
set innerHTML(html) {
var parser = new JSDOMParser();
var node = parser.parse(html);
for (var i = this.childNodes.length; --i >= 0;) {
var i;
for (i = this.childNodes.length; --i >= 0;) {
this.childNodes[i].parentNode = null;
}
this.childNodes = node.childNodes;
this.children = node.children;
for (var i = this.childNodes.length; --i >= 0;) {
for (i = this.childNodes.length; --i >= 0;) {
this.childNodes[i].parentNode = this;
}
},
@ -1081,16 +1083,16 @@
// Read any text as Text node
if (c !== "<") {
--this.currentChar;
var node = new Text();
var textNode = new Text();
var n = this.html.indexOf("<", this.currentChar);
if (n === -1) {
node.innerHTML = this.html.substring(this.currentChar, this.html.length);
textNode.innerHTML = this.html.substring(this.currentChar, this.html.length);
this.currentChar = this.html.length;
} else {
node.innerHTML = this.html.substring(this.currentChar, n);
textNode.innerHTML = this.html.substring(this.currentChar, n);
this.currentChar = n;
}
return node;
return textNode;
}
c = this.peekNext();

@ -1,3 +1,4 @@
/*eslint-env es6:false*/
/*
* Copyright (c) 2010 Arc90 Inc
*
@ -65,8 +66,11 @@ var Readability = function(uri, doc, options) {
return rv + '("' + e.textContent + '")';
}
var classDesc = e.className && ("." + e.className.replace(/ /g, "."));
var elDesc = e.id ? "(#" + e.id + classDesc + ")" :
(classDesc ? "(" + classDesc + ")" : "");
var elDesc = "";
if (e.id)
elDesc = "(#" + e.id + classDesc + ")";
else if (classDesc)
elDesc = "(" + classDesc + ")";
return rv + elDesc;
}
this.log = function () {
@ -368,9 +372,9 @@ Readability.prototype = {
// (which will be replaced with a <p> later).
while ((next = this._nextElement(next)) && (next.tagName == "BR")) {
replaced = true;
var sibling = next.nextSibling;
var brSibling = next.nextSibling;
next.parentNode.removeChild(next);
next = sibling;
next = brSibling;
}
// If we removed a <br> chain, replace the remaining <br> with a <p>. Add
@ -741,7 +745,12 @@ Readability.prototype = {
// - parent: 1 (no division)
// - grandparent: 2
// - great grandparent+: ancestor level * 3
var scoreDivider = level === 0 ? 1 : level === 1 ? 2 : level * 3;
if (level === 0)
var scoreDivider = 1;
else if (level === 1)
scoreDivider = 2;
else
scoreDivider = level * 3;
ancestor.readability.contentScore += contentScore / scoreDivider;
});
});
@ -854,7 +863,8 @@ Readability.prototype = {
if (nodeLength > 80 && linkDensity < 0.25) {
append = true;
} else if (nodeLength < 80 && linkDensity === 0 && nodeContent.search(/\.( |$)/) !== -1) {
} else if (nodeLength < 80 && nodeLength > 0 && linkDensity === 0 &&
nodeContent.search(/\.( |$)/) !== -1) {
append = true;
}
}
@ -1139,7 +1149,7 @@ Readability.prototype = {
_getLinkDensity: function(element) {
var textLength = this._getInnerText(element).length;
if (textLength === 0)
return;
return 0;
var linkLength = 0;

@ -17,7 +17,7 @@ var FFX_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100
if (process.argv.length < 3) {
console.error("Need at least a destination slug and potentially a URL (if the slug doesn't have source).");
process.exit(0);
return;
throw "Abort";
}
var slug = process.argv[2];

Loading…
Cancel
Save