switch to eslint-config-standard

This commit is contained in:
Jason Miller
2018-04-05 11:44:32 -04:00
parent 3f55698439
commit 387f4cf9a3
3 changed files with 70 additions and 49 deletions

View File

@@ -146,8 +146,7 @@ module.exports = class CrittersWebpackPlugin {
// If all rules were removed, get rid of the style element entirely
if (sheet.trim().length === 0) {
sheet.parentNode.removeChild(sheet);
}
else {
} else {
// replace the inline stylesheet with its critical'd counterpart
while (style.lastChild) {
style.removeChild(style.lastChild);
@@ -163,7 +162,6 @@ module.exports = class CrittersWebpackPlugin {
}
};
/** Recursively walk all rules in a stylesheet.
* 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. */
function makeDomInteractive (document) {
defineProperties(document, DocumentExtensions);
// 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.
// 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) {
// 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(
// 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
this.children.map(child => getElementsByTagName.call(child, tagName))
);
}
/** Methods and descriptors to mix into Element.prototype */
const ElementExtensions = {
nodeName: {
@@ -279,6 +278,17 @@ const DocumentExtensions = {
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) {
return treeAdapter.createElement(name, null, []);
},

View File

@@ -9,14 +9,19 @@
"lint": "eslint src"
},
"eslintConfig": {
"extends": "eslint-config-developit",
"extends": [
"standard",
"standard-jsx"
],
"rules": {
"indent": [
2,
2
],
"object-shorthand": 0,
"prefer-arrow-callback": 0,
"semi": [
2,
"always"
],
"prefer-const": 1
}
},
@@ -43,7 +48,13 @@
"css-loader": "^0.28.11",
"ejs-loader": "^0.3.1",
"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",
"fork-ts-checker-notifier-webpack-plugin": "^0.4.0",
"fork-ts-checker-webpack-plugin": "^0.4.1",

View File

@@ -11,9 +11,9 @@ const classNameDescriptor = {
}
};
let old = options.vnode;
const old = options.vnode;
options.vnode = vnode => {
let a = vnode.attributes;
const a = vnode.attributes;
if (a != null) {
if ('className' in a) {
a.class = a.className;