eslint comma-dangle error + autofix files

This commit is contained in:
tophf 2020-11-14 10:11:32 +03:00
parent 5a9451f267
commit 414609297d
52 changed files with 184 additions and 181 deletions

View File

@ -19,7 +19,7 @@ rules:
brace-style: [2, 1tbs, {allowSingleLine: false}]
camelcase: [2, {properties: never}]
class-methods-use-this: [2]
comma-dangle: [1, {arrays: always-multiline, objects: always-multiline}]
comma-dangle: [2, {arrays: always-multiline, objects: always-multiline}]
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, last]
complexity: [0]

View File

@ -25,7 +25,7 @@ workerUtil.createAPI({
'/js/meta-parser.js'
);
return metaParser.nullifyInvalidVars(vars);
}
},
});
function compileUsercss(preprocessor, code, vars) {
@ -55,7 +55,7 @@ function compileUsercss(preprocessor, code, vars) {
const va = vars[key];
output[key] = Object.assign({}, va, {
value: va.value === null || va.value === undefined ?
getVarValue(va, 'default') : getVarValue(va, 'value')
getVarValue(va, 'default') : getVarValue(va, 'value'),
});
return output;
}, {});
@ -86,7 +86,7 @@ function getUsercssCompiler(preprocessor) {
section.code = varDef + section.code;
}
}
}
},
},
stylus: {
preprocess(source, vars) {
@ -96,7 +96,7 @@ function getUsercssCompiler(preprocessor) {
new self.StylusRenderer(varDef + source)
.render((err, output) => err ? reject(err) : resolve(output));
});
}
},
},
less: {
preprocess(source, vars) {
@ -110,7 +110,7 @@ function getUsercssCompiler(preprocessor) {
const varDefs = Object.keys(vars).map(key => `@${key}:${vars[key].value};\n`).join('');
return self.less.render(varDefs + source)
.then(({css}) => css);
}
},
},
uso: {
preprocess(source, vars) {
@ -162,8 +162,8 @@ function getUsercssCompiler(preprocessor) {
return pool.get(name);
});
}
}
}
},
},
};
if (preprocessor) {

View File

@ -8,7 +8,7 @@
// eslint-disable-next-line no-var
var backgroundWorker = workerUtil.createWorker({
url: '/background/background-worker.js'
url: '/background/background-worker.js',
});
// eslint-disable-next-line no-var
@ -99,7 +99,7 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
getSyncStatus: sync.getStatus,
syncLogin: sync.login,
openManage
openManage,
});
// *************************************************************************
@ -119,7 +119,7 @@ if (FIREFOX) {
navigatorUtil.onDOMContentLoaded(webNavIframeHelperFF, {
url: [
{urlEquals: 'about:blank'},
]
],
});
}
@ -184,7 +184,7 @@ contextMenus = {
msg.sendTab(tab.id, {method: 'editDeleteText'}, undefined, 'extension')
.catch(msg.ignoreError);
},
}
},
};
async function createContextMenus(ids) {
@ -321,14 +321,14 @@ function openManage({options = false, search} = {}) {
url,
currentWindow: null,
ignoreHash: true,
ignoreSearch: true
ignoreSearch: true,
})
.then(tab => {
if (tab) {
return Promise.all([
activateTab(tab),
(tab.pendingUrl || tab.url) !== url && msg.sendTab(tab.id, {method: 'pushState', url})
.catch(console.error)
.catch(console.error),
]);
}
return getActiveTab().then(tab => {

View File

@ -29,7 +29,7 @@ const contentScripts = (() => {
url: [
{hostEquals: 'greasyfork.org', urlMatches},
{hostEquals: 'sleazyfork.org', urlMatches},
]
],
});
return {injectToTab, injectToAllTabs};
@ -57,7 +57,7 @@ const contentScripts = (() => {
const options = {
runAt: script.run_at,
allFrames: script.all_frames,
matchAboutBlank: script.match_about_blank
matchAboutBlank: script.match_about_blank,
};
if (frameId !== null) {
options.allFrames = false;
@ -80,7 +80,7 @@ const contentScripts = (() => {
} else {
injectToTab({
url: tab.pendingUrl || tab.url,
tabId: tab.id
tabId: tab.id,
});
}
}

View File

@ -32,7 +32,7 @@ function createChromeStorageDB() {
}
}
return output;
})
}),
};
return {exec};

View File

@ -13,7 +13,7 @@ const iconManager = (() => {
], () => debounce(refreshIconBadgeColor));
prefs.subscribe([
'show-badge'
'show-badge',
], () => debounce(refreshAllIconsBadgeText));
prefs.subscribe([
@ -79,7 +79,7 @@ const iconManager = (() => {
tabManager.set(tabId, 'icon', newIcon);
iconUtil.setIcon({
path: getIconPath(newIcon),
tabId
tabId,
});
}
@ -103,14 +103,14 @@ const iconManager = (() => {
function refreshGlobalIcon() {
iconUtil.setIcon({
path: getIconPath(getIconName())
path: getIconPath(getIconName()),
});
}
function refreshIconBadgeColor() {
const color = prefs.get(prefs.get('disableAll') ? 'badgeDisabled' : 'badgeNormal');
iconUtil.setBadgeBackgroundColor({
color
color,
});
}

View File

@ -19,7 +19,7 @@ const iconUtil = (() => {
Cache imageData for paths
*/
setIcon,
setBadgeText
setBadgeText,
});
function loadImage(url) {
@ -85,7 +85,7 @@ const iconUtil = (() => {
return target[prop];
}
return chrome.browserAction[prop].bind(chrome.browserAction);
}
},
});
}
})();

