Enforce brace style

This commit is contained in:
Pierre Ossman 2018-09-06 15:39:26 +02:00
parent e15950a8ef
commit a98881151f
3 changed files with 10 additions and 8 deletions

View File

@ -8,6 +8,8 @@
}, },
"extends": "eslint:recommended", "extends": "eslint:recommended",
"rules": { "rules": {
// Unsafe or confusing stuff that we forbid
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }], "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
"no-constant-condition": ["error", { "checkLoops": false }], "no-constant-condition": ["error", { "checkLoops": false }],
"no-var": "error", "no-var": "error",
@ -18,5 +20,9 @@
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }], "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
"arrow-spacing": ["error"], "arrow-spacing": ["error"],
"no-confusing-arrow": ["error", { "allowParens": true }], "no-confusing-arrow": ["error", { "allowParens": true }],
// Enforced coding style
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
} }
} }

View File

@ -147,8 +147,7 @@ const UI = {
if (!port) { if (!port) {
if (window.location.protocol.substring(0,5) == 'https') { if (window.location.protocol.substring(0,5) == 'https') {
port = 443; port = 443;
} } else if (window.location.protocol.substring(0,4) == 'http') {
else if (window.location.protocol.substring(0,4) == 'http') {
port = 80; port = 80;
} }
} }

View File

@ -15,23 +15,20 @@ import KeyTable from "./keysym.js";
const DOMKeyTable = {}; const DOMKeyTable = {};
function addStandard(key, standard) function addStandard(key, standard) {
{
if (standard === undefined) throw "Undefined keysym for key \"" + key + "\""; if (standard === undefined) throw "Undefined keysym for key \"" + key + "\"";
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\""; if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";
DOMKeyTable[key] = [standard, standard, standard, standard]; DOMKeyTable[key] = [standard, standard, standard, standard];
} }
function addLeftRight(key, left, right) function addLeftRight(key, left, right) {
{
if (left === undefined) throw "Undefined keysym for key \"" + key + "\""; if (left === undefined) throw "Undefined keysym for key \"" + key + "\"";
if (right === undefined) throw "Undefined keysym for key \"" + key + "\""; if (right === undefined) throw "Undefined keysym for key \"" + key + "\"";
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\""; if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";
DOMKeyTable[key] = [left, left, right, left]; DOMKeyTable[key] = [left, left, right, left];
} }
function addNumpad(key, standard, numpad) function addNumpad(key, standard, numpad) {
{
if (standard === undefined) throw "Undefined keysym for key \"" + key + "\""; if (standard === undefined) throw "Undefined keysym for key \"" + key + "\"";
if (numpad === undefined) throw "Undefined keysym for key \"" + key + "\""; if (numpad === undefined) throw "Undefined keysym for key \"" + key + "\"";
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\""; if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";