Revert no-inline-comments (2ea5a3bbaa2fdb0a)

This commit is contained in:
Rob Garrison 2017-08-21 13:58:24 -05:00
parent 4e502e57eb
commit 8dc2115347
8 changed files with 60 additions and 115 deletions

View File

@ -151,7 +151,7 @@ rules:
no-implicit-coercion: [1] no-implicit-coercion: [1]
no-implicit-globals: [0] no-implicit-globals: [0]
no-implied-eval: [2] no-implied-eval: [2]
no-inline-comments: [2] no-inline-comments: [0]
no-inner-declarations: [2] no-inner-declarations: [2]
no-invalid-regexp: [2] no-invalid-regexp: [2]
no-invalid-this: [0] no-invalid-this: [0]

View File

@ -10,21 +10,14 @@ var SLOPPY_REGEXP_PREFIX = '\0';
// Note, only 'var'-declared variables are visible from another extension page // Note, only 'var'-declared variables are visible from another extension page
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var cachedStyles = { var cachedStyles = {
// array of all styles list: null, // array of all styles
list: null, byId: new Map(), // all styles indexed by id
// all styles indexed by id filters: new Map(), // filterStyles() parameters mapped to the returned results, 10k max
byId: new Map(), regexps: new Map(), // compiled style regexps
// filterStyles() parameters mapped to the returned results, 10k max urlDomains: new Map(), // getDomain() results for 100 last checked urls
filters: new Map(),
// compiled style regexps
regexps: new Map(),
// getDomain() results for 100 last checked urls
urlDomains: new Map(),
mutex: { mutex: {
// while getStyles() is reading IndexedDB all subsequent calls inProgress: false, // while getStyles() is reading IndexedDB all subsequent calls
inProgress: false, onDone: [], // to getStyles() are queued and resolved when the first one finishes
// to getStyles() are queued and resolved when the first one finishes
onDone: [],
}, },
}; };
@ -255,10 +248,8 @@ function saveStyle(style) {
}); });
} }
if (reason === 'import') { if (reason === 'import') {
// TODO: remove in the future style.originalDigest = style.originalDigest || style.styleDigest; // TODO: remove in the future
style.originalDigest = style.originalDigest || style.styleDigest; delete style.styleDigest; // TODO: remove in the future
// TODO: remove in the future
delete style.styleDigest;
if (typeof style.originalDigest !== 'string' || style.originalDigest.length !== 40) { if (typeof style.originalDigest !== 'string' || style.originalDigest.length !== 40) {
delete style.originalDigest; delete style.originalDigest;
} }
@ -533,8 +524,7 @@ function cleanupCachedFilters({force = false} = {}) {
const now = Date.now(); const now = Date.now();
const timeSpan = now - oldestHit; const timeSpan = now - oldestHit;
const recencyWeight = 5 / size; const recencyWeight = 5 / size;
// we make ~4 hits per URL const hitWeight = 1 / 4; // we make ~4 hits per URL
const hitWeight = 1 / 4;
const lastHitWeight = 10; const lastHitWeight = 10;
// delete the oldest 10% // delete the oldest 10%
[...cachedStyles.filters.entries()] [...cachedStyles.filters.entries()]

View File

@ -100,8 +100,7 @@ var updater = {
} }
return !save ? json : return !save ? json :
saveStyle(Object.assign(json, { saveStyle(Object.assign(json, {
// keep local name customizations name: null, // keep local name customizations
name: null,
reason: 'update', reason: 'update',
})); }));
} }

View File

