Fix no-inline-comments issues
This commit is contained in:
parent
a3b8b7d168
commit
d563495c26
|
@ -10,14 +10,21 @@ 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 = {
|
||||||
list: null, // array of all styles
|
// array of all styles
|
||||||
byId: new Map(), // all styles indexed by id
|
list: null,
|
||||||
filters: new Map(), // filterStyles() parameters mapped to the returned results, 10k max
|
// all styles indexed by id
|
||||||
regexps: new Map(), // compiled style regexps
|
byId: new Map(),
|
||||||
urlDomains: new Map(), // getDomain() results for 100 last checked urls
|
// filterStyles() parameters mapped to the returned results, 10k max
|
||||||
|
filters: new Map(),
|
||||||
|
// compiled style regexps
|
||||||
|
regexps: new Map(),
|
||||||
|
// getDomain() results for 100 last checked urls
|
||||||
|
urlDomains: new Map(),
|
||||||
mutex: {
|
mutex: {
|
||||||
inProgress: false, // while getStyles() is reading IndexedDB all subsequent calls
|
// while getStyles() is reading IndexedDB all subsequent calls
|
||||||
onDone: [], // to getStyles() are queued and resolved when the first one finishes
|
inProgress: false,
|
||||||
|
// to getStyles() are queued and resolved when the first one finishes
|
||||||
|
onDone: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,8 +255,10 @@ function saveStyle(style) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (reason === 'import') {
|
if (reason === 'import') {
|
||||||
style.originalDigest = style.originalDigest || style.styleDigest; // TODO: remove in the future
|
// TODO: remove in the future
|
||||||
delete style.styleDigest; // TODO: remove in the future
|
style.originalDigest = style.originalDigest || style.styleDigest;
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -524,7 +533,8 @@ 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;
|
||||||
const hitWeight = 1 / 4; // we make ~4 hits per URL
|
// 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()]
|
||||||
|
|
|
@ -100,7 +100,8 @@ var updater = {
|
||||||
}
|
}
|
||||||
return !save ? json :
|
return !save ? json :
|
||||||
saveStyle(Object.assign(json, {
|
saveStyle(Object.assign(json, {
|
||||||
name: null, // keep local name customizations
|
// keep local name customizations
|
||||||
|
name: null,
|
||||||
reason: 'update',
|
reason: 'update',
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,8 @@ function initDocRewriteObserver() {
|
||||||
}
|
}
|
||||||
ROOT = document.documentElement;
|
ROOT = document.documentElement;
|
||||||
for (const el of styleElements.values()) {
|
for (const el of styleElements.values()) {
|
||||||
el.textContent += ' '; // invalidate CSSOM cache
|
// invalidate CSSOM cache
|
||||||
|
el.textContent += ' ';
|
||||||
addStyleElement(document.importNode(el, true));
|
addStyleElement(document.importNode(el, true));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -350,7 +351,8 @@ 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',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const CHROMIUM = /Chromium/.test(navigator.userAgent); // non-Windows Chromium
|
// 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);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
window.stylelintDefaultConfig = (defaultSeverity => ({
|
window.stylelintDefaultConfig = (defaultSeverity => ({
|
||||||
// 'sugarss' is a indent-based syntax like Sass or Stylus
|
// 'sugarss' is a indent-based syntax like Sass or Stylus
|
||||||
// ref: https://github.com/postcss/postcss#syntaxes
|
// ref: https://github.com/postcss/postcss#syntaxes
|
||||||
|
@ -20,7 +22,8 @@ window.stylelintDefaultConfig = (defaultSeverity => ({
|
||||||
'function-linear-gradient-no-nonstandard-direction': [true, defaultSeverity],
|
'function-linear-gradient-no-nonstandard-direction': [true, defaultSeverity],
|
||||||
'keyframe-declaration-no-important': [true, defaultSeverity],
|
'keyframe-declaration-no-important': [true, defaultSeverity],
|
||||||
'media-feature-name-no-unknown': [true, defaultSeverity],
|
'media-feature-name-no-unknown': [true, defaultSeverity],
|
||||||
'no-empty-source': false, /* recommended true */
|
/* recommended true */
|
||||||
|
'no-empty-source': false,
|
||||||
'no-extra-semicolons': [true, defaultSeverity],
|
'no-extra-semicolons': [true, defaultSeverity],
|
||||||
'no-invalid-double-slash-comments': [true, defaultSeverity],
|
'no-invalid-double-slash-comments': [true, defaultSeverity],
|
||||||
'property-no-unknown': [true, defaultSeverity],
|
'property-no-unknown': [true, defaultSeverity],
|
||||||
|
|
100
js/prefs.js
100
js/prefs.js
|
@ -4,34 +4,56 @@
|
||||||
// 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 = {
|
||||||
'openEditInWindow': false, // new editor opens in a own browser window
|
// new editor opens in a own browser window
|
||||||
'windowPosition': {}, // detached window position
|
'openEditInWindow': false,
|
||||||
'show-badge': true, // display text on popup menu icon
|
// detached window position
|
||||||
'disableAll': false, // boss key
|
'windowPosition': {},
|
||||||
'exposeIframes': false, // Add 'stylus-iframe' attribute to HTML element in all iframes
|
// display text on popup menu icon
|
||||||
|
'show-badge': true,
|
||||||
|
// boss key
|
||||||
|
'disableAll': false,
|
||||||
|
// Add 'stylus-iframe' attribute to HTML element in all iframes
|
||||||
|
'exposeIframes': false,
|
||||||
|
|
||||||
'popup.breadcrumbs': true, // display 'New style' links as URL breadcrumbs
|
// display 'New style' links as URL breadcrumbs
|
||||||
'popup.breadcrumbs.usePath': false, // use URL path for 'this URL'
|
'popup.breadcrumbs': true,
|
||||||
'popup.enabledFirst': true, // display enabled styles before disabled styles
|
// use URL path for 'this URL'
|
||||||
'popup.stylesFirst': true, // display enabled styles before disabled styles
|
'popup.breadcrumbs.usePath': false,
|
||||||
|
// display enabled styles before disabled styles
|
||||||
|
'popup.enabledFirst': true,
|
||||||
|
// display enabled styles before disabled styles
|
||||||
|
'popup.stylesFirst': true,
|
||||||
|
|
||||||
'manage.onlyEnabled': false, // display only enabled styles
|
// display only enabled styles
|
||||||
'manage.onlyLocal': false, // display only styles created locally
|
'manage.onlyEnabled': false,
|
||||||
|
// 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
|
||||||
'manage.newUI': true, // use the new compact layout
|
// use the new compact layout
|
||||||
'manage.newUI.favicons': false, // show favicons for the sites in applies-to
|
'manage.newUI': true,
|
||||||
'manage.newUI.faviconsGray': true, // gray out favicons
|
// show favicons for the sites in applies-to
|
||||||
'manage.newUI.targets': 3, // max number of applies-to targets visible: 0 = none
|
'manage.newUI.favicons': false,
|
||||||
|
// gray out favicons
|
||||||
|
'manage.newUI.faviconsGray': true,
|
||||||
|
// max number of applies-to targets visible: 0 = none
|
||||||
|
'manage.newUI.targets': 3,
|
||||||
|
|
||||||
'editor.options': {}, // CodeMirror.defaults.*
|
// CodeMirror.defaults.*
|
||||||
'editor.lineWrapping': true, // word wrap
|
'editor.options': {},
|
||||||
'editor.smartIndent': true, // 'smart' indent
|
// word wrap
|
||||||
'editor.indentWithTabs': false, // smart indent with tabs
|
'editor.lineWrapping': true,
|
||||||
'editor.tabSize': 4, // tab width, in spaces
|
// 'smart' indent
|
||||||
|
'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',
|
||||||
'editor.theme': 'default', // CSS theme
|
// CSS theme
|
||||||
'editor.beautify': { // CSS beautifier
|
'editor.theme': 'default',
|
||||||
|
// 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,
|
||||||
|
@ -41,24 +63,34 @@ var prefs = new function Prefs() {
|
||||||
end_with_newline: false,
|
end_with_newline: false,
|
||||||
indent_conditional: true,
|
indent_conditional: true,
|
||||||
},
|
},
|
||||||
'editor.lintDelay': 500, // lint gutter marker update delay, ms
|
// lint gutter marker update delay, ms
|
||||||
'editor.linter': 'csslint', // Choose csslint or stylelint
|
'editor.lintDelay': 500,
|
||||||
'editor.lintReportDelay': 4500, // lint report update delay, ms
|
// Options: 'csslint', 'stylelint' or 'null'
|
||||||
'editor.matchHighlight': 'token', // token = token/word under cursor even if nothing is selected
|
'editor.linter': 'csslint',
|
||||||
|
// 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.autocompleteOnTyping': false, // show autocomplete dropdown on typing a word token
|
'editor.matchHighlight': 'token',
|
||||||
'editor.contextDelete': contextDeleteMissing(), // "Delete" item in context menu
|
// show autocomplete dropdown on typing a word token
|
||||||
|
'editor.autocompleteOnTyping': false,
|
||||||
|
// "Delete" item in context menu
|
||||||
|
'editor.contextDelete': contextDeleteMissing(),
|
||||||
|
|
||||||
'iconset': 0, // 0 = dark-themed icon
|
// 0 = dark-themed icon; 1 = light-themed icon
|
||||||
// 1 = light-themed icon
|
'iconset': 0,
|
||||||
|
|
||||||
'badgeDisabled': '#8B0000', // badge background color when disabled
|
// badge background color when disabled
|
||||||
'badgeNormal': '#006666', // badge background color
|
'badgeDisabled': '#8B0000',
|
||||||
|
// badge background color
|
||||||
|
'badgeNormal': '#006666',
|
||||||
|
|
||||||
'popupWidth': 246, // popup width in pixels
|
// popup width in pixels
|
||||||
|
'popupWidth': 246,
|
||||||
|
|
||||||
'updateInterval': 24, // user-style automatic update interval, hours (0 = disable)
|
// user-style automatic update interval, hours (0 = disable)
|
||||||
|
'updateInterval': 24,
|
||||||
};
|
};
|
||||||
const values = deepCopy(defaults);
|
const values = deepCopy(defaults);
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,10 @@ function importFromString(jsonString) {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let lastRenderTime = performance.now();
|
let lastRenderTime = performance.now();
|
||||||
const renderQueue = [];
|
const renderQueue = [];
|
||||||
const RENDER_NAP_TIME_MAX = 1000; // ms
|
// ms
|
||||||
const RENDER_QUEUE_MAX = 50; // number of styles
|
const RENDER_NAP_TIME_MAX = 1000;
|
||||||
|
// 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);
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function messageBox({
|
function messageBox({
|
||||||
title, // [mandatory] string
|
// [mandatory] string
|
||||||
contents, // [mandatory] 1) DOM element 2) string
|
title,
|
||||||
className = '', // string, CSS class name of the message box element
|
// [mandatory] 1) DOM element 2) string
|
||||||
buttons = [], // array of strings used as labels
|
contents,
|
||||||
onshow, // function(messageboxElement) invoked after the messagebox is shown
|
// string, CSS class name of the message box element
|
||||||
blockScroll, // boolean, blocks the page scroll
|
className = '',
|
||||||
}) { // RETURNS: Promise resolved to {button[number], enter[boolean], esc[boolean]}
|
// array of strings used as labels
|
||||||
|
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();
|
||||||
|
|
|
@ -143,7 +143,8 @@ function initPopup(url) {
|
||||||
title: `url-prefix("${url}")`,
|
title: `url-prefix("${url}")`,
|
||||||
textContent: prefs.get('popup.breadcrumbs.usePath')
|
textContent: prefs.get('popup.breadcrumbs.usePath')
|
||||||
? new URL(url).pathname.slice(1)
|
? new URL(url).pathname.slice(1)
|
||||||
: t('writeStyleForURL').replace(/ /g, '\u00a0'), // this URL
|
// this URL
|
||||||
|
: t('writeStyleForURL').replace(/ /g, '\u00a0'),
|
||||||
onclick: handleEvent.openLink,
|
onclick: handleEvent.openLink,
|
||||||
});
|
});
|
||||||
if (prefs.get('popup.breadcrumbs')) {
|
if (prefs.get('popup.breadcrumbs')) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
CodeMirror.registerHelper('lint', 'csslint', text => {
|
CodeMirror.registerHelper('lint', 'csslint', text => {
|
||||||
const found = [];
|
const found = [];
|
||||||
if (window.CSSLint) {
|
if (window.CSSLint) {
|
||||||
/* STYLISH: hack start (part 1) */
|
/* STYLUS: hack start (part 1) */
|
||||||
const rules = CSSLint.getRules();
|
const rules = CSSLint.getRules();
|
||||||
const allowedRules = [
|
const allowedRules = [
|
||||||
'display-property-grouping',
|
'display-property-grouping',
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
CSSLint.addRule(rule);
|
CSSLint.addRule(rule);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* STYLISH: hack end */
|
/* STYLUS: hack end */
|
||||||
|
|
||||||
const results = CSSLint.verify(text);
|
const results = CSSLint.verify(text);
|
||||||
const messages = results.messages;
|
const messages = results.messages;
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
for (let i = 0; i < messages.length; i++) {
|
for (let i = 0; i < messages.length; i++) {
|
||||||
message = messages[i];
|
message = messages[i];
|
||||||
|
|
||||||
/* STYLISH: hack start (part 2) */
|
/* STYLUS: hack start (part 2) */
|
||||||
if (message.type === 'warning') {
|
if (message.type === 'warning') {
|
||||||
// @font-face {font-family: 'Ampersand'; unicode-range: U+26;}
|
// @font-face {font-family: 'Ampersand'; unicode-range: U+26;}
|
||||||
if (message.message.indexOf('unicode-range') !== -1) {
|
if (message.message.indexOf('unicode-range') !== -1) {
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* STYLISH: hack end */
|
/* STYLUS: hack end */
|
||||||
const startLine = message.line - 1;
|
const startLine = message.line - 1;
|
||||||
const endLine = message.line - 1;
|
const endLine = message.line - 1;
|
||||||
const startCol = message.col - 1;
|
const startCol = message.col - 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user