This commit is contained in:
Ilya Ig. Petrov 2017-02-05 15:17:59 +00:00
parent 5af9458eae
commit fda42ee307
9 changed files with 66 additions and 53 deletions

View File

@ -1,24 +1,33 @@
module.exports = { module.exports = {
"extends": ["airbnb"], extends: ['google'],
"env": { env: {
"browser": true, browser: true,
"webextensions": true, webextensions: true,
"es6": true es6: true
}, },
"globals": { globals: {
"chrome": true chrome: true
}, },
"parserOptions": { parserOptions: {
"sourceType": "script", sourceType: 'script',
"ecmaVersion": 2017, ecmaVersion: 2017,
"ecmaFeatures": { ecmaFeatures: {
"impliedStrict": false impliedStrict: false
} }
}, },
"rules": { rules: {
"strict": ["error", "global"], strict: ['error', 'global'],
"no-console": "off", 'no-console': 'off',
"padded-blocks": "off", 'padded-blocks': 'off',
"require-jsdoc": "off" 'require-jsdoc': 'off',
}
// Taken from airbnb:
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
},
}; };

View File

@ -11,9 +11,6 @@
"license": "GPLv3", "license": "GPLv3",
"devDependencies": { "devDependencies": {
"eslint": "^3.15.0", "eslint": "^3.15.0",
"eslint-config-airbnb": "^14.0.0", "eslint-config-google": "^0.7.1"
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0"
} }
} }

View File

@ -102,7 +102,7 @@
} }
localStorage.setItem(key, JSON.stringify(value)); localStorage.setItem(key, JSON.stringify(value));
} };
}, },

View File

@ -59,7 +59,7 @@
return (privates._strToHostObj[hostStr] = {host: hostStr}); return (privates._strToHostObj[hostStr] = {host: hostStr});
} };
const _getHostObj = function _getHostObj(hostStr) { const _getHostObj = function _getHostObj(hostStr) {
@ -186,9 +186,9 @@
console.log('Canonized hosts/ips:', hostSet.size + '/' + ipSet.size); console.log('Canonized hosts/ips:', hostSet.size + '/' + ipSet.size);
return [ipSet, hostSet]; return [ipSet, hostSet];
} };
const self = window.apis.ipToHost = { window.apis.ipToHost = {
persist() { persist() {
@ -247,7 +247,12 @@
console.log('Update all:', hostArr); console.log('Update all:', hostArr);
const promises = hostArr.map( 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) => { Promise.all( promises ).then( (cbsRes) => {

View File

@ -85,7 +85,7 @@
const pacMods = getCurrentConfigs(); const pacMods = getCurrentConfigs();
return Object.keys(configs).reduce((arr, key) => { return Object.keys(configs).reduce((arr, key) => {
const conf = configs[key] const conf = configs[key];
if(typeof(conf.index) === 'number') { if(typeof(conf.index) === 'number') {
arr[conf.index] = conf; arr[conf.index] = conf;
conf.value = pacMods[key]; conf.value = pacMods[key];
@ -144,7 +144,7 @@
this.excluded = []; this.excluded = [];
for(const host of Object.keys(this.exceptions)) { for(const host of Object.keys(this.exceptions)) {
if (this.exceptions[host]) { if (this.exceptions[host]) {
this.included.push(host) this.included.push(host);
} else { } else {
this.excluded.push(host); this.excluded.push(host);
} }
@ -320,7 +320,7 @@
return cb(null, res, ...warns); 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( window.apis.ipToHost.replaceAllAsync(
hosts, hosts,
(...args) => cb(...args, ...warns) (...args) => cb(...args, ...warns)

View File

@ -26,7 +26,6 @@
const chromified = window.utils.chromified; const chromified = window.utils.chromified;
const checkChromeError = window.utils.checkChromeError; const checkChromeError = window.utils.checkChromeError;
const clarify = window.apis.errorsLib.clarify;
const clarifyThen = window.apis.errorsLib.clarifyThen; const clarifyThen = window.apis.errorsLib.clarifyThen;
const Warning = window.apis.errorsLib.Warning; const Warning = window.apis.errorsLib.Warning;
@ -332,7 +331,7 @@
} }
const warns = pacWarns; const warns = pacWarns;
if (ipsErr) { if (ipsErr) {
warns.push(ipsErr) warns.push(ipsErr);
} }
this.pushToStorageAsync( this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, ...warns) (pushErr) => cb(pacErr || pushErr, null, ...warns)

View File

@ -144,11 +144,6 @@
) )
); );
};
const isInsideTabWithIp = function isInsideTabWithIp(requestDetails) {
}; };
const onRequest = function onRequest(requestDetails) { const onRequest = function onRequest(requestDetails) {

View File

@ -75,7 +75,11 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
return document.getElementById(id); return document.getElementById(id);
}; };
const checkChosenProvider = () => currentProviderRadio().checked = true; const checkChosenProvider = () => {
currentProviderRadio().checked = true;
};
const showErrors = (err, ...warns) => { const showErrors = (err, ...warns) => {
@ -234,7 +238,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
const ifInsideOptions = !currentTab || currentTab.url.startsWith('chrome://extensions/?options='); const ifInsideOptions = !currentTab || currentTab.url.startsWith('chrome://extensions/?options=');
if (ifInsideOptions) { if (ifInsideOptions) {
document.documentElement.classList.add('if-options-page') document.documentElement.classList.add('if-options-page');
} }
// EXCEPTIONS PANEL // EXCEPTIONS PANEL
@ -347,7 +351,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
excEditor.dataset.moveCursorTo = nu; excEditor.dataset.moveCursorTo = nu;
window.setTimeout(moveCursorIfNeeded, 0); window.setTimeout(moveCursorIfNeeded, 0);
} };
const originalHost = excEditor.value.trim(); const originalHost = excEditor.value.trim();
const ifInit = !event; const ifInit = !event;
@ -558,11 +562,11 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</tex
(str) => (str) =>
/^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g /^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g
.test(str) .test(str)
) );
if (!ifValid) { if (!ifValid) {
return showErrors(new TypeError( return showErrors(new TypeError(
'Неверный формат своих прокси. Свертесь с <a href="https://rebrand.ly/ac-own-proxy" data-in-bg="true">документацией</a>.' 'Неверный формат своих прокси. Свертесь с <a href="https://rebrand.ly/ac-own-proxy" data-in-bg="true">документацией</a>.'
)) ));
} }
oldMods[customProxyStringKey] = taVal; oldMods[customProxyStringKey] = taVal;
} else { } else {
@ -575,7 +579,11 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</tex
'Применяем настройки...', 'Применяем настройки...',
(cb) => pacKitchen.keepCookedNowAsync(oldMods, cb), (cb) => pacKitchen.keepCookedNowAsync(oldMods, cb),
'Настройки применены.', 'Настройки применены.',
() => { document.getElementById('apply-mods').disabled = true; } () => {
document.getElementById('apply-mods').disabled = true;
}
); );
}; };