View File

@ -4,7 +4,7 @@
const navigatorUtil = (() => {
const handler = {
urlChange: null
urlChange: null,
};
return extendNative({onUrlChange});
@ -69,7 +69,7 @@ const navigatorUtil = (() => {
return target[prop];
}
return chrome.webNavigation[prop].addListener.bind(chrome.webNavigation[prop]);
}
},
});
}
})();

View File

@ -31,11 +31,11 @@
return fetch(api, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json'
'Content-Type': 'application/json',
}),
body: query({
id
})
id,
}),
})
.then(res => res.json());
};

View File

@ -40,7 +40,7 @@ const styleManager = (() => {
style.appliesTo.delete(url);
}
}
}
},
});
const BAD_MATCHER = {test: () => false};
@ -60,7 +60,7 @@ const styleManager = (() => {
protocol: '',
search: '',
searchParams: new URLSearchParams(),
username: ''
username: '',
};
const DELETE_IF_NULL = ['id', 'customName'];
@ -68,7 +68,7 @@ const styleManager = (() => {
handleLivePreviewConnections();
return Object.assign(/** @namespace styleManager */{
compareRevision
compareRevision,
}, ensurePrepared(/** @namespace styleManager */{
get,
getByUUID,
@ -88,7 +88,7 @@ const styleManager = (() => {
addExclusion,
removeExclusion,
addInclusion,
removeInclusion
removeInclusion,
}));
function handleLivePreviewConnections() {
@ -317,7 +317,7 @@ const styleManager = (() => {
uuidIndex.delete(style.data._id);
return msg.broadcast({
method: 'styleDeleted',
style: {id}
style: {id},
});
})
.then(() => id);
@ -348,7 +348,7 @@ const styleManager = (() => {
md5Url: null,
url: null,
originalMd5: null,
installDate: Date.now()
installDate: Date.now(),
};
}
@ -369,7 +369,7 @@ const styleManager = (() => {
updated.add(url);
cache.sections[data.id] = {
id: data.id,
code
code,
};
}
}
@ -379,10 +379,10 @@ const styleManager = (() => {
style: {
id: data.id,
md5Url: data.md5Url,
enabled: data.enabled
enabled: data.enabled,
},
reason,
codeIsUpdated
codeIsUpdated,
});
}
@ -425,7 +425,7 @@ const styleManager = (() => {
if (!style) {
styles.set(data.id, {
appliesTo: new Set(),
data
data,
});
method = 'styleAdded';
} else {
@ -473,7 +473,7 @@ const styleManager = (() => {
result.push({
data: getStyleWithNoCode(data),
excluded,
sloppy
sloppy,
});
}
}
@ -485,7 +485,7 @@ const styleManager = (() => {
if (!cache) {
cache = {
sections: {},
maybeMatch: new Set()
maybeMatch: new Set(),
};
buildCache(styles.values());
cachedStyleForUrl.set(url, cache);
@ -511,7 +511,7 @@ const styleManager = (() => {
if (code) {
cache.sections[data.id] = {
id: data.id,
code
code,
};
appliesTo.add(url);
}
@ -536,7 +536,7 @@ const styleManager = (() => {
const ADD_MISSING_PROPS = {
name: style => `ID: ${style.id}`,
_id: () => uuidv4(),
_rev: () => Date.now()
_rev: () => Date.now(),
};
return db.exec('getAll')
@ -560,7 +560,7 @@ const styleManager = (() => {
fixUsoMd5Issue(style);
styles.set(style.id, {
appliesTo: new Set(),
data: style
data: style,
});
uuidIndex.set(style._id, style.id);
}
@ -706,7 +706,7 @@ const styleManager = (() => {
domain = u.hostname;
}
return domain;
}
},
};
}

View File

@ -13,7 +13,7 @@ const sync = (() => {
progress: null,
currentDriveName: null,
errorMessage: null,
login: false
login: false,
};
let currentDrive;
const ctrl = dbToCloud.dbToCloud({
@ -43,7 +43,7 @@ const sync = (() => {
setState(drive, state) {
const key = `sync/state/${drive.name}`;
return chromeLocal.setValue(key, state);
}
},
});
const initializing = prefs.initializing.then(() => {
@ -58,7 +58,7 @@ const sync = (() => {
});
return Object.assign({
getStatus: () => status
getStatus: () => status,
}, ensurePrepared({
start,
stop,
@ -73,7 +73,7 @@ const sync = (() => {
return ctrl.delete(...args);
},
syncNow,
login
login,
}));
function ensurePrepared(obj) {
@ -99,7 +99,7 @@ const sync = (() => {
function schedule(delay = SYNC_DELAY) {
chrome.alarms.create('syncNow', {
delayInMinutes: delay,
periodInMinutes: SYNC_INTERVAL
periodInMinutes: SYNC_INTERVAL,
});
}
@ -206,7 +206,7 @@ const sync = (() => {
function getDrive(name) {
if (name === 'dropbox' || name === 'google' || name === 'onedrive') {
return dbToCloud.drive[name]({
getAccessToken: () => tokenManager.getToken(name)
getAccessToken: () => tokenManager.getToken(name),
});
}
throw new Error(`unknown cloud name: ${name}`);

View File

@ -13,9 +13,9 @@ const tokenManager = (() => {
fetch('https://api.dropboxapi.com/2/auth/token/revoke', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
}
})
'Authorization': `Bearer ${token}`,
},
}),
},
google: {
flow: 'code',
@ -27,14 +27,14 @@ const tokenManager = (() => {
// tokens for multiple machines.
// https://stackoverflow.com/q/18519185
access_type: 'offline',
prompt: 'consent'
prompt: 'consent',
},
tokenURL: 'https://oauth2.googleapis.com/token',
scopes: ['https://www.googleapis.com/auth/drive.appdata'],
revoke: token => {
const params = {token};
return postQuery(`https://accounts.google.com/o/oauth2/revoke?${new URLSearchParams(params)}`);
}
},
},
onedrive: {
flow: 'code',
@ -45,8 +45,8 @@ const tokenManager = (() => {
redirect_uri: FIREFOX ?
'https://clngdbkpkpeebahjckkjfobafhncgmne.chromiumapp.org/' :
'https://' + location.hostname + '.chromiumapp.org/',
scopes: ['Files.ReadWrite.AppFolder', 'offline_access']
}
scopes: ['Files.ReadWrite.AppFolder', 'offline_access'],
},
};
const NETWORK_LATENCY = 30; // seconds
@ -114,7 +114,7 @@ const tokenManager = (() => {
client_id: provider.clientId,
refresh_token: obj[k.REFRESH],
grant_type: 'refresh_token',
scope: provider.scopes.join(' ')
scope: provider.scopes.join(' '),
};
if (provider.clientSecret) {
body.client_secret = provider.clientSecret;
@ -136,7 +136,7 @@ const tokenManager = (() => {
response_type: provider.flow,
client_id: provider.clientId,
redirect_uri: provider.redirect_uri || chrome.identity.getRedirectURL(),
state
state,
};
if (provider.scopes) {
query.scope = provider.scopes.join(' ');
@ -148,7 +148,7 @@ const tokenManager = (() => {
return webextLaunchWebAuthFlow({
url,
interactive,
redirect_uri: query.redirect_uri
redirect_uri: query.redirect_uri,
})
.then(url => {
const params = new URLSearchParams(
@ -171,7 +171,7 @@ const tokenManager = (() => {
code,
grant_type: 'authorization_code',
client_id: provider.clientId,
redirect_uri: query.redirect_uri
redirect_uri: query.redirect_uri,
};
if (provider.clientSecret) {
body.client_secret = provider.clientSecret;
@ -185,7 +185,7 @@ const tokenManager = (() => {
return chromeLocal.set({
[k.TOKEN]: result.access_token,
[k.EXPIRE]: result.expires_in ? Date.now() + (Number(result.expires_in) - NETWORK_LATENCY) * 1000 : undefined,
[k.REFRESH]: result.refresh_token
[k.REFRESH]: result.refresh_token,
})
.then(() => result.access_token);
}
@ -194,7 +194,7 @@ const tokenManager = (() => {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
'Content-Type': 'application/x-www-form-urlencoded',
},
body: body ? new URLSearchParams(body) : null,
};

View File

@ -61,7 +61,7 @@ const usercssHelper = (() => {
find(styleId ? {id: styleId} : style) : Promise.resolve();
return Promise.all([
metaOnly ? style : doBuild(style, findDup),
findDup
findDup,
]);
})
.then(([style, dup]) => ({style, dup}));

View File

@ -5,7 +5,7 @@
const manifest = chrome.runtime.getManifest();
const allowedOrigins = [
'https://openusercss.org',
'https://openusercss.com'
'https://openusercss.com',
];
const sendPostMessage = message => {
@ -17,7 +17,7 @@
const askHandshake = () => {
// Tell the page that we exist and that it should send the handshake
sendPostMessage({
type: 'ouc-begin-handshake'
type: 'ouc-begin-handshake',
});
};
@ -25,7 +25,7 @@
const sendInstalledCallback = styleData => {
sendPostMessage({
type: 'ouc-is-installed-response',
style: styleData
style: styleData,
});
};
@ -36,14 +36,14 @@
) {
API.findUsercss({
name: event.data.name,
namespace: event.data.namespace
namespace: event.data.namespace,
}).then(style => {
const data = {event};
const callbackObject = {
installed: Boolean(style),
enabled: style.enabled,
name: data.name,
namespace: data.namespace
namespace: data.namespace,
};
sendInstalledCallback(callbackObject);
@ -71,7 +71,7 @@
'update-auto',
'export-json-backups',
'import-json-backups',
'manage-local'
'manage-local',
];
const reportedFeatures = [];
@ -96,8 +96,8 @@
key: event.data.key,
extension: {
name: manifest.name,
capabilities: reportedFeatures
}
capabilities: reportedFeatures,
},
});
};
@ -120,7 +120,7 @@
// we were able to install the theme and it may display a success message
sendPostMessage({
type: 'ouc-install-callback',
key: data.key
key: data.key,
});
};
@ -135,7 +135,7 @@
}).then(style => {
sendInstallCallback({
enabled: style.enabled,
key: event.data.key
key: event.data.key,
});
});
}

View File

@ -85,7 +85,7 @@
const observer = new MutationObserver(check);
observer.observe(document.documentElement, {
childList: true,
subtree: true
subtree: true,
});
check();
@ -105,7 +105,7 @@
? 'styleCanBeUpdatedChrome'
: 'styleAlreadyInstalledChrome',
detail: {
updateUrl: installedStyle.updateUrl
updateUrl: installedStyle.updateUrl,
},
});
});
@ -155,7 +155,7 @@
function doInstall() {
let oldStyle;
return API.findStyle({
md5Url: getMeta('stylish-md5-url') || location.href
md5Url: getMeta('stylish-md5-url') || location.href,
}, true)
.then(_oldStyle => {
oldStyle = _oldStyle;

View File

@ -162,7 +162,7 @@ function beautify(scope, ui = true) {
$create('SVG:path', {
'fill-rule': 'evenodd',
'd': 'M1408 704q0 26-19 45l-448 448q-19 19-45 ' +
'19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z'
'19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z',
}),
]),
]),
@ -176,7 +176,7 @@ function beautify(scope, ui = true) {
$create('input', {
type: 'checkbox',
dataset: {option: optionName},
checked: options[optionName] !== false
checked: options[optionName] !== false,
}),
$create('SVG:svg.svg-icon.checked',
$create('SVG:use', {'xlink:href': '#svg-icon-checked'})),

View File

@ -82,7 +82,7 @@
[
{from: 'Ctrl-', to: ['Alt-', 'Ctrl-Alt-']},
// Note: modifier order in CodeMirror is S-C-A
{from: 'Shift-Ctrl-', to: ['Ctrl-Alt-', 'Shift-Ctrl-Alt-']}
{from: 'Shift-Ctrl-', to: ['Ctrl-Alt-', 'Shift-Ctrl-Alt-']},
].forEach(remap => {
const oldKey = remap.from + char;
Object.keys(CodeMirror.keyMap).forEach(keyMapName => {
@ -134,7 +134,7 @@
let filled;
this.eachLine(({text}) => (filled = text && /\S/.test(text)));
return !filled;
}
},
});
// editor commands

View File

@ -33,13 +33,13 @@ const cmFactory = (() => {
cm.setOption('highlightSelectionMatches', {
showToken: /[#.\-\w]/,
annotateScrollbar: true,
onUpdate: updateMatchHighlightCount
onUpdate: updateMatchHighlightCount,
});
} else if (value === 'selection') {
cm.setOption('highlightSelectionMatches', {
showToken: false,
annotateScrollbar: true,
onUpdate: updateMatchHighlightCount
onUpdate: updateMatchHighlightCount,
});
} else {
cm.setOption('highlightSelectionMatches', null);

View File

@ -1,7 +1,7 @@
/* exported CODEMIRROR_THEMES */
// this file is generated by update-codemirror-themes.js
/* Do not edit. This file is auto-generated by build-vendor.js */
'use strict';
/* exported CODEMIRROR_THEMES */
const CODEMIRROR_THEMES = [
'3024-day',
'3024-night',
@ -65,5 +65,5 @@ const CODEMIRROR_THEMES = [
'xq-light',
'yeti',
'yonce',
'zenburn'
'zenburn',
];

View File

@ -72,7 +72,7 @@ lazyInit();
cm.scrollIntoView(cm.getCursor(), si.parentHeight / 2);
});
}
}
},
});
prefs.subscribe('editor.linter', updateLinter);
prefs.subscribe('editor.keyMap', showHotkeyInTooltip);
@ -512,7 +512,7 @@ function showCodeMirrorPopup(title, html, options) {
matchBrackets: true,
styleActiveLine: true,
theme: prefs.get('editor.theme'),
keyMap: prefs.get('editor.keyMap')
keyMap: prefs.get('editor.keyMap'),
}, options));
cm.focus();
rerouteHotkeys(false);

View File

@ -29,13 +29,13 @@ workerUtil.createAPI({
code: err.code,
args: err.args,
message: err.message,
index: err.index
index: err.index,
})
);
return result;
},
getStylelintRules,
getCsslintRules
getCsslintRules,
});
function getCsslintRules() {

View File

@ -100,7 +100,7 @@ onDOMready().then(() => {
state.lastFind = '';
toggleDataset(this, 'enabled', !state.icase);
doSearch({canAdvance: false});
}
},
},
};
@ -136,7 +136,7 @@ onDOMready().then(() => {
trimUndoHistory();
enableUndoButton(state.undoHistory.length);
if (state.find) doSearch({canAdvance: false});
}
},
};
const DIALOG_PROPS = {
@ -152,7 +152,7 @@ onDOMready().then(() => {
state.replace = this.value;
adjustTextareaSize(this);
debounce(writeStorage, STORAGE_UPDATE_DELAY);
}
},
},
};
@ -169,7 +169,7 @@ onDOMready().then(() => {
replace(cm) {
state.reverse = false;
focusDialog('replace', cm);
}
},
};
COMMANDS.replaceAll = COMMANDS.replace;

View File

@ -61,7 +61,7 @@
loadScript([
'/vendor/codemirror/mode/javascript/javascript.js',
'/vendor/codemirror/addon/lint/json-lint.js',
'/vendor/jsonlint/jsonlint.js'
'/vendor/jsonlint/jsonlint.js',
]).then(() => {
cm.setOption('mode', 'application/json');
cm.setOption('lint', true);

View File

@ -12,13 +12,13 @@ const LINTER_DEFAULTS = (() => {
rules: {
'at-rule-no-unknown': [true, {
'ignoreAtRules': ['extend', 'extends', 'css', 'block'],
'severity': 'warning'
'severity': 'warning',
}],
'block-no-empty': [true, SEVERITY],
'color-no-invalid-hex': [true, SEVERITY],
'declaration-block-no-duplicate-properties': [true, {
'ignore': ['consecutive-duplicates-with-different-values'],
'severity': 'warning'
'severity': 'warning',
}],
'declaration-block-no-shorthand-property-overrides': [true, SEVERITY],
'font-family-no-duplicate-names': [true, SEVERITY],
@ -172,7 +172,7 @@ const LINTER_DEFAULTS = (() => {
'value-list-comma-space-before': 'never',
'value-list-max-empty-lines': 0
*/
}
},
};
const CSSLINT = {
// Default warnings
@ -216,7 +216,7 @@ const LINTER_DEFAULTS = (() => {
'universal-selector': 0,
'unqualified-attributes': 0,
'vendor-prefix': 0,
'zero-units': 0
'zero-units': 0,
};
return {STYLELINT, CSSLINT, SEVERITY};
})();

View File

@ -7,7 +7,7 @@
storageName: chromeSync.LZ_KEY.csslint,
lint: csslint,
validMode: mode => mode === 'css',
getConfig: config => Object.assign({}, LINTER_DEFAULTS.CSSLINT, config)
getConfig: config => Object.assign({}, LINTER_DEFAULTS.CSSLINT, config),
},
stylelint: {
storageName: chromeSync.LZ_KEY.stylelint,
@ -15,9 +15,9 @@
validMode: () => true,
getConfig: config => ({
syntax: 'sugarss',
rules: Object.assign({}, LINTER_DEFAULTS.STYLELINT.rules, config && config.rules)
})
}
rules: Object.assign({}, LINTER_DEFAULTS.STYLELINT.rules, config && config.rules),
}),
},
});
async function stylelint(text, config, mode) {

View File

@ -33,7 +33,7 @@ function createMetaCompiler(cm, onUpdated) {
to: cm.posFromIndex((err.index || 0) + match.index),
message: err.code && chrome.i18n.getMessage(`meta_${err.code}`, err.args) || err.message,
severity: err.code === 'unknownMeta' ? 'warning' : 'error',
rule: err.code
rule: err.code,
})
);
meta = match[0];

View File

@ -77,7 +77,7 @@ Object.assign(linter, (() => {
element: table,
trs,
updateAnnotations,
updateCaption
updateCaption,
};
function updateCaption() {
@ -124,18 +124,18 @@ Object.assign(linter, (() => {
const message = $create('td', {attributes: {role: 'message'}});
const trElement = $create('tr', {
onclick: () => gotoLintIssue(cm, anno)
onclick: () => gotoLintIssue(cm, anno),
}, [
severity,
line,
$create('td', {attributes: {role: 'sep'}}, ':'),
col,
message
message,
]);
return {
element: trElement,
update,
getAnnotation: () => anno
getAnnotation: () => anno,
};
function update(_anno) {

View File

@ -3,7 +3,7 @@
/* exported editorWorker */
const editorWorker = workerUtil.createWorker({
url: '/edit/editor-worker.js'
url: '/edit/editor-worker.js',
});
/* exported linter */
@ -19,7 +19,7 @@ const linter = (() => {
enableForEditor,
disableForEditor,
onLintingUpdated,
onUnhook
onUnhook,
};
function onUnhook(cb) {

View File

@ -40,7 +40,7 @@ function createLivePreview(preprocess, shouldShow) {
function createPreviewer() {
const port = chrome.runtime.connect({
name: 'livePreview'
name: 'livePreview',
});
port.onDisconnect.addListener(err => {
throw err;

View File

@ -75,7 +75,7 @@ function MozSectionFinder(cm) {
/** @param {MozSection} [section] */
updatePositions(section) {
(section ? [section] : getState().sections).forEach(setPositionFromMark);
}
},
};
return MozSectionFinder;

View File

@ -74,7 +74,7 @@ function MozSectionWidget(
if (funcs.length < 2) {
messageBox({
contents: t('appliesRemoveError'),
buttons: [t('confirmClose')]
buttons: [t('confirmClose')],
});
return;
}
@ -125,7 +125,7 @@ function MozSectionWidget(
return;
}
}
}
},
};
actualStyle = $create('style');

View File

@ -436,7 +436,7 @@ function SectionsEditor() {
/** @returns {Style} */
function getModel() {
return Object.assign({}, style, {
sections: sections.filter(s => !s.removed).map(s => s.getModel())
sections: sections.filter(s => !s.removed).map(s => s.getModel()),
});
}

View File

@ -99,7 +99,7 @@ function SourceEditor() {
return API.buildUsercss({
styleId: style.id,
sourceCode: style.sourceCode,
assignVars: true
assignVars: true,
})
.then(({style: newStyle}) => {
delete newStyle.enabled;

View File

@ -214,6 +214,6 @@ function createHotkeyInput(prefId, onDone = () => {}) {
},
onpaste(event) {
event.preventDefault();
}
},
});
}

View File

@ -22,7 +22,7 @@
if (theme !== 'default') {
document.head.appendChild($create('link', {
rel: 'stylesheet',
href: `vendor/codemirror/theme/${theme}.css`
href: `vendor/codemirror/theme/${theme}.css`,
}));
}
window.addEventListener('resize', adjustCodeHeight);
@ -111,7 +111,7 @@
frag.appendChild($createLink(url,
$create('SVG:svg.svg-icon', {viewBox: '0 0 20 20'},
$create('SVG:path', {
d: 'M4,4h5v2H6v8h8v-3h2v5H4V4z M11,3h6v6l-2-2l-4,4L9,9l4-4L11,3z'
d: 'M4,4h5v2H6v8h8v-3h2v5H4V4z M11,3h6v6l-2-2l-4,4L9,9l4-4L11,3z',
}))
));
}
@ -130,7 +130,7 @@
$create('li',
$createLink(...args)
)
))
)),
]));
}
}

View File

@ -25,7 +25,7 @@ function createCache({size = 1000, onDeleted} = {}) {
},
get size() {
return map.size;
}
},
};
function get(id) {

View File

@ -296,7 +296,7 @@ function $createLink(href = '', content) {
const opt = {
tag: 'a',
target: '_blank',
rel: 'noopener'
rel: 'noopener',
};
if (typeof href === 'object') {
Object.assign(opt, href);

View File

@ -126,7 +126,7 @@ function urlToMatchPattern(url, ignoreSearch) {
if (ignoreSearch) {
return [
`${url.protocol}//${url.hostname}/${url.pathname}`,
`${url.protocol}//${url.hostname}/${url.pathname}?*`
`${url.protocol}//${url.hostname}/${url.pathname}?*`,
];
}
// FIXME: is %2f allowed in pathname and search?
@ -220,7 +220,7 @@ function activateTab(tab, {url, index, openerTabId} = {}) {
return Promise.all([
browser.tabs.update(tab.id, options),
browser.windows && browser.windows.update(tab.windowId, {focused: true}),
index != null && browser.tabs.move(tab.id, {index})
index != null && browser.tabs.move(tab.id, {index}),
])
.then(() => tab);
}

View File

@ -12,17 +12,17 @@ const metaParser = (() => {
throw new ParseError({
code: 'unknownPreprocessor',
args: [state.value],
index: state.valueIndex
index: state.valueIndex,
});
}
}
},
},
validateVar: {
select: state => {
if (state.varResult.options.every(o => o.name !== state.value)) {
throw new ParseError({
code: 'invalidSelectValueMismatch',
index: state.valueIndex
index: state.valueIndex,
});
}
},
@ -32,19 +32,19 @@ const metaParser = (() => {
throw new ParseError({
code: 'invalidColor',
args: [state.value],
index: state.valueIndex
index: state.valueIndex,
});
}
state.value = colorConverter.format(color, 'rgb');
}
}
},
},
};
const parser = createParser(options);
const looseParser = createParser(Object.assign({}, options, {allowErrors: true, unknownKey: 'throw'}));
return {
parse,
lint,
nullifyInvalidVars
nullifyInvalidVars,
};
function parse(text, indexOffset) {

View File

@ -20,7 +20,7 @@ const usercss = (() => {
const style = {
enabled: true,
sourceCode,
sections: []
sections: [],
};
const match = sourceCode.match(RX_META);

View File

@ -67,7 +67,7 @@ const workerUtil = {
message: err.message,
lineNumber: err.lineNumber,
columnNumber: err.columnNumber,
fileName: err.fileName
fileName: err.fileName,
}, err);
},

View File

@ -28,7 +28,7 @@ function configDialog(style) {
contents: [
$create('.config-heading', data.supportURL &&
$createLink({className: '.external-support', href: data.supportURL}, t('externalFeedback'))),
$create('.config-body', elements)
$create('.config-body', elements),
],
buttons: [{
textContent: t('confirmSave'),
@ -210,8 +210,8 @@ function configDialog(style) {
$create('SVG:polygon', {
points: '16.2,5.5 14.5,3.8 10,8.3 5.5,3.8 3.8,5.5 8.3,10 3.8,14.5 ' +
'5.5,16.2 10,11.7 14.5,16.2 16.2,14.5 11.7,10',
})
])
}),
]),
]);
for (const va of vars) {
let children;
@ -222,7 +222,7 @@ function configDialog(style) {
va.input = $create('a.color-swatch', {
va,
href: '#',
onclick: showColorpicker
onclick: showColorpicker,
}),
]),
];
@ -268,7 +268,7 @@ function configDialog(style) {
onblur: va.type === 'number' ? updateVarOnBlur : null,
onchange: updateVarOnChange,
oninput: updateVarOnInput,
required: true
required: true,
};
if (typeof va.min === 'number') {
options.min = va.min;
@ -281,7 +281,7 @@ function configDialog(style) {
}
children = [
va.type === 'range' && $create('span.current-value'),
va.input = $create('input.config-value', options)
va.input = $create('input.config-value', options),
];
break;
}

