Skip to content

Commit

Permalink
[lit-next] Unify Prettier dependency to the root (lit#1292)
Browse files Browse the repository at this point in the history
Unify Prettier dependency to the root.
Also format all files in all packages
  • Loading branch information
abdonrd authored Oct 1, 2020
1 parent b9b9d46 commit b9a5049
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 201 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"format": "lerna run format",
"lint": "lerna run lint",
"test": "cd packages/tests && npm test",
"benchmarks": "cd packages/benchmarks && npm run benchmarks"
Expand All @@ -16,6 +17,7 @@
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"eslint": "^7.10.0",
"prettier": "^2.1.2",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-summary": "^1.2.3",
Expand Down
6 changes: 0 additions & 6 deletions packages/benchmarks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"format": "prettier lit-html/* lit-element/* --write",
"format": "prettier \"**/*{cjs,html,js,json,md,ts}\" --write",
"lint": "eslint \"**/*.{js,ts}\" --ignore-path .gitignore",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"benchmarks": "tach --config lit-html/kitchen-sink/tachometer.json && tach --config lit-element/stub1/tachometer.json",
Expand All @@ -25,7 +25,6 @@
"tachometer": "^0.5.3"
},
"devDependencies": {
"prettier": "^2.1.1",
"typescript": "^4.0.2"
}
}
5 changes: 1 addition & 4 deletions packages/benchmarks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true
},
"include": [
"lit-element/**/*.ts",
"lit-html/**/*.ts"
],
"include": ["lit-element/**/*.ts", "lit-html/**/*.ts"],
"exclude": []
}
4 changes: 0 additions & 4 deletions packages/lit-element/.prettierrc.json

This file was deleted.

237 changes: 134 additions & 103 deletions packages/lit-element/demo/lit-element.html
Original file line number Diff line number Diff line change
@@ -1,124 +1,155 @@
<!DOCTYPE html><!--
<!DOCTYPE html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
--><html><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>lit-element demo</title>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<script type="module" src = "./ts-element.js"></script>
</head>
<body>
-->
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"
/>
<title>lit-element demo</title>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<script type="module" src="./ts-element.js"></script>
</head>
<body>
<my-element bar="5" whales="5" foobar="17">Hi</my-element>
<hr>
<hr />
<ts-element message="Yo" more-info="person"></ts-element>

<script type="module">
import { LitElement, html, css } from '../lib/lit-element.js';

class Inner extends LitElement {

static get styles() {
return [css`:host { color: green; }`];
}
render() {
return html`Hello world`;
}
}

customElements.define('x-inner', Inner);

