diff --git a/docs/faq/README.md b/docs/faq/README.md
index e4a6448c..abe3ba35 100644
--- a/docs/faq/README.md
+++ b/docs/faq/README.md
@@ -200,9 +200,7 @@ class MyComponent extends LitElement {
// ...
}
render() {
- return html`
-
- `;
+ return html` `;
}
}
```
@@ -215,11 +213,7 @@ import { expect, fixture, html } from '@open-wc/testing';
describe('my component', () => {
it('calls myFunction when a button is clicked', () => {
- const el = fixture(
- html`
-
Demo component
- `; + return html`Demo component
`; } } diff --git a/packages/building-rollup/demo/js/lazy-component.js b/packages/building-rollup/demo/js/lazy-component.js index 4512aff0..25eff371 100644 --- a/packages/building-rollup/demo/js/lazy-component.js +++ b/packages/building-rollup/demo/js/lazy-component.js @@ -10,9 +10,7 @@ class LazyComponent extends LitElement { } render() { - return html` -Lazy component
- `; + return html`Lazy component
`; } } diff --git a/packages/building-utils/dom5-fork/index.js b/packages/building-utils/dom5-fork/index.js index 06de6f0e..956f43e7 100644 --- a/packages/building-utils/dom5-fork/index.js +++ b/packages/building-utils/dom5-fork/index.js @@ -37,7 +37,7 @@ function hasAttribute(element, name) { } module.exports.hasAttribute = hasAttribute; function hasSpaceSeparatedAttrValue(name, value) { - return function(element) { + return function (element) { var attributeValue = getAttribute(element, name); if (typeof attributeValue !== 'string') { return false; @@ -75,7 +75,7 @@ function removeAttribute(element, name) { module.exports.removeAttribute = removeAttribute; function hasTagName(name) { var n = name.toLowerCase(); - return function(node) { + return function (node) { if (!node.tagName) { return false; } @@ -88,7 +88,7 @@ function hasTagName(name) { * This will use the lowercased tagName for comparison. */ function hasMatchingTagName(regex) { - return function(node) { + return function (node) { if (!node.tagName) { return false; } @@ -189,7 +189,7 @@ module.exports.setTextContent = setTextContent; * the textnode is the only child in that parent. */ function hasTextValue(value) { - return function(node) { + return function (node) { return getTextContent(node) === value; }; } @@ -198,7 +198,7 @@ function OR() { for (var i = 0; i < arguments.length; i++) { rules[i] = arguments[i]; } - return function(node) { + return function (node) { for (var i = 0; i < rules.length; i++) { if (rules[i](node)) { return true; @@ -212,7 +212,7 @@ function AND() { for (var i = 0; i < arguments.length; i++) { rules[i] = arguments[i]; } - return function(node) { + return function (node) { for (var i = 0; i < rules.length; i++) { if (!rules[i](node)) { return false; @@ -225,7 +225,7 @@ function AND() { * negate an individual predicate, or a group with AND or OR */ function NOT(predicateFn) { - return function(node) { + return function (node) { return !predicateFn(node); }; } @@ -234,7 +234,7 @@ function NOT(predicateFn) { * `predicateFn`. */ function parentMatches(predicateFn) { - return function(node) { + return function (node) { var parent = node.parentNode; while (parent !== undefined) { if (predicateFn(parent)) { @@ -246,12 +246,12 @@ function parentMatches(predicateFn) { }; } function hasAttr(attr) { - return function(node) { + return function (node) { return getAttributeIndex(node, attr) > -1; }; } function hasAttrValue(attr, value) { - return function(node) { + return function (node) { return getAttribute(node, attr) === value; }; } @@ -281,17 +281,17 @@ module.exports.isCommentNode = isCommentNode; */ function treeMap(node, mapfn) { var results = []; - nodeWalk(node, function(node) { + nodeWalk(node, function (node) { results = results.concat(mapfn(node)); return false; }); return results; } module.exports.treeMap = treeMap; -module.exports.defaultChildNodes = function(node) { +module.exports.defaultChildNodes = function (node) { return node.childNodes; }; -module.exports.childNodesIncludeTemplate = function(node) { +module.exports.childNodesIncludeTemplate = function (node) { if (node.nodeName === 'template') { return parse5_1.treeAdapters['default'].getTemplateContent(node).childNodes; } @@ -537,7 +537,7 @@ function insertNode(parent, index, newNode, replace) { removedNode = parent.childNodes[index]; } Array.prototype.splice.apply(parent.childNodes, [index, replace ? 1 : 0].concat(newNodes)); - newNodes.forEach(function(n) { + newNodes.forEach(function (n) { n.parentNode = parent; }); if (removedNode) { @@ -597,12 +597,12 @@ module.exports.removeNodeSaveChildren = removeNodeSaveChildren; function removeFakeRootElements(ast) { var injectedNodes = queryAll( ast, - AND(function(node) { + AND(function (node) { return !node.__location; }, hasMatchingTagName(/^(html|head|body)$/i)), undefined, // Don't descend past 3 levels 'document > html > head|body' - function(node) { + function (node) { return node.parentNode && node.parentNode.parentNode ? undefined : node.childNodes; }, ); diff --git a/packages/building-utils/index-html/dynamic-import-polyfill.js b/packages/building-utils/index-html/dynamic-import-polyfill.js index 5ff9fa70..e1de2f1c 100644 --- a/packages/building-utils/index-html/dynamic-import-polyfill.js +++ b/packages/building-utils/index-html/dynamic-import-polyfill.js @@ -9,7 +9,7 @@ * - We need it to be a plain script which registers to the window */ -(function() { +(function () { function toAbsoluteURL(url) { const a = document.createElement('a'); a.setAttribute('href', url); // @@ -18,11 +18,7 @@ function importShim(url) { return new Promise((resolve, reject) => { - const vector = - '$importModule$' + - Math.random() - .toString(32) - .slice(2); + const vector = '$importModule$' + Math.random().toString(32).slice(2); const script = document.createElement('script'); const destructor = () => { delete window[vector]; diff --git a/packages/building-utils/index-html/utils.js b/packages/building-utils/index-html/utils.js index 42f08726..fe8d9103 100644 --- a/packages/building-utils/index-html/utils.js +++ b/packages/building-utils/index-html/utils.js @@ -1,10 +1,7 @@ const crypto = require('crypto'); function createContentHash(content) { - return crypto - .createHash('md4') - .update(content) - .digest('hex'); + return crypto.createHash('md4').update(content).digest('hex'); } function cleanImportPath(path) { diff --git a/packages/building-webpack/demo/js/demo-component.js b/packages/building-webpack/demo/js/demo-component.js index 31306d5d..97bfdc6a 100644 --- a/packages/building-webpack/demo/js/demo-component.js +++ b/packages/building-webpack/demo/js/demo-component.js @@ -11,9 +11,7 @@ class DemoComponent extends LitElement { } render() { - return html` -Demo component
- `; + return html`Demo component
`; } } diff --git a/packages/building-webpack/demo/js/lazy-component.js b/packages/building-webpack/demo/js/lazy-component.js index 4512aff0..25eff371 100644 --- a/packages/building-webpack/demo/js/lazy-component.js +++ b/packages/building-webpack/demo/js/lazy-component.js @@ -10,9 +10,7 @@ class LazyComponent extends LitElement { } render() { - return html` -Lazy component
- `; + return html`Lazy component
`; } } diff --git a/packages/chai-a11y-axe/README.md b/packages/chai-a11y-axe/README.md index 7b313c4a..29eafdba 100644 --- a/packages/chai-a11y-axe/README.md +++ b/packages/chai-a11y-axe/README.md @@ -16,40 +16,24 @@ Rules can be ignored by passing `ignoredRules` with a list of ignored rules as a import { fixture, expect, html } from '@open-wc/testing'; it('passes accessibility test', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await expect(el).to.be.accessible(); }); it('fails without label', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await expect(el).not.to.be.accessible(); }); it('passes for all rules, ignores attributes test', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await expect(el).to.be.accessible({ ignoredRules: ['aria-valid-attr-value'], }); }); it('accepts "done" option', done => { - fixture( - html` - - `, - ).then(el => { + fixture(html` `).then(el => { expect(el).to.be.accessible({ done, }); @@ -65,31 +49,19 @@ The `isAccessible()` and `isNotAccessible()` methods work on Chai's `assert` fun import { fixture, assert, html } from '@open-wc/testing'; it('passes axe accessible tests', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await assert.isAccessible(el); }); it('accepts ignored rules list', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await assert.isAccessible(el, { ignoredRules: ['aria-valid-attr-value'], }); }); it('passes for negation', async () => { - const el = await fixture( - html` - - `, - ); + const el = await fixture(html` `); await assert.isNotAccessible(el); }); ``` diff --git a/packages/codelabs/src/basics/lit-html.md b/packages/codelabs/src/basics/lit-html.md index feafa56e..20a4c6f5 100644 --- a/packages/codelabs/src/basics/lit-html.md +++ b/packages/codelabs/src/basics/lit-html.md @@ -144,9 +144,7 @@ In order to create an actual lit-html template, we need to prefix the template l ```js import { html } from 'https://unpkg.com/lit-element?module'; -const template = html` -${JSON.stringify(this.breweries, null, 2)}
- `;
+ return html` ${JSON.stringify(this.breweries, null, 2)} `;
}
}
@@ -331,14 +327,10 @@ render() {
render() {
if (this.loading) {
- return html`
- Loading...
- `; + return html`Loading...
`; } - return html` -${JSON.stringify(this.breweries, null, 2)}
- `;
+ return html` ${JSON.stringify(this.breweries, null, 2)} `;
}
}
@@ -453,9 +445,7 @@ render() {
render() {
if (this.loading) {
- return html`
- Loading...
- `; + return html`Loading...
`; } return html` @@ -547,9 +537,7 @@ function visitedStatus(visited) { class MyBrewery extends LitElement { render() { - return html` - Bendërbrāu ${visitedStatus(this.visited)} - `; + return html` Bendërbrāu ${visitedStatus(this.visited)} `; } } ``` @@ -616,9 +604,7 @@ In this example, we register an event listener for the `click` event, and call t render() { if (this.loading) { - return html` -Loading...
- `; + return html`Loading...
`; } return html` @@ -798,9 +784,7 @@ render() { render() { if (this.loading) { - return html` -Loading...
- `; + return html`Loading...
`; } const totalVisited = this.breweries.filter(b => b.visited).length; @@ -941,9 +925,7 @@ Then, on the top of your `render` function, you can filter the array of brewerie render() { if (this.loading) { - return html` -Loading...
- `; + return html`Loading...
`; } const totalVisited = this.breweries.filter(b => b.visited).length; @@ -1127,9 +1109,7 @@ html` render() { if (this.loading) { - return html` -Loading...
- `; + return html`Loading...
`; } const totalVisited = this.breweries.filter(b => b.visited).length; @@ -1236,9 +1216,7 @@ Since lit-html templates are actual javascript variables, we could write our tem ```js function BeerTemplate(beer) { - return html` -Loading...
- `; + return html`Loading...
`; } const totalVisited = this.breweries.filter(b => b.visited).length; diff --git a/packages/create/owc-app/README.md b/packages/create/owc-app/README.md index b9b2a72d..2050deb9 100644 --- a/packages/create/owc-app/README.md +++ b/packages/create/owc-app/README.md @@ -27,4 +27,4 @@ npm init @open-wc For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project. -If you customize the configuration a lot, you can consider moving them to individual files. \ No newline at end of file +If you customize the configuration a lot, you can consider moving them to individual files. diff --git a/packages/create/owc-app/package.json b/packages/create/owc-app/package.json index 6a7ad15b..880a77ff 100644 --- a/packages/create/owc-app/package.json +++ b/packages/create/owc-app/package.json @@ -1,20 +1,29 @@ { + "name": "owc-app", + "version": "0.0.0", + "description": "Webcomponent owc-app following open-wc recommendations", + "license": "MIT", + "author": "owc-app", "scripts": { - "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore", + "format": "npm run format:eslint && npm run format:prettier", "format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore", - "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore", "format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore", "lint": "npm run lint:eslint && npm run lint:prettier", - "format": "npm run format:eslint && npm run format:prettier", + "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore", + "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore", "start": "es-dev-server --app-index index.html --node-resolve --open --watch" }, + "dependencies": { + "lit-element": "^2.0.1", + "lit-html": "^1.0.0" + }, "devDependencies": { - "eslint": "^6.1.0", "@open-wc/eslint-config": "^2.0.0", - "prettier": "^2.0.4", + "es-dev-server": "^1.5.0", + "eslint": "^6.1.0", "husky": "^1.0.0", "lint-staged": "^8.0.0", - "es-dev-server": "^1.5.0" + "prettier": "^2.0.4" }, "eslintConfig": { "extends": [ @@ -22,10 +31,6 @@ "eslint-config-prettier" ] }, - "prettier": { - "singleQuote": true, - "arrowParens": "avoid" - }, "husky": { "hooks": { "pre-commit": "lint-staged" @@ -38,13 +43,8 @@ "git add" ] }, - "name": "owc-app", - "version": "0.0.0", - "description": "Webcomponent owc-app following open-wc recommendations", - "author": "owc-app", - "license": "MIT", - "dependencies": { - "lit-html": "^1.0.0", - "lit-element": "^2.0.1" + "prettier": { + "singleQuote": true, + "arrowParens": "avoid" } } diff --git a/packages/create/test/integration.test.js b/packages/create/test/integration.test.js index 5fcee9d0..2b495fb8 100644 --- a/packages/create/test/integration.test.js +++ b/packages/create/test/integration.test.js @@ -42,9 +42,7 @@ function stripUserDir(output) { * @param {string} actualPath path to actual output */ function assertFile(expectedPath, actualPath) { - expect(actualPath) - .to.be.a.file() - .and.equal(expectedPath); + expect(actualPath).to.be.a.file().and.equal(expectedPath); } /** @@ -90,9 +88,7 @@ describe('create', function create() { it('scaffolds a fully loaded app project', async () => { // Check that all files exist, without checking their contents - expect(ACTUAL_PATH) - .to.be.a.directory() - .and.deep.equal(expectedPath); + expect(ACTUAL_PATH).to.be.a.directory().and.deep.equal(expectedPath); }); it('generates expected file contents', () => { diff --git a/packages/dedupe-mixin/package.json b/packages/dedupe-mixin/package.json index 79d1032f..cf0a9504 100644 --- a/packages/dedupe-mixin/package.json +++ b/packages/dedupe-mixin/package.json @@ -13,6 +13,7 @@ }, "author": "open-wc", "homepage": "https://github.com/open-wc/open-wc/tree/master/packages/dedupe-mixin", + "module": "index.js", "scripts": { "demo-build:no-dedupe": "rollup -c demo-typed/no-dedupe/rollup.config.js", "demo-build:with-dedupe": "rollup -c demo-typed/with-dedupe/rollup.config.js", @@ -33,6 +34,5 @@ "devDependencies": { "http-server": "^0.11.1" }, - "module": "index.js", "sideEffects": false } diff --git a/packages/demoing-storybook/MIGRATION.md b/packages/demoing-storybook/MIGRATION.md index 52a586a0..8956499e 100644 --- a/packages/demoing-storybook/MIGRATION.md +++ b/packages/demoing-storybook/MIGRATION.md @@ -162,9 +162,7 @@ export default { parameters: { options: { selectedPanel: 'storybookjs/knobs/panel' } }, }; -export const singleComponent = () => html` -const foo = 1;\n\n',
diff --git a/packages/mdjs/test/mdjsStoryParse.test.js b/packages/mdjs/test/mdjsStoryParse.test.js
index a71cdd52..50df3485 100644
--- a/packages/mdjs/test/mdjsStoryParse.test.js
+++ b/packages/mdjs/test/mdjsStoryParse.test.js
@@ -33,10 +33,7 @@ describe('mdjsStoryParse', () => {
'',
].join('\n');
- const parser = unified()
- .use(markdown)
- .use(mdjsStoryParse)
- .use(html);
+ const parser = unified().use(markdown).use(mdjsStoryParse).use(html);
const result = await parser.process(input);
expect(result.contents).to.equal(expected);
// @ts-ignore
diff --git a/packages/polyfills-loader/src/utils.js b/packages/polyfills-loader/src/utils.js
index 4158e25a..b5581340 100644
--- a/packages/polyfills-loader/src/utils.js
+++ b/packages/polyfills-loader/src/utils.js
@@ -21,10 +21,7 @@ const fileTypes = {
* @returns {string}
*/
function createContentHash(content) {
- return crypto
- .createHash('md4')
- .update(content)
- .digest('hex');
+ return crypto.createHash('md4').update(content).digest('hex');
}
/**
diff --git a/packages/rollup-plugin-index-html/README.md b/packages/rollup-plugin-index-html/README.md
index c44de796..89d63b62 100644
--- a/packages/rollup-plugin-index-html/README.md
+++ b/packages/rollup-plugin-index-html/README.md
@@ -28,7 +28,7 @@ Rollup plugin to make rollup understand your index.html.