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

View File

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

View File

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