class MyElement extends LitElement {

static get properties() {
return {
nug: {},
foo: {},
bar: {},
whales: {type: Number},
fooBar: {converter: {fromAttribute: parseInt, toAttribute: (value) => value + '-attr'}, reflect: true}
<script type="module">
import {LitElement, html, css} from '../lib/lit-element.js';

class Inner extends LitElement {
static get styles() {
return [
css`
:host {
color: green;
}
`,
];
}
render() {
return html`Hello world`;
}
}

constructor() {
super();
this.foo = 'foo';
this.nug = [1, 2, 3];
this.whales = 0;
this.addEventListener('click', async (e) => {
this.whales++;
await this.updateComplete;
this.dispatchEvent(new CustomEvent('whales', {detail: {whales: this.whales}}))
console.log(this.shadowRoot.querySelector('.count').textContent);
});
}

static get styles() {
return [css`h4 { color: orange;} `];
}
customElements.define('x-inner', Inner);

class MyElement extends LitElement {
static get properties() {
return {
nug: {},
foo: {},
bar: {},
whales: {type: Number},
fooBar: {
converter: {
fromAttribute: parseInt,
toAttribute: (value) => value + '-attr',
},
reflect: true,
},
};
}

render() {
const {foo, bar, whales, fooBar, nug} = this;
return html`
<style>
:host {
display: block;
}
constructor() {
super();
this.foo = 'foo';
this.nug = [1, 2, 3];
this.whales = 0;
this.addEventListener('click', async (e) => {
this.whales++;
await this.updateComplete;
this.dispatchEvent(
new CustomEvent('whales', {detail: {whales: this.whales}})
);
console.log(this.shadowRoot.querySelector('.count').textContent);
});
}

:host([hidden]) {
display: none;
}
static get styles() {
return [
css`
h4 {
color: orange;
}
`,
];
}

.count {
color: green;
}
render() {
const {foo, bar, whales, fooBar, nug} = this;
return html`
<style>
:host {
display: block;
}
:host([hidden]) {
display: none;
}
.count {
color: green;
}
.content {
border: 1px solid black;
padding: 8px;
}
</style>
<h4 on-click="${(e) => console.log(this, e.target)}">
Foo: ${foo}, Bar: ${bar}
</h4>
<div class="content">
<slot></slot>
</div>
<div class="count">whales: ${'🐳'.repeat(whales)}</div>
<ul>
${nug.map((n) => html`<li>${n}</li>`)}
</ul>
<x-inner></x-inner>
`;
}

.content {
border: 1px solid black;
padding: 8px;
}
</style>
<h4 on-click="${(e) => console.log(this, e.target)}">Foo: ${foo}, Bar: ${bar}</h4>
<div class="content">
<slot></slot>
</div>
<div class="count">
whales: ${'🐳'.repeat(whales)}
</div>
<ul>
${nug.map(n => html`<li>${n}</li>`)}
</ul>
<x-inner></x-inner>
`;
}
update(changedProps) {
super.update(changedProps);
console.log('updated!', changedProps);
}

update(changedProps) {
super.update(changedProps);
console.log('updated!', changedProps);
}
firstUpdated() {
this._inner = this.shadowRoot.querySelector('x-inner');
}

firstUpdated() {
this._inner = this.shadowRoot.querySelector('x-inner');
get updateComplete() {
return (async () => {
return (
(await super.updateComplete) && (await this._inner.updateComplete)
);
})();
}
}

get updateComplete() {
return (async () => {
return await super.updateComplete && await this._inner.updateComplete;
})();
};
}

customElements.define('my-element', MyElement);

(async () => {
const x = document.querySelector('my-element');
await x.updateComplete;
console.log('updateComplete!', x.shadowRoot.querySelector('x-inner').shadowRoot.textContent, x.whales);
})();
</script>
</body></html>
customElements.define('my-element', MyElement);

(async () => {
const x = document.querySelector('my-element');
await x.updateComplete;
console.log(
'updateComplete!',
x.shadowRoot.querySelector('x-inner').shadowRoot.textContent,
x.whales
);
})();
</script>
</body>
</html>
6 changes: 0 additions & 6 deletions packages/lit-element/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/lit-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"test:prod": "MODE=prod npm run test:dev",
"test:watch": "npm run test:dev -- --watch",
"checksize": "rollup -c --environment=CHECKSIZE",
"format": "prettier src/* --write",
"format": "prettier \"**/*{cjs,html,js,json,md,ts}\" --write",
"lint": "eslint \"**/*.{js,ts}\" --ignore-path .gitignore",
"check-version": "node scripts/check-version-tracker.js",
"prepublishOnly": "npm run check-version && npm run lint && npm test",
Expand All @@ -68,7 +68,6 @@
"chokidar-cli": "^2.1.0",
"downlevel-dts": "^0.6.0",
"mocha": "^8.1.1",
"prettier": "^2.0.5",
"rollup": "^2.26.4",
"typescript": "^4.0.2"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/lit-element/scripts/check-version-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const {version} = JSON.parse(packageFile);
const ts = fs.readFileSync(path.resolve('src/lit-element.ts'));

if (!ts.includes(`'${version}'`)) {
console.log(`\nExpected lit-element.ts to contain current version "${version}"`);
console.log(
`\nExpected lit-element.ts to contain current version "${version}"`
);
console.log(
`Don't forget to update the version tracker string before release!`
);
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-element/src/lib/css-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const supportsAdoptingStyleSheets =

export type CSSResultOrNative = CSSResult | CSSStyleSheet;

export type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>
export type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;

export type CSSResultGroup = CSSResultOrNative | CSSResultArray;

Expand Down
2 changes: 1 addition & 1 deletion packages/lit-element/src/lit-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ declare global {

type CSSResultFlatArray = CSSResultOrNative[];

export type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>
export type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;

/**
* Sentinal value used to avoid calling lit-html's render function when
Expand Down
Loading

0 comments on commit b9a5049

Please sign in to comment.