Skip to content

Commit cad8dca

Browse files
committed
Update lit-starter-js to lit-next
* Upgrades the source to work with lit-next * Aligns the linting and formatting rules/settings & ignores with the monorepo * Upgrades to the same version of typescript and tsconfig settings as the monorepo * Upgrades the test runner from karma to web-test-runner * Upgrades the dev server from es-dev-server to @web/dev-server
1 parent 47f1b3e commit cad8dca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5859
-588
lines changed

.eslintignore

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ packages/lit-starter-ts/docs-src/*
9898
packages/lit-starter-ts/**/rollup-config.js
9999
packages/lit-starter-ts/**/custom-elements.json
100100

101+
packages/lit-starter-js/node_modules/
102+
packages/lit-starter-js/**/custom-elements.json
103+
# only generated for size check
104+
packages/lit-starter-js/**/my-element.bundled.js
105+
packages/lit-starter-js/node_modules/*
106+
packages/lit-starter-js/docs/*
107+
packages/lit-starter-js/docs-src/*
108+
packages/lit-starter-js/**/rollup-config.js
109+
packages/lit-starter-js/**/custom-elements.json
110+
101111
packages/localize/lib/
102112
packages/localize/lib_client/
103113
packages/localize/node_modules/

.eslintignore-sync

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ packages/lit-html/.gitignore
1111
packages/lit-ssr/.gitignore
1212
packages/lit-starter-ts/.gitignore
1313
packages/lit-starter-ts/.eslintignore
14+
packages/lit-starter-js/.gitignore
15+
packages/lit-starter-js/.eslintignore
1416
packages/localize/.gitignore
1517
packages/tests/.gitignore
1618
packages/reactive-element/.gitignore

.prettierignore

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ packages/lit-starter-ts/docs-src/*
9898
packages/lit-starter-ts/**/rollup-config.js
9999
packages/lit-starter-ts/**/custom-elements.json
100100

101+
packages/lit-starter-js/node_modules/
102+
packages/lit-starter-js/**/custom-elements.json
103+
# only generated for size check
104+
packages/lit-starter-js/**/my-element.bundled.js
105+
packages/lit-starter-js/node_modules/*
106+
packages/lit-starter-js/docs/*
107+
packages/lit-starter-js/docs-src/*
108+
packages/lit-starter-js/**/rollup-config.js
109+
packages/lit-starter-js/**/custom-elements.json
110+
101111
packages/localize/lib/
102112
packages/localize/lib_client/
103113
packages/localize/node_modules/

