Re-enable and reconfigure eslint

This commit is contained in:
Florian Bruhin 2016-08-09 11:00:26 +02:00
parent 80016006c4
commit 4da53480c2
4 changed files with 55 additions and 64 deletions

View File

@ -1,49 +1,39 @@
# vim: ft=yaml
env: env:
browser: true browser: true
parserOptions:
ecmaVersion: 3
extends:
"eslint:all"
rules: rules:
block-scoped-var: 2
dot-location: 2
default-case: 2
guard-for-in: 2
no-div-regex: 2
no-param-reassign: 2
no-eq-null: 2
no-floating-decimal: 2
no-self-compare: 2
no-throw-literal: 2
no-void: 2
radix: 2
wrap-iife: [2, "inside"]
brace-style: [2, "1tbs", {"allowSingleLine": true}]
comma-style: [2, "last"]
consistent-this: [2, "self"]
func-style: [2, "declaration"]
indent: [2, 4, {"SwitchCase": 1}]
linebreak-style: [2, "unix"]
max-nested-callbacks: [2, 3]
no-lonely-if: 2
no-multiple-empty-lines: [2, {"max": 2}]
no-nested-ternary: 2
no-unneeded-ternary: 2
operator-assignment: [2, "always"]
operator-linebreak: [2, "after"]
keyword-spacing: 2
space-before-blocks: [2, "always"]
space-before-function-paren: [2, {"anonymous": "never", "named": "never"}]
object-curly-spacing: [2, "never"]
array-bracket-spacing: [2, "never"]
computed-property-spacing: [2, "never"]
space-in-parens: [2, "never"]
space-unary-ops: [2, {"words": true, "nonwords": false}]
spaced-comment: [2, "always"]
max-depth: [2, 5]
max-len: [2, 79, 4]
max-params: [2, 5]
max-statements: [2, 30]
no-bitwise: 2
quote-props: [2, "always"]
strict: ["error", "global"] strict: ["error", "global"]
quotes: 0 one-var: "off"
padded-blocks: ["error", "never"]
space-before-function-paren: ["error", "never"]
no-underscore-dangle: "off"
no-var: "off"
vars-on-top: "off"
newline-after-var: "off"
camelcase: "off"
require-jsdoc: "off"
func-style: ["error", "declaration"]
newline-before-return: "off"
init-declarations: "off"
no-plusplus: "off"
no-extra-parens: off
id-length: ["error", {"exceptions": ["i", "x", "y"]}]
object-shorthand: "off"
max-statements: ["error", {"max": 30}]
quotes: ["error", "double", {"avoidEscape": true}]
object-property-newline: ["error", {"allowMultiplePropertiesPerLine": true}]
comma-dangle: ["error", "always-multiline"]
no-magic-numbers: "off"
no-undefined: "off"
wrap-iife: ["error", "inside"]
func-names: "off"
# FIXME turn these on again after using a _qutebrowser object
no-unused-vars: "off"
no-implicit-globals: "off"

View File