@ -276,8 +276,7 @@ function initDocRewriteObserver() {
} }
ROOT = document.documentElement; ROOT = document.documentElement;
for (const el of styleElements.values()) { for (const el of styleElements.values()) {
// invalidate CSSOM cache el.textContent += ' '; // invalidate CSSOM cache
el.textContent += ' ';
addStyleElement(document.importNode(el, true)); addStyleElement(document.importNode(el, true));
} }
}; };
@ -351,8 +350,7 @@ function orphanCheck() {
window.removeEventListener(chrome.runtime.id, orphanCheck, true); window.removeEventListener(chrome.runtime.id, orphanCheck, true);
// we can't detach chrome.runtime.onMessage because it's no longer connected internally // we can't detach chrome.runtime.onMessage because it's no longer connected internally
// we can destroy our globals in this context to free up memory // we can destroy our globals in this context to free up memory
[ [ // functions
// functions
'addStyleElement', 'addStyleElement',
'applyOnMessage', 'applyOnMessage',
'applySections', 'applySections',

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
// non-Windows Chromium const CHROMIUM = /Chromium/.test(navigator.userAgent); // non-Windows Chromium
const CHROMIUM = /Chromium/.test(navigator.userAgent);
const FIREFOX = /Firefox/.test(navigator.userAgent); const FIREFOX = /Firefox/.test(navigator.userAgent);
const VIVALDI = /Vivaldi/.test(navigator.userAgent); const VIVALDI = /Vivaldi/.test(navigator.userAgent);
const OPERA = /OPR/.test(navigator.userAgent); const OPERA = /OPR/.test(navigator.userAgent);

View File

@ -4,56 +4,34 @@
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var prefs = new function Prefs() { var prefs = new function Prefs() {
const defaults = { const defaults = {
// new editor opens in a own browser window 'openEditInWindow': false, // new editor opens in a own browser window
'openEditInWindow': false, 'windowPosition': {}, // detached window position
// detached window position 'show-badge': true, // display text on popup menu icon
'windowPosition': {}, 'disableAll': false, // boss key
// display text on popup menu icon 'exposeIframes': false, // Add 'stylus-iframe' attribute to HTML element in all iframes
'show-badge': true,
// boss key
'disableAll': false,
// Add 'stylus-iframe' attribute to HTML element in all iframes
'exposeIframes': false,
// display 'New style' links as URL breadcrumbs 'popup.breadcrumbs': true, // display 'New style' links as URL breadcrumbs
'popup.breadcrumbs': true, 'popup.breadcrumbs.usePath': false, // use URL path for 'this URL'
// use URL path for 'this URL' 'popup.enabledFirst': true, // display enabled styles before disabled styles
'popup.breadcrumbs.usePath': false, 'popup.stylesFirst': true, // display enabled styles before disabled styles
// display enabled styles before disabled styles
'popup.enabledFirst': true,
// display enabled styles before disabled styles
'popup.stylesFirst': true,
// display only enabled styles 'manage.onlyEnabled': false, // display only enabled styles
'manage.onlyEnabled': false, 'manage.onlyLocal': false, // display only styles created locally
// display only styles created locally
'manage.onlyLocal': false,
'manage.onlyEnabled.invert': false, // display only disabled styles 'manage.onlyEnabled.invert': false, // display only disabled styles
'manage.onlyLocal.invert': false, // display only externally installed styles 'manage.onlyLocal.invert': false, // display only externally installed styles
// use the new compact layout 'manage.newUI': true, // use the new compact layout
'manage.newUI': true, 'manage.newUI.favicons': false, // show favicons for the sites in applies-to
// show favicons for the sites in applies-to 'manage.newUI.faviconsGray': true, // gray out favicons
'manage.newUI.favicons': false, 'manage.newUI.targets': 3, // max number of applies-to targets visible: 0 = none
// gray out favicons
'manage.newUI.faviconsGray': true,
// max number of applies-to targets visible: 0 = none
'manage.newUI.targets': 3,
// CodeMirror.defaults.* 'editor.options': {}, // CodeMirror.defaults.*
'editor.options': {}, 'editor.lineWrapping': true, // word wrap
// word wrap 'editor.smartIndent': true, // 'smart' indent
'editor.lineWrapping': true, 'editor.indentWithTabs': false, // smart indent with tabs
// 'smart' indent 'editor.tabSize': 4, // tab width, in spaces
'editor.smartIndent': true,
// smart indent with tabs
'editor.indentWithTabs': false,
// tab width, in spaces
'editor.tabSize': 4,
'editor.keyMap': navigator.appVersion.indexOf('Windows') > 0 ? 'sublime' : 'default', 'editor.keyMap': navigator.appVersion.indexOf('Windows') > 0 ? 'sublime' : 'default',
// CSS theme 'editor.theme': 'default', // CSS theme
'editor.theme': 'default', 'editor.beautify': { // CSS beautifier
// CSS beautifier
'editor.beautify': {
selector_separator_newline: true, selector_separator_newline: true,
newline_before_open_brace: false, newline_before_open_brace: false,
newline_after_open_brace: true, newline_after_open_brace: true,
@ -63,34 +41,24 @@ var prefs = new function Prefs() {
end_with_newline: false, end_with_newline: false,
indent_conditional: true, indent_conditional: true,
}, },
// lint gutter marker update delay, ms 'editor.lintDelay': 500, // lint gutter marker update delay, ms
'editor.lintDelay': 500, 'editor.linter': 'csslint', // Choose csslint or stylelint
// Options: 'csslint', 'stylelint' or 'null' 'editor.lintReportDelay': 4500, // lint report update delay, ms
'editor.linter': 'csslint', 'editor.matchHighlight': 'token', // token = token/word under cursor even if nothing is selected
// lint report update delay, ms
'editor.lintReportDelay': 4500,
// token = token/word under cursor even if nothing is selected
// selection = only when something is selected // selection = only when something is selected
// '' (empty string) = disabled // '' (empty string) = disabled
'editor.matchHighlight': 'token', 'editor.autocompleteOnTyping': false, // show autocomplete dropdown on typing a word token
// show autocomplete dropdown on typing a word token 'editor.contextDelete': contextDeleteMissing(), // "Delete" item in context menu
'editor.autocompleteOnTyping': false,
// "Delete" item in context menu
'editor.contextDelete': contextDeleteMissing(),
// 0 = dark-themed icon; 1 = light-themed icon 'iconset': 0, // 0 = dark-themed icon
'iconset': 0, // 1 = light-themed icon
// badge background color when disabled 'badgeDisabled': '#8B0000', // badge background color when disabled
'badgeDisabled': '#8B0000', 'badgeNormal': '#006666', // badge background color
// badge background color
'badgeNormal': '#006666',
// popup width in pixels 'popupWidth': 246, // popup width in pixels
'popupWidth': 246,
// user-style automatic update interval, hours (0 = disable) 'updateInterval': 24, // user-style automatic update interval, hours (0 = disable)
'updateInterval': 24,
}; };
const values = deepCopy(defaults); const values = deepCopy(defaults);

View File

@ -72,10 +72,8 @@ function importFromString(jsonString) {
let index = 0; let index = 0;
let lastRenderTime = performance.now(); let lastRenderTime = performance.now();
const renderQueue = []; const renderQueue = [];
// ms const RENDER_NAP_TIME_MAX = 1000; // ms
const RENDER_NAP_TIME_MAX = 1000; const RENDER_QUEUE_MAX = 50; // number of styles
// number of styles
const RENDER_QUEUE_MAX = 50;
const SAVE_OPTIONS = {reason: 'import', notify: false}; const SAVE_OPTIONS = {reason: 'import', notify: false};
return new Promise(proceed); return new Promise(proceed);

View File

@ -1,20 +1,13 @@
'use strict'; 'use strict';
function messageBox({ function messageBox({
// [mandatory] string title, // [mandatory] string
title, contents, // [mandatory] 1) DOM element 2) string
// [mandatory] 1) DOM element 2) string className = '', // string, CSS class name of the message box element
contents, buttons = [], // array of strings used as labels
// string, CSS class name of the message box element onshow, // function(messageboxElement) invoked after the messagebox is shown
className = '', blockScroll, // boolean, blocks the page scroll
// array of strings used as labels }) { // RETURNS: Promise resolved to {button[number], enter[boolean], esc[boolean]}
buttons = [],
// function(messageboxElement) invoked after the messagebox is shown
onshow,
// boolean, blocks the page scroll
blockScroll,
// RETURNS: Promise resolved to {button[number], enter[boolean], esc[boolean]}
}) {
initOwnListeners(); initOwnListeners();
bindGlobalListeners(); bindGlobalListeners();
createElement(); createElement();