.prettierignore-sync

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ packages/lit-html/.gitignore
1111
packages/lit-ssr/.gitignore
1212
packages/lit-starter-ts/.gitignore
1313
packages/lit-starter-ts/.eslintignore
14+
packages/lit-starter-js/.gitignore
15+
packages/lit-starter-js/.eslintignore
1416
packages/localize/.gitignore
1517
packages/tests/.gitignore
1618
packages/reactive-element/.gitignore

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ignore-sync": "ignore-sync .",
1111
"lint": "eslint \"**/*.{js,ts}\"",
1212
"nuke": "rm -rf node_modules packages/*/{node_modules} && npm install && npm run bootstrap",
13-
"test": "(cd packages/tests && npm test) && (cd packages/lit-ssr && npm test) && (cd packages/localize && npm test) && (cd packages/lit-starter-ts && npm test)"
13+
"test": "(cd packages/tests && npm test) && (cd packages/lit-ssr && npm test) && (cd packages/localize && npm test) && (cd packages/lit-starter-ts && npm test) && (cd packages/lit-starter-js && npm test)"
1414
},
1515
"dependencies": {
1616
"lerna": "^3.22.1"

packages/lit-starter-js/.eleventy.cjs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
1+
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
22

3-
module.exports = function(eleventyConfig) {
3+
module.exports = function (eleventyConfig) {
44
eleventyConfig.addPlugin(syntaxHighlight);
5-
eleventyConfig.addPassthroughCopy("docs-src/docs.css");
6-
eleventyConfig.addPassthroughCopy("docs-src/.nojekyll");
5+
eleventyConfig.addPassthroughCopy('docs-src/docs.css');
6+
eleventyConfig.addPassthroughCopy('docs-src/.nojekyll');
7+
eleventyConfig.addPassthroughCopy(
8+
'node_modules/@webcomponents/webcomponentsjs'
9+
);
10+
eleventyConfig.addPassthroughCopy('node_modules/lit/polyfill-support.js');
711
return {
812
dir: {
9-
input: "docs-src",
10-
output: "docs"
13+
input: 'docs-src',
14+
output: 'docs',
1115
},
1216
templateExtensionAliases: {
13-
"11ty.cjs": "11ty.js",
14-
"11tydata.cjs": "11tydata.js"
15-
}
17+
'11ty.cjs': '11ty.js',
18+
'11tydata.cjs': '11tydata.js',
19+
},
1620
};
1721
};

packages/lit-starter-js/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/*
22
docs/*
33
docs-src/*
44
rollup-config.js
5+
custom-elements.json
+16-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
{
2-
"extends": [
3-
"eslint:recommended"
4-
],
5-
"env": {
6-
"browser": true,
7-
"mocha": true
8-
},
2+
"root": true,
3+
"extends": ["eslint:recommended"],
4+
"parser": "babel-eslint",
95
"globals": {
106
"chai": "readonly"
117
},
12-
"parser": "babel-eslint",
138
"parserOptions": {
149
"sourceType": "module"
1510
},
11+
"env": {
12+
"browser": true,
13+
"mocha": true
14+
},
1615
"rules": {
1716
"no-unexpected-multiline": "off"
18-
}
17+
},
18+
"overrides": [
19+
{
20+
"files": ["rollup.config.js", "web-test-runner.config.js"],
21+
"env": {
22+
"node": true
23+
}
24+
}
25+
]
1926
}

packages/lit-starter-js/.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/node_modules/
2-
2+
custom-elements.json
33
# only generated for size check
4-
my-element.bundled.js
4+
my-element.bundled.js
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
24
"singleQuote": true,
3-
"bracketSpacing": false
5+
"bracketSpacing": false,
6+
"arrowParens": "always"
47
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3-
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
44

5-
// List of extensions which should be recommended for users of this workspace.
6-
"recommendations": [
7-
"runem.lit-plugin"
8-
],
9-
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10-
"unwantedRecommendations": [
11-
12-
]
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": ["runem.lit-plugin"],
7+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
8+
"unwantedRecommendations": []
139
}

packages/lit-starter-js/README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LitElement JavaScript starter
1+
# LitElement JavaScript starter
22

33
This project includes a sample component using LitElement with JavaScript.
44

@@ -12,7 +12,11 @@ npm i
1212

1313
## Testing
1414

15-
This sample uses Karma, Chai, Mocha, and the open-wc test helpers for testing. See the [open-wc testing documentation](https://open-wc.org/testing/testing.html) for more information.
15+
This sample modern-web.dev's
16+
[@web/test-runner](https://www.npmjs.com/package/@web/test-runner) along with
17+
Mocha, Chai, and some related helpers for testing. See the
18+
[modern-web.dev testing documentation](https://modern-web.dev/docs/test-runner/overview) for
19+
more information.
1620

1721
Tests can be run with the `test` script:
1822

@@ -22,7 +26,7 @@ npm test
2226

2327
## Dev Server
2428

25-
This sample uses open-wc's [es-dev-server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) for previewing the project without additional build steps. ES dev server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers.
29+
This sample uses modern-web.dev's [@web/dev-server](https://www.npmjs.com/package/@web/dev-server) for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See [modern-web.dev's Web Dev Server documentation](https://modern-web.dev/docs/dev-server/overview/) for more information.
2630

2731
To run the dev server and open the project in a new browser tab:
2832

@@ -35,15 +39,16 @@ There is a development HTML file located at `/dev/index.html` that you can view
3539
## Editing
3640

3741
If you use VS Code, we highly reccomend the [lit-plugin extension](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin), which enables some extremely useful features for lit-html templates:
38-
- Syntax highlighting
39-
- Type-checking
40-
- Code completion
41-
- Hover-over docs
42-
- Jump to definition
43-
- Linting
44-
- Quick Fixes
45-
46-
The project is setup to reccomend lit-plugin to VS Code users if they don't already have it installed.
42+
43+
- Syntax highlighting
44+
- Type-checking
45+
- Code completion
46+
- Hover-over docs
47+
- Jump to definition
48+
- Linting
49+
- Quick Fixes
50+
51+
The project is setup to reccomend lit-plugin to VS Code users if they don't already have it installed.
4752

4853
## Linting
4954

@@ -95,7 +100,6 @@ This starter project doesn't include any build-time optimizations like bundling
95100

96101
For information on building application projects that include LitElement components, see [Build for production](https://lit-element.polymer-project.org/guide/build) on the LitElement site.
97102

98-
99103
## More information
100104

101105
See [Get started](https://lit-element.polymer-project.org/guide/start) on the LitElement site for more information.

packages/lit-starter-js/custom-elements.json

+18-34
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
"description": "The number of times the button has been clicked.",
3434
"type": "number",
3535
"default": "0"
36+
},
37+
{
38+
"name": "renderRoot",
39+
"description": "Node or ShadowRoot into which element DOM should be rendered. Defaults\nto an open shadowRoot.",
40+
"type": "HTMLElement | ShadowRoot"
41+
},
42+
{
43+
"name": "isUpdatePending",
44+
"type": "boolean"
45+
},
46+
{
47+
"name": "hasUpdated",
48+
"type": "boolean"
49+
},
50+
{
51+
"name": "updateComplete",
52+
"description": "Returns a Promise that resolves when the element has completed updating.\nThe Promise value is a boolean that is `true` if the element completed the\nupdate without triggering another update. The Promise result is `false` if\na property was set inside `updated()`. If the Promise is rejected, an\nexception was thrown during the update.\n\nTo await additional asynchronous work, override the `getUpdateComplete`\nmethod. For example, it is sometimes useful to await a rendered element\nbefore fulfilling this Promise. To do this, first await\n`super.getUpdateComplete()`, then any subsequent state.",
53+
"type": "Promise<boolean>"
3654
}
3755
],
3856
"slots": [
@@ -47,40 +65,6 @@
4765
"description": "The button"
4866
}
4967
]
50-
},
51-
{
52-
"name": "my-element",
53-
"path": "./docs-/my-element.bundled.js",
54-
"attributes": [
55-
{
56-
"name": "name",
57-
"type": "string"
58-
},
59-
{
60-
"name": "count",
61-
"type": "number"
62-
}
63-
],
64-
"properties": [
65-
{
66-
"name": "name",
67-
"attribute": "name",
68-
"type": "string"
69-
},
70-
{
71-
"name": "count",
72-
"attribute": "count",
73-
"type": "number"
74-
},
75-
{
76-
"name": "hasUpdated",
77-
"type": "number"
78-
},
79-
{
80-
"name": "updateComplete",
81-
"type": "Promise<any>"
82-
}
83-
]
8468
}
8569
]
8670
}

packages/lit-starter-js/dev/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
This directory contains HTML files containing your element for development. By running `npm run build:watch` and `npm run serve` you can edit and see changes without bundling.

packages/lit-starter-js/dev/index.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22

33
<html>
44
<head>
5-
<meta charset="utf-8">
5+
<meta charset="utf-8" />
66
<title>&lt;my-element> Demo</title>
7+
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
8+
<script src="../node_modules/lit/polyfill-support.js"></script>
79
<script type="module" src="../my-element.js"></script>
810
<style>
911
p {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore files with a leading underscore; useful for e.g. readmes in source documentation
2+
_*.md

packages/lit-starter-js/docs-src/_data/api.11tydata.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const fs = require('fs');
22

33
module.exports = () => {
4-
const customElements = JSON.parse(fs.readFileSync('custom-elements.json', 'utf-8'));
4+
const customElements = JSON.parse(
5+
fs.readFileSync('custom-elements.json', 'utf-8')
6+
);
57
return {
68
customElements,
79
};

packages/lit-starter-js/docs-src/_includes/example.11ty.cjs

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ const relative = require('./relative-path.cjs');
44
/**
55
* This template extends the page template and adds an examples list.
66
*/
7-
module.exports = function(data) {
8-
7+
module.exports = function (data) {
98
return page({
109
...data,
1110
content: renderExample(data),
@@ -18,13 +17,22 @@ const renderExample = ({name, content, collections, page}) => {
1817
<section class="examples">
1918
<nav class="collection">
2019
<ul>
21-
${collections.example === undefined
20+
${
21+
collections.example === undefined
2222
? ''
23-
: collections.example.map((post) => `
23+
: collections.example
24+
.map(
25+
(post) => `
2426
<li class=${post.url === page.url ? 'selected' : ''}>
25-
<a href="${relative(page.url, post.url)}">${post.data.description.replace('<', '&lt;')}</a>
27+
<a href="${relative(
28+
page.url,
29+
post.url
30+
)}">${post.data.description.replace('<', '&lt;')}</a>
2631
</li>
27-
`).join('')}
32+
`
33+
)
34+
.join('')
35+
}
2836
</ul>
2937
</nav>
3038
<div>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module.exports = function(data) {
1+
module.exports = function (data) {
22
return `
33
<footer>
44
<p>
55
Made with
6-
<a href="https://github.com/PolymerLabs/lit-element-starter-js">lit-element-starter-js</a>
6+
<a href="https://github.com/PolymerLabs/lit-starter-js">lit-starter-js</a>
77
</p>
88
</footer>`;
99
};

packages/lit-starter-js/docs-src/_includes/header.11ty.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(data) {
1+
module.exports = function (data) {
22
return `
33
<header>
44
<h1>&lt;my-element></h1>

packages/lit-starter-js/docs-src/_includes/nav.11ty.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const relative = require('./relative-path.cjs');
22

3-
module.exports = function({page}) {
3+
module.exports = function ({page}) {
44
return `
55
<nav>
66
<a href="${relative(page.url, '/')}">Home</a>

0 commit comments

Comments
 (0)