View File

@ -157,7 +157,7 @@ function filterOnChange({target: el, forceRefilter}) {
el.dataset[hide ? 'filterHide' : 'filter']
.split(/,\s*/)
.map(s => (hide ? '.entry:not(.hidden)' : '') + s)
.join(','))
.join(',')),
].join(hide ? ',' : '');
Object.assign(filtersSelector, {
hide: buildFilter(true),

View File

@ -71,7 +71,7 @@ Promise.all([
// FIXME: integrate this into filter.js
router.getSearch('search') && API.searchDB({query: router.getSearch('search')}),
waitForSelector('#installed'), // needed to avoid flicker due to an extra frame and layout shift
prefs.initializing
prefs.initializing,
]).then(([styles, ids, el]) => {
installed = el;
installed.onclick = handleEvent.entryClicked;
@ -370,7 +370,7 @@ Object.assign(handleEvent, {
'.update': 'update',
'.delete': 'delete',
'.applies-to .expander': 'expandTargets',
'.configure-usercss': 'config'
'.configure-usercss': 'config',
},
entryClicked(event) {
@ -526,7 +526,7 @@ Object.assign(handleEvent, {
{prop: 'updateDate', name: 'dateUpdated'},
].map(({prop, name}) =>
t(name) + ': ' + (formatDate(entry.styleMeta[prop]) || '—')).join('\n');
}
},
});

View File

@ -13,28 +13,28 @@ const sorter = (() => {
title: {
text: t('genericTitle'),
parse: ({name}) => name,
sorter: sorterType.alpha
sorter: sorterType.alpha,
},
usercss: {
text: 'Usercss',
parse: ({style}) => style.usercssData ? 0 : 1,
sorter: sorterType.number
sorter: sorterType.number,
},
disabled: {
text: '', // added as either "enabled" or "disabled" by the addOptions function
parse: ({style}) => style.enabled ? 1 : 0,
sorter: sorterType.number
sorter: sorterType.number,
},
dateInstalled: {
text: t('dateInstalled'),
parse: ({style}) => style.installDate,
sorter: sorterType.number
sorter: sorterType.number,
},
dateUpdated: {
text: t('dateUpdated'),
parse: ({style}) => style.updateDate || style.installDate,
sorter: sorterType.number
}
sorter: sorterType.number,
},
};
// Adding (assumed) most commonly used ('title,asc' should always be first)
@ -56,7 +56,7 @@ const sorter = (() => {
'usercss,asc, title,desc',
'usercss,desc, title,desc',
'disabled,desc, title,desc',
'disabled,desc, usercss,asc, title,desc'
'disabled,desc, usercss,asc, title,desc',
];
const splitRegex = /\s*,\s*/;
@ -76,7 +76,7 @@ const sorter = (() => {
dateNew: ` (${t('sortDateNewestFirst')})`,
dateOld: ` (${t('sortDateOldestFirst')})`,
groupAsc: t('sortLabelTitleAsc'),
groupDesc: t('sortLabelTitleDesc')
groupDesc: t('sortLabelTitleDesc'),
};
const optgroupRegex = /\{\w+\}/;
selectOptions.forEach(sort => {
@ -132,7 +132,7 @@ const sorter = (() => {
entry,
name: entry.styleNameLowerCase,
style: entry.styleMeta,
}))
})),
});
if (current.some((entry, index) => entry !== sorted[index].entry)) {
const renderBin = document.createDocumentFragment();

View File

@ -87,7 +87,7 @@ function messageBox({
},
scroll() {
scrollTo(blockScroll.x, blockScroll.y);
}
},
};
}
@ -160,7 +160,7 @@ messageBox.alert = (contents, className, title) =>
title,
contents,
className: `center ${className || ''}`,
buttons: [t('confirmClose')]
buttons: [t('confirmClose')],
});
/**
@ -174,5 +174,5 @@ messageBox.confirm = (contents, className, title) =>
title,
contents,
className: `center ${className || ''}`,
buttons: [t('confirmYes'), t('confirmNo')]
buttons: [t('confirmYes'), t('confirmNo')],
}).then(result => result.button === 0 || result.enter);

View File

@ -344,7 +344,7 @@ function createStyleElement(style) {
styleId: style.id,
styleIsUsercss: Boolean(style.usercssData),
onmousedown: handleEvent.maybeEdit,
styleMeta: style
styleMeta: style,
});
const checkbox = $('.checker', entry);
Object.assign(checkbox, {
@ -645,7 +645,7 @@ Object.assign(handleEvent, {
this.eventHandled = true;
API.openManage({
search: tabURL && (event.shiftKey || event.button === 2) ?
`url:${tabURL}` : null
`url:${tabURL}` : null,
});
window.close();
}

View File

@ -273,7 +273,7 @@ window.addEventListener('showStyles:done', () => {
// title
Object.assign($('.search-result-title', entry), {
onclick: handleEvent.openURLandHide,
href: URLS.usoArchive + `?category=${category}&style=${id}`
href: URLS.usoArchive + `?category=${category}&style=${id}`,
});
$('.search-result-title span', entry).textContent =
tWordBreak(name.length < 300 ? name : name.slice(0, 300) + '...');
@ -303,7 +303,7 @@ window.addEventListener('showStyles:done', () => {
// time
Object.assign($('[data-type="updated"] time', entry), {
dateTime: updateTime * 1000,
textContent: formatDate(updateTime * 1000)
textContent: formatDate(updateTime * 1000),
});
// totals
$('[data-type="weekly"] dd', entry).textContent = formatNumber(weeklyInstalls);

View File

@ -32,37 +32,37 @@ const files = {
'mode/css',
'mode/javascript',
'mode/stylus',
'theme/*'
'theme/*',
],
'jsonlint': [
'lib/jsonlint.js → jsonlint.js',
'README.md → LICENSE'
'README.md → LICENSE',
],
'less-bundle': [
'dist/less.min.js → less.min.js'
'dist/less.min.js → less.min.js',
],
'lz-string-unsafe': [
'lz-string-unsafe.min.js'
'lz-string-unsafe.min.js',
],
'semver-bundle': [
'dist/semver.js → semver.js'
'dist/semver.js → semver.js',
],
'stylelint-bundle': [
'stylelint-bundle.min.js',
'https://github.com/stylelint/stylelint/raw/{VERSION}/LICENSE → LICENSE'
'https://github.com/stylelint/stylelint/raw/{VERSION}/LICENSE → LICENSE',
],
'stylus-lang-bundle': [
'dist/stylus-renderer.min.js → stylus-renderer.min.js'
'dist/stylus-renderer.min.js → stylus-renderer.min.js',
],
'usercss-meta': [
'dist/usercss-meta.min.js → usercss-meta.min.js'
'dist/usercss-meta.min.js → usercss-meta.min.js',
],
'db-to-cloud': [
'dist/db-to-cloud.min.js → db-to-cloud.min.js'
'dist/db-to-cloud.min.js → db-to-cloud.min.js',
],
'webext-launch-web-auth-flow': [
'dist/webext-launch-web-auth-flow.min.js → webext-launch-web-auth-flow.min.js'
]
'dist/webext-launch-web-auth-flow.min.js → webext-launch-web-auth-flow.min.js',
],
};
main().catch(console.error);
@ -87,12 +87,15 @@ async function generateThemeList() {
.map(name => name.replace('.css', ''))
.sort();
return endent`
/* exported CODEMIRROR_THEMES */
// this file is generated by update-codemirror-themes.js
/* Do not edit. This file is auto-generated by build-vendor.js */
'use strict';
const CODEMIRROR_THEMES = ${JSON.stringify(themes, null, 2)};
`.replace(/"/g, "'") + '\n';
/* exported CODEMIRROR_THEMES */
const CODEMIRROR_THEMES = [
${
themes.map(t => ` '${t.replace(/'/g, '\\$&')}',\n`).join('')
}];
` + '\n';
}
async function copyLicense(pkg) {

View File

@ -16,7 +16,7 @@ function createZip({isFirefox} = {}) {
'package-lock.json',
'yarn.lock',
'*.zip',
'*.map'
'*.map',
];
const file = fs.createWriteStream(fileName);

View File

@ -12,7 +12,7 @@
{hex: '#00ffff', start: .50},
{hex: '#0000ff', start: .67},
{hex: '#ff00ff', start: .83},
{hex: '#ff0000', start: 1}
{hex: '#ff0000', start: 1},
];
const MIN_HEIGHT = 220;
const MARGIN = 8;
@ -119,7 +119,7 @@
$inputGroups.hex = $(['input-group', 'hex'], [
$(['input-field', 'hex'], [
$hexCode = $('input', {tag: 'input', type: 'text', spellcheck: false,
pattern: /^\s*#([a-fA-F\d]{3}([a-fA-F\d]([a-fA-F\d]{2}([a-fA-F\d]{2})?)?)?)\s*$/.source
pattern: /^\s*#([a-fA-F\d]{3}([a-fA-F\d]([a-fA-F\d]{2}([a-fA-F\d]{2})?)?)?)\s*$/.source,
}),
$('title', [
$hexLettercase.true = $('title-action', {onclick: onHexLettercaseClicked}, 'HEX'),
@ -186,7 +186,7 @@
Object.defineProperty($inputs.hsl, 'color', {get: inputsToHSL});
Object.defineProperty($inputs, 'color', {get: () => $inputs[currentFormat].color});
Object.defineProperty($inputs, 'colorString', {
get: () => currentFormat && colorConverter.format($inputs[currentFormat].color)
get: () => currentFormat && colorConverter.format($inputs[currentFormat].color),
});
HUE_COLORS.forEach(color => Object.assign(color, colorConverter.parse(color.hex)));

View File

@ -2057,7 +2057,7 @@ self.parserlib = (() => {
return m.toString(p);
}).join(required === false ? ' || ' : ' && ');
return prec > p ? `[ ${s} ]` : s;
}
},
};
Matcher.parseGrammar = (() => {
@ -5300,7 +5300,7 @@ self.parserlib = (() => {
_readDeclarations({
checkStart = true,
readMargins = false,
stopAfterBrace = false
stopAfterBrace = false,
} = {}) {
const stream = this._tokenStream;
if (checkStart) stream.mustMatch(Tokens.LBRACE);