@ -32,10 +32,11 @@
"use strict"; "use strict";
function isElementInViewport(node) { function isElementInViewport(node) { // eslint-disable-line complexity
var i; var i;
var boundingRect = (node.getClientRects()[0] || var boundingRect = (node.getClientRects()[0] ||
node.getBoundingClientRect()); node.getBoundingClientRect());
if (boundingRect.width <= 1 && boundingRect.height <= 1) { if (boundingRect.width <= 1 && boundingRect.height <= 1) {
var rects = node.getClientRects(); var rects = node.getClientRects();
for (i = 0; i < rects.length; i++) { for (i = 0; i < rects.length; i++) {
@ -54,8 +55,7 @@ function isElementInViewport(node) {
if (boundingRect.width <= 1 || boundingRect.height <= 1) { if (boundingRect.width <= 1 || boundingRect.height <= 1) {
var children = node.children; var children = node.children;
var visibleChildNode = false; var visibleChildNode = false;
var l = children.length; for (i = 0; i < children.length; ++i) {
for (i = 0; i < l; ++i) {
boundingRect = (children[i].getClientRects()[0] || boundingRect = (children[i].getClientRects()[0] ||
children[i].getBoundingClientRect()); children[i].getBoundingClientRect());
if (boundingRect.width > 1 && boundingRect.height > 1) { if (boundingRect.width > 1 && boundingRect.height > 1) {
@ -72,9 +72,9 @@ function isElementInViewport(node) {
return null; return null;
} }
var computedStyle = window.getComputedStyle(node, null); var computedStyle = window.getComputedStyle(node, null);
if (computedStyle.visibility !== 'visible' || if (computedStyle.visibility !== "visible" ||
computedStyle.display === 'none' || computedStyle.display === "none" ||
node.hasAttribute('disabled') || node.hasAttribute("disabled") ||
parseInt(computedStyle.width, 10) === 0 || parseInt(computedStyle.width, 10) === 0 ||
parseInt(computedStyle.height, 10) === 0) { parseInt(computedStyle.height, 10) === 0) {
return null; return null;
@ -88,7 +88,7 @@ function isElementInViewport(node) {
var textNodes = []; var textNodes = [];
var el; var el;
while ((node = walker.nextNode())) { while ((node = walker.nextNode())) {
if (node.nodeType === 3 && node.data.trim() !== '') { if (node.nodeType === 3 && node.data.trim() !== "") {
textNodes.push(node); textNodes.push(node);
} }
} }

View File

@ -43,9 +43,8 @@ function _qutebrowser_scroll_delta_page(x, y) {
function _qutebrowser_scroll_pos() { function _qutebrowser_scroll_pos() {
var elem = document.documentElement; var elem = document.documentElement;
var dx = (elem.scrollWidth - elem.clientWidth); var dx = elem.scrollWidth - elem.clientWidth;
var dy = (elem.scrollHeight - elem.clientHeight); var dy = elem.scrollHeight - elem.clientHeight;
var perc_x, perc_y; var perc_x, perc_y;
if (dx === 0) { if (dx === 0) {
@ -60,9 +59,10 @@ function _qutebrowser_scroll_pos() {
perc_y = 100 / dy * window.scrollY; perc_y = 100 / dy * window.scrollY;
} }
var pos_perc = {'x': perc_x, 'y': perc_y}; var pos = {
var pos_px = {'x': window.scrollX, 'y': window.scrollY}; "perc": {"x": perc_x, "y": perc_y},
var pos = {'perc': pos_perc, 'px': pos_px}; "px": {"x": window.scrollX, "y": window.scrollY},
};
// console.log(JSON.stringify(pos)); // console.log(JSON.stringify(pos));
return pos; return pos;

View File

@ -27,15 +27,15 @@ function _qutebrowser_serialize_elem(elem, id) {
"id": id, "id": id,
"text": elem.text, "text": elem.text,
"tag_name": elem.tagName, "tag_name": elem.tagName,
"outer_xml": elem.outerHTML "outer_xml": elem.outerHTML,
}; };
var attributes = {}; var attributes = {};
for (var i = 0; i < elem.attributes.length; ++i) { for (var i = 0; i < elem.attributes.length; ++i) {
attr = elem.attributes[i]; var attr = elem.attributes[i];
attributes[attr.name] = attr.value; attributes[attr.name] = attr.value;
} }
out["attributes"] = attributes; out.attributes = attributes;
// console.log(JSON.stringify(out)); // console.log(JSON.stringify(out));
@ -61,6 +61,7 @@ function _qutebrowser_find_all_elements(selector) {
function _qutebrowser_focus_element() { function _qutebrowser_focus_element() {
var elem = document.activeElement; var elem = document.activeElement;
if (!elem || elem === document.body) { if (!elem || elem === document.body) {
// "When there is no selection, the active element is the page's <body> // "When there is no selection, the active element is the page's <body>
// or null." // or null."