mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 17:49:52 +00:00
switch to eslint-config-standard
This commit is contained in:
@@ -146,8 +146,7 @@ module.exports = class CrittersWebpackPlugin {
|
|||||||
// If all rules were removed, get rid of the style element entirely
|
// If all rules were removed, get rid of the style element entirely
|
||||||
if (sheet.trim().length === 0) {
|
if (sheet.trim().length === 0) {
|
||||||
sheet.parentNode.removeChild(sheet);
|
sheet.parentNode.removeChild(sheet);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// replace the inline stylesheet with its critical'd counterpart
|
// replace the inline stylesheet with its critical'd counterpart
|
||||||
while (style.lastChild) {
|
while (style.lastChild) {
|
||||||
style.removeChild(style.lastChild);
|
style.removeChild(style.lastChild);
|
||||||
@@ -163,7 +162,6 @@ module.exports = class CrittersWebpackPlugin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Recursively walk all rules in a stylesheet.
|
/** Recursively walk all rules in a stylesheet.
|
||||||
* The iterator can explicitly return `false` to remove the current node.
|
* The iterator can explicitly return `false` to remove the current node.
|
||||||
*/
|
*/
|
||||||
@@ -178,12 +176,11 @@ function visit(node, fn) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Enhance an htmlparser2-style DOM with basic manipulation methods. */
|
/** Enhance an htmlparser2-style DOM with basic manipulation methods. */
|
||||||
function makeDomInteractive (document) {
|
function makeDomInteractive (document) {
|
||||||
defineProperties(document, DocumentExtensions);
|
defineProperties(document, DocumentExtensions);
|
||||||
// Find the first <html> element within the document
|
// Find the first <html> element within the document
|
||||||
document.documentElement = document.childNodes.filter( child => String(child.tagName).toLowerCase()==='html' )[0];
|
// document.documentElement = document.childNodes.filter( child => String(child.tagName).toLowerCase()==='html' )[0];
|
||||||
|
|
||||||
// Extend Element.prototype with DOM manipulation methods.
|
// Extend Element.prototype with DOM manipulation methods.
|
||||||
// Note: document.$$scratchElement is also used by createTextNode()
|
// Note: document.$$scratchElement is also used by createTextNode()
|
||||||
@@ -210,19 +207,21 @@ function defineProperties(obj, properties) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {document,Element}.getElementsByTagName() is the only traversal method required by nwmatcher. */
|
/** {document,Element}.getElementsByTagName() is the only traversal method required by nwmatcher.
|
||||||
|
* Note: if perf issues arise, 2 faster but more verbose implementations are benchmarked here:
|
||||||
|
* https://esbench.com/bench/5ac3b647f2949800a0f619e1
|
||||||
|
*/
|
||||||
function getElementsByTagName (tagName) {
|
function getElementsByTagName (tagName) {
|
||||||
// Only return Element/Document nodes
|
// Only return Element/Document nodes
|
||||||
if (this.nodeType!==1 && this.nodeType!==9 || this.type==='directive') return [];
|
if ((this.nodeType !== 1 && this.nodeType !== 9) || this.type === 'directive') return [];
|
||||||
return Array.prototype.concat.apply(
|
return Array.prototype.concat.apply(
|
||||||
// Add current element if it matches tag
|
// Add current element if it matches tag
|
||||||
(tagName === '*' || (this.tagName && (this.tagName == tagName || this.nodeName === tagName.toUpperCase()))) ? [this] : [],
|
(tagName === '*' || (this.tagName && (this.tagName === tagName || this.nodeName === tagName.toUpperCase()))) ? [this] : [],
|
||||||
// Check children recursively
|
// Check children recursively
|
||||||
this.children.map(child => getElementsByTagName.call(child, tagName))
|
this.children.map(child => getElementsByTagName.call(child, tagName))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Methods and descriptors to mix into Element.prototype */
|
/** Methods and descriptors to mix into Element.prototype */
|
||||||
const ElementExtensions = {
|
const ElementExtensions = {
|
||||||
nodeName: {
|
nodeName: {
|
||||||
@@ -279,6 +278,17 @@ const DocumentExtensions = {
|
|||||||
return '#document';
|
return '#document';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
documentElement: {
|
||||||
|
get () {
|
||||||
|
// Find the first <html> element within the document
|
||||||
|
return this.childNodes.filter(child => String(child.tagName).toLowerCase() === 'html')[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
get () {
|
||||||
|
return this.querySelector('body');
|
||||||
|
}
|
||||||
|
},
|
||||||
createElement (name) {
|
createElement (name) {
|
||||||
return treeAdapter.createElement(name, null, []);
|
return treeAdapter.createElement(name, null, []);
|
||||||
},
|
},
|
||||||
|
|||||||
19
package.json
19
package.json
@@ -9,14 +9,19 @@
|
|||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": "eslint-config-developit",
|
"extends": [
|
||||||
|
"standard",
|
||||||
|
"standard-jsx"
|
||||||
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"indent": [
|
"indent": [
|
||||||
2,
|
2,
|
||||||
2
|
2
|
||||||
],
|
],
|
||||||
"object-shorthand": 0,
|
"semi": [
|
||||||
"prefer-arrow-callback": 0,
|
2,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
"prefer-const": 1
|
"prefer-const": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -43,7 +48,13 @@
|
|||||||
"css-loader": "^0.28.11",
|
"css-loader": "^0.28.11",
|
||||||
"ejs-loader": "^0.3.1",
|
"ejs-loader": "^0.3.1",
|
||||||
"eslint": "^4.18.2",
|
"eslint": "^4.18.2",
|
||||||
"eslint-config-developit": "^1.1.1",
|
"eslint-config-standard": "^11.0.0",
|
||||||
|
"eslint-config-standard-jsx": "^5.0.0",
|
||||||
|
"eslint-plugin-import": "^2.10.0",
|
||||||
|
"eslint-plugin-node": "^6.0.1",
|
||||||
|
"eslint-plugin-promise": "^3.7.0",
|
||||||
|
"eslint-plugin-react": "^7.7.0",
|
||||||
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
"extract-text-webpack-plugin": "^4.0.0-beta.0",
|
"extract-text-webpack-plugin": "^4.0.0-beta.0",
|
||||||
"fork-ts-checker-notifier-webpack-plugin": "^0.4.0",
|
"fork-ts-checker-notifier-webpack-plugin": "^0.4.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^0.4.1",
|
"fork-ts-checker-webpack-plugin": "^0.4.1",
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ const classNameDescriptor = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let old = options.vnode;
|
const old = options.vnode;
|
||||||
options.vnode = vnode => {
|
options.vnode = vnode => {
|
||||||
let a = vnode.attributes;
|
const a = vnode.attributes;
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
if ('className' in a) {
|
if ('className' in a) {
|
||||||
a.class = a.className;
|
a.class = a.className;
|
||||||
|
|||||||
Reference in New Issue
Block a user