From fda42ee307f436682d873168354c0b81ce474227 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sun, 5 Feb 2017 15:17:59 +0000 Subject: [PATCH] Lint --- extensions/chromium/.eslintrc.js | 45 +++++++++++-------- extensions/chromium/package.json | 5 +-- .../extension/00-init-apis.js | 2 +- .../extension/14-ip-to-host-api.js | 19 +++++--- .../extension/15-pac-kitchen-api.js | 8 ++-- ...7-sync-pac-script-with-pac-provider-api.js | 3 +- .../extension/20-api-fixes.js | 2 +- .../extension/30-block-informer.js | 5 --- .../pages/choose-pac-provider/index.js | 30 ++++++++----- 9 files changed, 66 insertions(+), 53 deletions(-) diff --git a/extensions/chromium/.eslintrc.js b/extensions/chromium/.eslintrc.js index 8eabbff..7ab3f09 100644 --- a/extensions/chromium/.eslintrc.js +++ b/extensions/chromium/.eslintrc.js @@ -1,24 +1,33 @@ module.exports = { - "extends": ["airbnb"], - "env": { - "browser": true, - "webextensions": true, - "es6": true + extends: ['google'], + env: { + browser: true, + webextensions: true, + es6: true }, - "globals": { - "chrome": true + globals: { + chrome: true }, - "parserOptions": { - "sourceType": "script", - "ecmaVersion": 2017, - "ecmaFeatures": { - "impliedStrict": false + parserOptions: { + sourceType: 'script', + ecmaVersion: 2017, + ecmaFeatures: { + impliedStrict: false } }, - "rules": { - "strict": ["error", "global"], - "no-console": "off", - "padded-blocks": "off", - "require-jsdoc": "off" - } + rules: { + strict: ['error', 'global'], + 'no-console': 'off', + 'padded-blocks': 'off', + 'require-jsdoc': 'off', + + // Taken from airbnb: + 'max-len': ['error', 100, 2, { + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }], + }, }; diff --git a/extensions/chromium/package.json b/extensions/chromium/package.json index b42437e..3428831 100644 --- a/extensions/chromium/package.json +++ b/extensions/chromium/package.json @@ -11,9 +11,6 @@ "license": "GPLv3", "devDependencies": { "eslint": "^3.15.0", - "eslint-config-airbnb": "^14.0.0", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^3.0.2", - "eslint-plugin-react": "^6.9.0" + "eslint-config-google": "^0.7.1" } } diff --git a/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js b/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js index b3d1dde..26ed1fb 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js +++ b/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js @@ -102,7 +102,7 @@ } localStorage.setItem(key, JSON.stringify(value)); - } + }; }, diff --git a/extensions/chromium/runet-censorship-bypass/extension/14-ip-to-host-api.js b/extensions/chromium/runet-censorship-bypass/extension/14-ip-to-host-api.js index cbf7d2c..70559eb 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/14-ip-to-host-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/14-ip-to-host-api.js @@ -20,7 +20,7 @@ const m = (str.match(ipRe) || []).filter( (c) => c ); const port = m.length > 1 ? m.pop() : false; - return { ifMatched: m.length, port: port }; + return {ifMatched: m.length, port: port}; }; @@ -57,9 +57,9 @@ const _createHostObj = function _addHostObj(hostStr) { - return (privates._strToHostObj[hostStr] = { host: hostStr }); + return (privates._strToHostObj[hostStr] = {host: hostStr}); - } + }; const _getHostObj = function _getHostObj(hostStr) { @@ -186,16 +186,16 @@ console.log('Canonized hosts/ips:', hostSet.size + '/' + ipSet.size); return [ipSet, hostSet]; - } + }; - const self = window.apis.ipToHost = { + window.apis.ipToHost = { persist() { console.log('Persisting ipToHost...', privates); const ipToHost = {}; for( const ip of Object.keys(privates._ipToHostObj) ) { - ipToHost[ ip ] = privates._ipToHostObj[ ip ].host; + ipToHost[ip] = privates._ipToHostObj[ip].host; } _state(ip2host, ipToHost); @@ -247,7 +247,12 @@ console.log('Update all:', hostArr); const promises = hostArr.map( - (hostStr) => new Promise( (resolve) => this._addAsync(hostStr, (...args) => resolve(args) ) ) + (hostStr) => new Promise( + (resolve) => this._addAsync( + hostStr, + (...args) => resolve(args) + ) + ) ); Promise.all( promises ).then( (cbsRes) => { diff --git a/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js index 8527830..7f186e2 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js @@ -85,7 +85,7 @@ const pacMods = getCurrentConfigs(); return Object.keys(configs).reduce((arr, key) => { - const conf = configs[key] + const conf = configs[key]; if(typeof(conf.index) === 'number') { arr[conf.index] = conf; conf.value = pacMods[key]; @@ -144,7 +144,7 @@ this.excluded = []; for(const host of Object.keys(this.exceptions)) { if (this.exceptions[host]) { - this.included.push(host) + this.included.push(host); } else { this.excluded.push(host); } @@ -320,7 +320,7 @@ return cb(null, res, ...warns); } - const hosts = par.map( (ps) => ps.split(/\s+/)[1] ) + const hosts = par.map( (ps) => ps.split(/\s+/)[1] ); window.apis.ipToHost.replaceAllAsync( hosts, (...args) => cb(...args, ...warns) @@ -355,7 +355,7 @@ } const pacMods = getCurrentConfigs(); pac.data = pacKitchen.cook( pac.data, pacMods ); - originalSet({ value: details.value }, (/* No args. */) => { + originalSet({value: details.value}, (/* No args. */) => { kitchenState(ifIncontinence, null); cb && cb(); diff --git a/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js b/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js index b379258..e8f969b 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js @@ -26,7 +26,6 @@ const chromified = window.utils.chromified; const checkChromeError = window.utils.checkChromeError; - const clarify = window.apis.errorsLib.clarify; const clarifyThen = window.apis.errorsLib.clarifyThen; const Warning = window.apis.errorsLib.Warning; @@ -332,7 +331,7 @@ } const warns = pacWarns; if (ipsErr) { - warns.push(ipsErr) + warns.push(ipsErr); } this.pushToStorageAsync( (pushErr) => cb(pacErr || pushErr, null, ...warns) diff --git a/extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js b/extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js index 18b51ec..cc24199 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js +++ b/extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js @@ -5,7 +5,7 @@ in bg error handlers. More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568 setTimeout is applied to Async/Void methods - only (name ends with Async/Void) + only (name ends with Async/Void) */ // Fix error context of methods of all APIs. diff --git a/extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js b/extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js index e20a0a5..2ab92f1 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js +++ b/extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js @@ -144,11 +144,6 @@ ) ); - }; - - const isInsideTabWithIp = function isInsideTabWithIp(requestDetails) { - - }; const onRequest = function onRequest(requestDetails) { diff --git a/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.js b/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.js index 8011d26..7719d06 100755 --- a/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.js +++ b/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.js @@ -75,7 +75,11 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => return document.getElementById(id); }; - const checkChosenProvider = () => currentProviderRadio().checked = true; + const checkChosenProvider = () => { + + currentProviderRadio().checked = true; + + }; const showErrors = (err, ...warns) => { @@ -227,14 +231,14 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => const currentTab = await new Promise( (resolve) => chrome.tabs.query( - { active: true, currentWindow: true }, + {active: true, currentWindow: true}, ([tab]) => resolve(tab) ) ); const ifInsideOptions = !currentTab || currentTab.url.startsWith('chrome://extensions/?options='); if (ifInsideOptions) { - document.documentElement.classList.add('if-options-page') + document.documentElement.classList.add('if-options-page'); } // EXCEPTIONS PANEL @@ -347,7 +351,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => excEditor.dataset.moveCursorTo = nu; window.setTimeout(moveCursorIfNeeded, 0); - } + }; const originalHost = excEditor.value.trim(); const ifInit = !event; @@ -525,7 +529,7 @@ HTTPS foobar.com:3143; HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}`; li.querySelector('textarea').onkeyup = function() { - this.dispatchEvent(new Event('change', { 'bubbles': true })); + this.dispatchEvent( new Event('change', {'bubbles': true}) ); }; } @@ -555,14 +559,14 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''} str ) .every( - (str) => - /^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g - .test(str) - ) + (str) => + /^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g + .test(str) + ); if (!ifValid) { return showErrors(new TypeError( 'Неверный формат своих прокси. Свертесь с документацией.' - )) + )); } oldMods[customProxyStringKey] = taVal; } else { @@ -575,7 +579,11 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''} pacKitchen.keepCookedNowAsync(oldMods, cb), 'Настройки применены.', - () => { document.getElementById('apply-mods').disabled = true; } + () => { + + document.getElementById('apply-mods').disabled = true; + + } ); };