aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
authorGravatar KillyMXI2017-06-02 19:07:56 +0300
committerGravatar Vitaly Takmazov2017-06-03 15:08:20 +0300
commit7817d34a3f012f6c2cd446b70f97d6dcc72e6170 (patch)
treec91b1f4b0c734c8065772341ef2b77f5c27c7afe /juick-www
parent1fc31d9d94696be3a3c34e2652ad90ee95f76481 (diff)
eslint rules
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/.eslintrc43
-rw-r--r--juick-www/src/main/js/killy/index.js26
-rw-r--r--juick-www/src/main/static/scripts.js12
3 files changed, 53 insertions, 28 deletions
diff --git a/juick-www/.eslintrc b/juick-www/.eslintrc
index 70f0fc89..12d9a477 100644
--- a/juick-www/.eslintrc
+++ b/juick-www/.eslintrc
@@ -9,24 +9,49 @@
// features, you will need to enable a custom parser
// as described in a section below.
"parserOptions": {
- "ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"browser": true,
- "node": true
+ "node": true,
+ "es6": true
},
// Enable custom plugin known as eslint-plugin-react
"plugins": [
// "react"
],
+ // http://eslint.org/docs/rules/
"rules": {
- // Disable `no-console` rule
- "no-console": 0,
- // Give a warning if identifiers contain underscores
- "no-underscore-dangle": 1,
- // Default to single quotes and raise an error if something
- // else is used
- "quotes": [2, "single"]
+ "no-console": "off",
+ "no-underscore-dangle": "warn",
+ "quotes": ["error", "single"],
+
+ "no-const-assign": "warn",
+ "no-this-before-super": "warn",
+ "no-unreachable": "warn",
+ "no-undef": "warn",
+ "constructor-super": "warn",
+ "valid-typeof": "warn",
+ "no-eq-null": "warn",
+ "no-shadow-restricted-names": "warn",
+ "no-trailing-spaces": "warn",
+ "semi": "warn",
+ "keyword-spacing": "warn",
+ "block-spacing": "warn",
+ "arrow-spacing": "warn",
+ "semi-spacing": "warn",
+ "brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
+ "dot-location": ["warn", "property"],
+ //"indent": ["warn", 2],
+ "no-tabs": "warn",
+ "linebreak-style": ["warn", "windows"],
+ "eol-last": "warn",
+ "comma-style": "warn",
+ "curly": "warn",
+ //"no-var": "warn",
+ "no-shadow": "off",
+ "no-cond-assign": "off",
+ "no-sparse-arrays": "off",
+ "no-unused-vars": "off"
}
} \ No newline at end of file
diff --git a/juick-www/src/main/js/killy/index.js b/juick-www/src/main/js/killy/index.js
index 4d2331b6..bb8e21f9 100644
--- a/juick-www/src/main/js/killy/index.js
+++ b/juick-www/src/main/js/killy/index.js
@@ -8,18 +8,18 @@ function insertAfter(newNode, referenceNode) {
}
function moveAll(fromNode, toNode) {
- for (let c; (c = fromNode.firstChild) != null; ) { toNode.appendChild(c); }
+ for (let c; c = fromNode.firstChild; ) { toNode.appendChild(c); }
}
function removeAllFrom(fromNode) {
- for (let c; (c = fromNode.lastChild) != null; ) { fromNode.removeChild(c); }
+ for (let c; c = fromNode.lastChild; ) { fromNode.removeChild(c); }
}
function turnIntoCts(node, makeNodeCallback) {
node.onclick = function(e){
e.preventDefault();
let newNode = makeNodeCallback();
- if(newNode !== node) {
+ if (newNode !== node) {
removeAllFrom(node);
moveAll(newNode, node);
node.className = newNode.className;
@@ -161,7 +161,7 @@ function getEmbedableLinkTypes() {
return wrapIntoTag(makeIframe('//player.vimeo.com/video/' + reResult[1], 640, 360), 'div', 'vimeo');
}
}
- ]
+ ];
}
function embedLink(aNode, linkTypes, container, alwaysCts, afterNode) {
@@ -175,7 +175,7 @@ function embedLink(aNode, linkTypes, container, alwaysCts, afterNode) {
if (reResult !== null) {
if ((linkType.match !== undefined) && (linkType.match(aNode, reResult) === false)) { return false; }
let newNode;
- let isCts = alwaysCts /* || TODO user click-to-show setting */;
+ let isCts = alwaysCts; /* || TODO user click-to-show setting */
if (isCts) {
let linkTitle = (linkType.makeTitle !== undefined) ? linkType.makeTitle(aNode, reResult) : naiveEllipsis(aNode.href, 55);
newNode = makeCts(() => linkType.makeNode(aNode, reResult, newNode), 'Click to show: ' + linkTitle);
@@ -240,7 +240,7 @@ function embedLinksToX(x, beforeNodeSelector, allLinksSelector, ctsUsers, ctsTag
}
function embedLinksToArticles() {
- let ctsUsers = [], ctsTags = [] // TODO click-to-show users and tags
+ let ctsUsers = [], ctsTags = []; // TODO click-to-show users and tags
let beforeNodeSelector = 'nav.l';
let allLinksSelector = 'p:not(.ir) a, pre a';
Array.from(document.querySelectorAll('#content > article')).forEach(article => {
@@ -249,7 +249,7 @@ function embedLinksToArticles() {
}
function embedLinksToPost() {
- let ctsUsers = [], ctsTags = [] // TODO click-to-show users and tags
+ let ctsUsers = [], ctsTags = []; // TODO click-to-show users and tags
let beforeNodeSelector = '.msg-txt + *';
let allLinksSelector = '.msg-txt a';
Array.from(document.querySelectorAll('#content .msg-cont')).forEach(msg => {
@@ -258,9 +258,9 @@ function embedLinksToPost() {
}
exports.embed = function() {
- if (document.querySelectorAll('#content > article').length) {
- embedLinksToArticles();
- } else {
- embedLinksToPost();
- }
-}
+ if (document.querySelectorAll('#content > article').length) {
+ embedLinksToArticles();
+ } else {
+ embedLinksToPost();
+ }
+};
diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js
index 3951bfae..7de14b34 100644
--- a/juick-www/src/main/static/scripts.js
+++ b/juick-www/src/main/static/scripts.js
@@ -19,9 +19,9 @@ var ws,
function initWS() {
var content = document.getElementById('content');
- if (!content) { return }
+ if (!content) { return; }
var pageMID = content.getAttribute('data-mid');
- if (!pageMID) { return }
+ if (!pageMID) { return; }
var url = (window.location.protocol === 'https:' ? 'wss' : 'ws') + ':'
+ (typeof juickDebug !== 'undefined' ?
@@ -158,7 +158,7 @@ function wsIncomingReply(msg) {
if (isTreeMode() && (msg.replyto > 0)) {
var p = document.getElementById(msg.replyto);
var m = parseInt(p.style.marginLeft) + 20;
- while (p.nextElementSibling && (parseInt(p.nextElementSibling.style.marginLeft) >= m)) p = p.nextElementSibling;
+ while (p.nextElementSibling && (parseInt(p.nextElementSibling.style.marginLeft) >= m)) { p = p.nextElementSibling; }
li.style.marginLeft = m + 'px';
p.parentNode.insertBefore(li, p.nextSibling);
} else {
@@ -231,7 +231,7 @@ function newMessage() {
function showMoreReplies(el, id) {
var foldedReplies = el.closest('li').querySelector('.msg-comments');
- if (!foldedReplies) { return }
+ if (!foldedReplies) { return; }
foldedReplies.style.display = 'none';
var replies = document.querySelectorAll('#replies>li'),
@@ -383,7 +383,7 @@ function unfoldReply() {
var anchor = window.location.hash.substring(1);
if ((0 + anchor) > 0) {
var el = document.getElementById(anchor);
- if (!el) { return }
+ if (!el) { return; }
while (el.style.display === 'none') {
el = el.previousElementSibling;
}
@@ -444,7 +444,7 @@ function closeDialog() {
function openSocialWindow(a) {
var w = window.open(a.href, 'juickshare', 'width=640,height=400');
- if (window.focus) w.focus();
+ if (window.focus) { w.focus(); }
return false;
}