Skip to content

Commit bebd632

Browse files
authored
chore: update dev dependencies and demo, format code (#65)
1 parent 11477e3 commit bebd632

13 files changed

+2318
-5229
lines changed

.eslintrc.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
"plugin:import/typescript",
77
"plugin:lit/all",
88
"plugin:wc/recommended",
9-
"plugin:prettier/recommended",
10-
"prettier/@typescript-eslint"
9+
"plugin:prettier/recommended"
1110
],
1211
"plugins": ["@typescript-eslint", "wc", "prettier"],
1312
"parser": "@typescript-eslint/parser",
1413
"parserOptions": {
1514
"sourceType": "module",
16-
"ecmaVersion": 2018,
17-
"project": "./tsconfig.json"
15+
"ecmaVersion": 2019
1816
},
1917
"env": {
2018
"browser": true

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v12.22.1

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $ wca analyze my-element.js --outFile custom-elements.json --format json
7171
</html>
7272
```
7373

74-
4. Use [es-dev-server](https://open-wc.org/developing/es-dev-server.html) to serve your HTML page.
74+
4. Use [web-dev-server](https://modern-web.dev/docs/dev-server/overview/) to serve your HTML page.
7575

7676
## Usage options
7777

@@ -357,7 +357,7 @@ $ yarn
357357
$ yarn dev
358358
```
359359

360-
Open http://127.0.0.1:8081/demo/
360+
Open http://127.0.0.1:8080
361361

362362
### Create dist folder
363363

@@ -377,4 +377,4 @@ $ yarn serve:dist
377377
- Thanks to [@bahrus](https://github.com/bahrus) for [wc-info](https://github.com/bahrus/wc-info) component which inspired me.
378378
- The visual appearance is largely inspired by [Vuetify](https://vuetifyjs.com/en/getting-started/quick-start) API docs.
379379
- The tabs component is based on the [howto-tabs](https://developers.google.com/web/fundamentals/web-components/examples/howto-tabs) example.
380-
- Thanks to [open-wc.org](https://open-wc.org/) for [es-dev-server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) and [rollup preset](https://open-wc.org/building/building-rollup.html).
380+
- Thanks to [Modern Web](https://modern-web.dev) for [Web Dev Server](https://modern-web.dev/docs/dev-server/overview/) and [Rollup Plugin HTML](https://modern-web.dev/docs/building/rollup-plugin-html/).

demo/custom-elements.json renamed to custom-elements.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"tags": [
44
{
55
"name": "expansion-panel",
6-
"path": "./../src/fixtures/expansion-panel.ts",
6+
"path": "./src/fixtures/expansion-panel.ts",
77
"description": "A custom element similar to the HTML5 `<details>` element.",
88
"attributes": [
99
{
@@ -97,7 +97,7 @@
9797
},
9898
{
9999
"name": "fancy-accordion",
100-
"path": "./../src/fixtures/fancy-accordion.ts",
100+
"path": "./src/fixtures/fancy-accordion.ts",
101101
"description": "A custom element implementing the accordion widget: a vertically stacked set of expandable panels\nthat wraps several instances of the `<expansion-panel>` element. Only one panel can be opened\n(expanded) at a time.\n\nPanel headings function as controls that enable users to open (expand) or hide (collapse) their\nassociated sections of content. The user can toggle panels by mouse click, Enter and Space keys.\n\nThe component supports keyboard navigation and is aligned with the\n[WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion).",
102102
"attributes": [
103103
{
@@ -133,7 +133,7 @@
133133
},
134134
{
135135
"name": "intl-currency",
136-
"path": "./../src/fixtures/intl-currency.ts",
136+
"path": "./src/fixtures/intl-currency.ts",
137137
"description": "A custom element that formats currency using Intl.",
138138
"attributes": [
139139
{
@@ -181,7 +181,7 @@
181181
},
182182
{
183183
"name": "progress-bar",
184-
"path": "./../src/fixtures/progress-bar.ts",
184+
"path": "./src/fixtures/progress-bar.ts",
185185
"description": "A custom element similar to the HTML5 `<progress>` element.",
186186
"attributes": [
187187
{
@@ -249,7 +249,7 @@
249249
{
250250
"name": "--progress-bar-opacity",
251251
"description": "Opacity set on the underlying track.",
252-
"default": "\"0.16\""
252+
"default": "0.16"
253253
}
254254
],
255255
"cssParts": [

demo/index.html renamed to index.html

+8-9
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
}
6060
</style>
61-
<link rel="stylesheet" href="./styles.css">
61+
<link rel="stylesheet" href="./demo/styles.css">
6262
</head>
6363
<body>
6464
<nav>
@@ -198,15 +198,14 @@ <h2>CSS shadow parts</h2>
198198
</section>
199199
</template>
200200

201-
<script type="module" src="../lib/fixtures/expansion-panel.js"></script>
202-
<script type="module" src="../lib/fixtures/fancy-accordion.js"></script>
203-
<script type="module" src="../lib/fixtures/intl-currency.js"></script>
204-
<script type="module" src="../lib/fixtures/progress-bar.js"></script>
205-
<script type="module" src="../lib/api-viewer.js"></script>
206-
<script type="module" src="../lib/api-docs.js"></script>
207-
<script type="module" src="../lib/api-demo.js"></script>
201+
<script type="module">
202+
import './lib/fixtures/expansion-panel.js';
203+
import './lib/fixtures/fancy-accordion.js';
204+
import './lib/fixtures/progress-bar.js';
205+
import './lib/api-viewer.js';
206+
import './lib/api-docs.js';
207+
import './lib/api-demo.js';
208208

209-
<script>
210209
if (window.location.hash === '') {
211210
history.pushState({}, '', '#api-viewer');
212211
}

package.json

+28-26
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
"scripts": {
2727
"build": "tsc",
2828
"dev": "npm run watch & npm run serve",
29-
"dist": "rimraf dist && rollup -c rollup.config.js && cp ./demo/*.json dist",
30-
"fixtures": "wca analyze src/fixtures/*.ts --format json --outFile demo/custom-elements.json",
29+
"dist": "rimraf dist && rollup -c rollup.config.js && npm run fixtures && cp custom-elements.json dist",
30+
"fixtures": "wca analyze src/fixtures/*.ts --format json --outFile custom-elements.json",
3131
"lint:css": "stylelint src/*.ts",
3232
"lint:eslint": "eslint src --ext .ts",
3333
"lint:lit": "lit-analyzer src --strict",
3434
"lint": "npm-run-all --parallel lint:*",
3535
"prepublishOnly": "npm run build",
36-
"serve": "es-dev-server --node-resolve --port 8081",
37-
"serve:dist": "es-dev-server --app-index dist/index.html --open",
36+
"serve": "web-dev-server --node-resolve",
37+
"serve:dist": "web-dev-server --app-index dist/index.html --open",
3838
"size": "size-limit",
3939
"size:why": "size-limit --why",
4040
"watch": "tsc-watch"
@@ -50,38 +50,40 @@
5050
"lit-element": "^2.0.0",
5151
"lit-html": "^1.0.0",
5252
"marked": "^2.0.0",
53-
"tslib": "^2.0.1"
53+
"tslib": "^2.3.1"
5454
},
5555
"devDependencies": {
56-
"@open-wc/building-rollup": "^1.9.0",
57-
"@size-limit/preset-small-lib": "^4.6.0",
58-
"@typescript-eslint/eslint-plugin": "^4.1.0",
59-
"@typescript-eslint/parser": "^4.1.0",
56+
"@rollup/plugin-node-resolve": "^11.0.0",
57+
"@size-limit/preset-small-lib": "^6.0.0",
58+
"@typescript-eslint/eslint-plugin": "^5.0.0",
59+
"@typescript-eslint/parser": "^5.0.0",
60+
"@web/dev-server": "^0.1.25",
61+
"@web/rollup-plugin-html": "^1.10.1",
6062
"deepmerge": "4.2.2",
61-
"es-dev-server": "^1.57.4",
62-
"eslint": "^7.8.1",
63+
"eslint": "^8.0.0",
6364
"eslint-config-airbnb-base": "^14.2.0",
64-
"eslint-config-prettier": "^6.11.0",
65-
"eslint-plugin-import": "^2.22.0",
66-
"eslint-plugin-lit": "^1.2.2",
67-
"eslint-plugin-prettier": "^3.1.4",
68-
"eslint-plugin-wc": "^1.2.0",
65+
"eslint-config-prettier": "^8.3.0",
66+
"eslint-plugin-import": "^2.25.2",
67+
"eslint-plugin-lit": "1.3.0",
68+
"eslint-plugin-prettier": "^4.0.0",
69+
"eslint-plugin-wc": "^1.3.2",
6970
"husky": "^4.3.0",
7071
"lint-staged": "^10.3.0",
7172
"lit-analyzer": "^1.2.1",
7273
"npm-run-all": "^4.1.5",
73-
"prettier": "^2.1.1",
74+
"prettier": "^2.4.1",
7475
"rimraf": "^3.0.2",
75-
"rollup": "^2.26.11",
76-
"rollup-plugin-copy": "^3.3.0",
77-
"size-limit": "^4.6.0",
78-
"stylelint": "^13.7.1",
79-
"stylelint-config-prettier": "^8.0.2",
80-
"stylelint-config-standard": "^20.0.0",
76+
"rollup": "^2.58.0",
77+
"rollup-plugin-copy": "^3.4.0",
78+
"rollup-plugin-terser": "^7.0.2",
79+
"size-limit": "^6.0.0",
80+
"stylelint": "^13.13.1",
81+
"stylelint-config-prettier": "^9.0.3",
82+
"stylelint-config-standard": "^22.0.0",
8183
"stylelint-config-styled-components": "^0.1.1",
8284
"stylelint-processor-styled-components": "1.10.0",
83-
"tsc-watch": "^4.2.9",
84-
"typescript": "^4.0.2",
85+
"tsc-watch": "^4.5.0",
86+
"typescript": "^4.4.4",
8587
"web-component-analyzer": "^1.1.6"
8688
},
8789
"husky": {
@@ -98,7 +100,7 @@
98100
"size-limit": [
99101
{
100102
"path": "lib/api-viewer.js",
101-
"limit": "37 KB"
103+
"limit": "38 KB"
102104
}
103105
]
104106
}

rollup.config.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import merge from 'deepmerge';
2-
import copy from 'rollup-plugin-copy';
3-
import { createSpaConfig } from '@open-wc/building-rollup';
1+
import { nodeResolve } from '@rollup/plugin-node-resolve';
2+
import { terser } from 'rollup-plugin-terser';
3+
import html from '@web/rollup-plugin-html';
44

5-
const config = createSpaConfig({
6-
html: {
7-
minify: false
8-
}
9-
});
10-
11-
export default merge(config, {
12-
input: './demo/index.html',
13-
plugins: [
14-
copy({
15-
targets: [{ src: './demo/*.css', dest: './dist' }]
16-
})
17-
]
18-
});
5+
export default {
6+
input: './index.html',
7+
output: {
8+
dir: './dist'
9+
},
10+
plugins: [html({ minify: false }), nodeResolve(), terser()]
11+
};

src/api-demo-layout-mixin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export const ApiDemoLayoutMixin = <T extends Constructor<LitElement>>(
324324

325325
private _syncKnob(component: Element, changed: PropertyInfo) {
326326
const { name, type, attribute } = changed;
327-
const value = ((component as unknown) as ComponentWithProps)[name];
327+
const value = (component as unknown as ComponentWithProps)[name];
328328

329329
// update knobs to avoid duplicate event
330330
this.knobs = {

src/fixtures/fancy-accordion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class FancyAccordion extends LitElement {
104104

105105
get focused(): Element | null {
106106
const root = this.getRootNode();
107-
return ((root as unknown) as DocumentOrShadowRoot).activeElement;
107+
return (root as unknown as DocumentOrShadowRoot).activeElement;
108108
}
109109

110110
private _onKeydown(event: KeyboardEvent) {

0 commit comments

Comments
 (0)