@blockquote/create-wc 2.11.2 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,159 +1,165 @@
1
- # Web Components with Lit - Scaffold
1
+ # create-wc
2
2
 
3
- This scaffold generator extends and customizes **[@open-wc/create](https://open-wc.org/docs/development/generator/#extending)**, providing a starting point for creating web components with **[Lit](https://lit.dev/)**.
3
+ `create-wc` extends **[@open-wc/create](https://open-wc.org/docs/development/generator/#extending)** and scaffolds **[Lit](https://lit.dev/)** web components with a batteries-included setup for linting, formatting, testing, Sass, Vite, and Custom Elements Manifest generation.
4
4
 
5
- **Example:**
5
+ Example output:
6
6
 
7
7
  [![Open in GitHub](https://img.shields.io/badge/Open_in_GitHub-%23121011.svg?logo=github&logoColor=white)](https://github.com/oscarmarina/lit-vitest-testing-comparison)
8
8
 
9
9
  [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/oscarmarina/lit-vitest-testing-comparison)
10
10
 
11
- <hr>
11
+ ## Tutorial
12
12
 
13
- ## Development Tools
13
+ Use this section if you want the shortest path from zero to a working component.
14
14
 
15
- ### Scaffold
16
-
17
- - Lint: `eslint`
18
- - Format: `prettier`
19
-
20
- ### Vite & Vitest
21
-
22
- - **Server**: [Vite Server](https://vitejs.dev/config/server-options.html)
23
- - **Preview**: [Vite Preview](https://vitejs.dev/config/preview-options.html)
24
- - **Build**: [Vite Build](https://vitejs.dev/guide/build.html)
25
-
26
- - TypeScript: [`vite` transpile only](https://vite.dev/guide/features.html#typescript)
27
- - TypeScript: [`tsc` emit declarations only](https://www.typescriptlang.org/tsconfig/#emitDeclarationOnly)
28
-
29
- - **Test**: [Vitest browser mode](https://vitest.dev/guide/browser/) and [chai-a11y-axe](https://www.npmjs.com/package/chai-a11y-axe)
30
-
31
- - ### Sass
32
-
33
- - SCSS [watcher](https://github.com/oscarmarina/sass-style-template) with [sass](https://www.npmjs.com/package/sass)
34
-
35
- - ### analyze
36
- - [Custom Elements Manifest](https://custom-elements-manifest.open-wc.org/blog/intro/)
37
- - [Plugin: cem-to-markdown-readme](https://github.com/oscarmarina/cem-to-markdown-readme)
38
-
39
- <hr>
40
-
41
- ## Installation
15
+ ### Create a project
42
16
 
43
17
  ```bash
44
18
  npm init @blockquote/wc
45
19
  ```
46
20
 
47
- ### Start
21
+ The generator will ask for:
22
+
23
+ - The custom element tag name
24
+ - An optional namespace
25
+ - Whether the project should use TypeScript
26
+
27
+ ### Start development
28
+
29
+ After the project is generated:
48
30
 
49
31
  ```bash
32
+ cd your-project-name
33
+ npm install
50
34
  npm start
51
35
  ```
52
36
 
53
- <hr>
54
-
55
- ### Linting and Formatting
37
+ `npm start` runs the Vite workflow together with the Sass watcher.
56
38
 
57
- To scan the project for linting and formatting errors, run:
39
+ ## How-to Guides
58
40
 
59
- ```bash
60
- npm run lint
61
- ```
41
+ Use these commands once you already have a generated project.
62
42
 
63
- To automatically fix them, run:
43
+ ### Format the generated project
64
44
 
65
45
  ```bash
66
46
  npm run format
67
47
  ```
68
48
 
69
- ### Testing
49
+ This runs ESLint, Prettier, and Stylelint fixes.
70
50
 
71
- Run tests with:
51
+ ### Run tests
72
52
 
73
53
  ```bash
74
- // vitest --run --browser.headless
75
-
76
54
  npm run test
77
55
  ```
78
56
 
79
- ```bash
80
- // vitest
57
+ For interactive browser testing:
81
58
 
59
+ ```bash
82
60
  npm run test:watch
83
61
  ```
84
62
 
85
- <hr>
63
+ ### Preview the demo output
86
64
 
87
- ### Development Server
65
+ Build the demo assets:
88
66
 
89
- Start the development server:
67
+ ```bash
68
+ npm run dev:vite
69
+ ```
70
+
71
+ Preview the built output:
90
72
 
91
73
  ```bash
92
- npm run start
74
+ npm run preview:vite
93
75
  ```
94
76
 
95
- ### Hosting a Static Demo (Do Not Bundle)
77
+ ### Build the TypeScript variant
96
78
 
97
- For hosting a static demo without bundling:
79
+ In TypeScript projects:
98
80
 
99
81
  ```bash
100
- npm run dev:vite
82
+ npm run build
101
83
  ```
102
84
 
103
- Preview demo:
85
+ This runs Vite for bundling and `tsc` for declarations.
86
+
87
+ ### Regenerate Custom Elements documentation
104
88
 
105
89
  ```bash
106
- npm run preview:vite
90
+ npm run analyze
107
91
  ```
108
92
 
109
- <hr>
93
+ ### Enable Husky hooks
110
94
 
111
- ### TypeScript
95
+ After `git init`, run:
112
96
 
113
97
  ```bash
114
- npm run build
98
+ npm run prepare
115
99
  ```
116
100
 
117
- <hr>
101
+ ## Reference
118
102
 
119
- ### Sass
103
+ ### What the generator includes
120
104
 
121
- #### SCSS Watcher
105
+ - **Lit** for component authoring
106
+ - **Vite** for local development and preview builds
107
+ - **Vitest** in browser mode plus `chai-a11y-axe` for testing
108
+ - **ESLint**, **Prettier**, and **Stylelint** for code quality
109
+ - **Sass** via [sass-style-template](https://github.com/oscarmarina/sass-style-template)
110
+ - **Custom Elements Manifest** generation and README tooling
122
111
 
123
- Start the SCSS watcher:
112
+ ### Generated project scripts
124
113
 
125
- ```bash
126
- npm run sass:watch
127
- ```
114
+ These scripts are available in generated projects.
128
115
 
129
- <hr>
116
+ | Script | Purpose |
117
+ | ---------------------- | ------------------------------------------------ |
118
+ | `npm start` | Run Vite and the Sass watcher together |
119
+ | `npm run vite` | Start the Vite dev server |
120
+ | `npm run dev:vite` | Build the demo assets |
121
+ | `npm run preview:vite` | Preview the built demo |
122
+ | `npm run test` | Run Vitest |
123
+ | `npm run test:watch` | Run Vitest in browser mode without headless mode |
124
+ | `npm run analyze` | Generate the Custom Elements Manifest |
125
+ | `npm run prepare` | Install Husky hooks |
126
+ | `npm run format` | Run ESLint, Prettier, and Stylelint fixes |
127
+ | `npm run sass:watch` | Run the Sass watcher |
130
128
 
131
- ### Custom Elements Manifest
129
+ ### Variant-specific scripts
132
130
 
133
- #### Generating README from `custom-elements.json`
131
+ JavaScript projects:
134
132
 
135
- Generate documentation:
133
+ - `npm run build` prints a message because there is no TypeScript build step.
136
134
 
137
- ```bash
138
- npm run analyze
139
- ```
135
+ TypeScript projects:
140
136
 
141
- ### Husky
137
+ - `npm run build` runs the library build and TypeScript declaration output.
142
138
 
143
- Husky is pre-installed.
139
+ ### Maintainer scripts for this repository
144
140
 
145
- After initializing Git with `git init`, run:
141
+ These scripts belong to this generator repository itself, not to generated projects.
146
142
 
147
- ```bash
148
- npm run prepare
149
- ```
143
+ | Script | Purpose |
144
+ | ---------------- | ------------------------- |
145
+ | `npm start` | Run the generator locally |
146
+ | `npm run format` | Format this repository |
147
+
148
+ ## Explanation
149
+
150
+ This project exists to provide a more opinionated starting point than raw `@open-wc/create`, while still building on its generator model instead of replacing it.
150
151
 
151
- to set up Husky and its Git hooks.
152
+ The generated scaffold is aimed at teams building Lit-based web components that want:
152
153
 
153
- <hr>
154
+ - A ready-to-run development setup
155
+ - Sass support out of the box
156
+ - Test tooling for browser-oriented component work
157
+ - Linting and formatting defaults across JavaScript, TypeScript, HTML, and styles
158
+ - Custom Elements Manifest generation as part of the workflow
154
159
 
155
- **Plugins:**
160
+ The repository itself is intentionally small: it assembles mixins and templates that define the generated project structure and scripts.
156
161
 
157
- - [rollup-plugin-externalize-source-dependencies](https://github.com/oscarmarina/rollup-plugin-externalize-source-dependencies)
162
+ ## Related Links
158
163
 
164
+ - [rollup-plugin-total-bundlesize](https://github.com/oscarmarina/rollup-plugin-total-bundlesize)
159
165
  - [vite-plugin-prevent-rewrite-imports-type-module](https://github.com/oscarmarina/vite-plugin-prevent-rewrite-imports-type-module/tree/main)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockquote/create-wc",
3
- "version": "2.11.2",
3
+ "version": "2.12.0",
4
4
  "description": "Web component with Lit scaffolding - Extending Open Web Component",
5
5
  "keywords": [
6
6
  "Lit",
@@ -26,7 +26,7 @@
26
26
  "/src/"
27
27
  ],
28
28
  "scripts": {
29
- "format": "eslint . --fix && prettier \"**/*.{js,mjs,cjs,md.json}\" --write --ignore-path .prettierignore",
29
+ "format": "eslint . --fix --no-config-lookup --config ./eslint.config.js && prettier \"**/*.{js,mjs,cjs,md,json}\" --write --ignore-path .prettierignore",
30
30
  "start": "node ./src/create.js"
31
31
  },
32
32
  "prettier": {
@@ -50,15 +50,15 @@
50
50
  "chalk": "^5.6.2",
51
51
  "command-line-args": "^6.0.2",
52
52
  "prompts": "^2.4.2",
53
- "semver": "^7.7.4"
53
+ "semver": "^7.8.5"
54
54
  },
55
55
  "devDependencies": {
56
- "@eslint/js": "^9.39.4",
57
- "@open-wc/eslint-config": "^13.0.0",
58
- "eslint": "^9.39.4",
56
+ "@eslint/js": "^10.0.1",
57
+ "@open-wc/eslint-config": "^13.1.0",
58
+ "eslint": "^10.5.0",
59
59
  "eslint-config-prettier": "^10.1.8",
60
- "prettier": "^3.8.3",
61
- "globals": "^17.6.0"
60
+ "prettier": "^3.8.4",
61
+ "globals": "^17.7.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"
@@ -68,22 +68,23 @@
68
68
  ]
69
69
  },
70
70
  "devDependencies": {
71
- "@eslint/js": "^9.39.4",
72
- "@html-eslint/eslint-plugin": "^0.60.0",
73
- "@html-eslint/parser": "^0.60.0",
74
- "eslint": "^9.39.4",
71
+ "@eslint/js": "^10.0.1",
72
+ "@html-eslint/eslint-plugin": "^0.62.0",
73
+ "@html-eslint/parser": "^0.62.0",
74
+ "eslint": "^10.5.0",
75
75
  "eslint-config-prettier": "^10.1.8",
76
76
  "eslint-plugin-html": "^8.1.4",
77
- "eslint-plugin-import": "^2.32.0",
78
- "eslint-plugin-lit": "^2.2.1",
77
+ "eslint-plugin-import-x": "^4.17.0",
78
+ "eslint-import-resolver-typescript": "4.4.5",
79
+ "eslint-plugin-lit": "^2.3.1",
79
80
  "eslint-plugin-lit-a11y": "^5.1.1",
80
81
  "eslint-plugin-wc": "^3.1.0",
81
- "typescript-eslint": "^8.59.2",
82
- "globals": "^17.6.0",
82
+ "typescript-eslint": "^8.62.0",
83
+ "globals": "^17.7.0",
83
84
  "husky": "^9.1.7",
84
- "lint-staged": "^17.0.2",
85
- "prettier": "^3.8.3",
86
- "stylelint": "^17.11.0",
85
+ "lint-staged": "^17.0.8",
86
+ "prettier": "^3.8.4",
87
+ "stylelint": "^17.13.0",
87
88
  "stylelint-config-standard-scss": "^17.0.0"
88
89
  }
89
90
  }
@@ -2,13 +2,14 @@ import js from '@eslint/js';
2
2
  import {configs as wc} from 'eslint-plugin-wc';
3
3
  import {configs as lit} from 'eslint-plugin-lit';
4
4
  import {default as litA11y} from 'eslint-plugin-lit-a11y';
5
- import {flatConfigs as importPlugin} from 'eslint-plugin-import';
5
+ import {flatConfigs as importPlugin, createNodeResolver} from 'eslint-plugin-import-x';
6
6
  import {configs as tseslint, parser as tsParser} from 'typescript-eslint';
7
7
  import htmlEslint from '@html-eslint/eslint-plugin';
8
8
  import htmlEslintParser from '@html-eslint/parser';
9
9
  import eslintPluginHtml from 'eslint-plugin-html';
10
10
  import eslintConfigPrettier from 'eslint-config-prettier';
11
11
  import globals from 'globals';
12
+ import path from 'node:path';
12
13
 
13
14
  const fileTypes = '{js,ts,mjs}';
14
15
 
@@ -34,7 +35,7 @@ const baseConfig = [
34
35
 
35
36
  //
36
37
  // ──────────────────────────────────────────────────────────────
37
- // eslint-plugin-import
38
+ // eslint-plugin-import-x
38
39
  // ──────────────────────────────────────────────────────────────
39
40
  //
40
41
  const importFilesConfig = [importPlugin.recommended, importPlugin.typescript].map((conf) => ({
@@ -52,19 +53,20 @@ const importFilesConfig = [importPlugin.recommended, importPlugin.typescript].ma
52
53
  const importFilesRules = {
53
54
  files: [`**/*.${fileTypes}`],
54
55
  rules: {
55
- 'import/extensions': ['error', 'always', {ignorePackages: true}],
56
- 'import/no-extraneous-dependencies': [
56
+ 'import-x/extensions': ['error', 'always', {ignorePackages: true}],
57
+ 'import-x/no-extraneous-dependencies': [
57
58
  'error',
58
59
  {
59
60
  devDependencies: [
61
+ `**/demo/**/*.${fileTypes}`,
60
62
  `**/test/**/*.${fileTypes}`,
61
63
  `**/*.config.${fileTypes}`,
62
64
  `**/*.conf.${fileTypes}`,
63
65
  ],
64
66
  },
65
67
  ],
66
- 'import/no-unresolved': 'off',
67
- 'import/prefer-default-export': 'off',
68
+ 'import-x/no-unresolved': 'off',
69
+ 'import-x/prefer-default-export': 'off',
68
70
  },
69
71
  };
70
72
 
@@ -73,11 +75,13 @@ const importFilesRules = {
73
75
  // eslint-plugin-lit-a11y
74
76
  // ──────────────────────────────────────────────────────────────
75
77
  //
76
- // @ts-ignore
77
- const litA11yFilesConfig = [litA11y.configs.recommended].map((conf) => ({
78
- ...conf,
79
- files: [`**/*.${fileTypes}`],
80
- }));
78
+ const litA11yFilesConfig = [
79
+ {
80
+ // @ts-ignore
81
+ ...litA11y.configs.recommended,
82
+ files: [`**/*.${fileTypes}`],
83
+ },
84
+ ];
81
85
 
82
86
  const litA11yFilesRules = {
83
87
  files: [`**/*.${fileTypes}`],
@@ -93,10 +97,12 @@ const litA11yFilesRules = {
93
97
  // eslint-plugin-wc
94
98
  // ──────────────────────────────────────────────────────────────
95
99
  //
96
- const wcFilesConfig = [wc['flat/recommended']].map((conf) => ({
97
- ...conf,
98
- files: [`**/*.${fileTypes}`],
99
- }));
100
+ const wcFilesConfig = [
101
+ {
102
+ ...wc['flat/recommended'],
103
+ files: [`**/*.${fileTypes}`],
104
+ },
105
+ ];
100
106
 
101
107
  const wcFilesRules = {
102
108
  files: [`**/*.${fileTypes}`],
@@ -110,10 +116,12 @@ const wcFilesRules = {
110
116
  // eslint-plugin-lit
111
117
  // ──────────────────────────────────────────────────────────────
112
118
  //
113
- const litFilesConfig = [lit['flat/recommended']].map((conf) => ({
114
- ...conf,
115
- files: [`**/*.${fileTypes}`],
116
- }));
119
+ const litFilesConfig = [
120
+ {
121
+ ...lit['flat/recommended'],
122
+ files: [`**/*.${fileTypes}`],
123
+ },
124
+ ];
117
125
 
118
126
  const litFilesRules = {
119
127
  files: [`**/*.${fileTypes}`],
@@ -174,19 +182,18 @@ const tsFilesRules = {
174
182
  // HTML
175
183
  // ──────────────────────────────────────────────────────────────
176
184
  //
177
- // @ts-ignore
178
- const htmlFilesConfig = [htmlEslint.configs['flat/recommended']].map((conf) => ({
179
- ...conf,
180
- files: ['**/*.html'],
181
- plugins: {
182
- ...conf.plugins,
183
- '@html-eslint': htmlEslint,
184
- },
185
- languageOptions: {
186
- ...conf.languageOptions,
187
- parser: htmlEslintParser,
185
+ const htmlFilesConfig = [
186
+ {
187
+ ...htmlEslint.configs['flat/recommended'],
188
+ files: ['**/*.html'],
189
+ plugins: {
190
+ '@html-eslint': htmlEslint,
191
+ },
192
+ languageOptions: {
193
+ parser: htmlEslintParser,
194
+ },
188
195
  },
189
- }));
196
+ ];
190
197
 
191
198
  const htmlFilesRules = {
192
199
  files: ['**/*.html'],
@@ -195,6 +202,7 @@ const htmlFilesRules = {
195
202
  '@html-eslint/require-closing-tags': 'off',
196
203
  '@html-eslint/no-extra-spacing-tags': 'off',
197
204
  '@html-eslint/attrs-newline': 'off',
205
+ '@html-eslint/use-baseline': ['error', {available: 'newly'}],
198
206
  },
199
207
  };
200
208
 
@@ -254,15 +262,15 @@ export default [
254
262
 
255
263
  eslintConfigPrettier,
256
264
 
265
+ {
266
+ settings: {
267
+ 'import-x/resolver-next': [createNodeResolver({extensions: ['.js', '.ts']})],
268
+ },
269
+ },
270
+
257
271
  {
258
272
  rules: {
259
- 'no-unused-expressions': [
260
- 'error',
261
- {
262
- allowShortCircuit: true,
263
- allowTernary: true,
264
- },
265
- ],
273
+ 'no-unused-expressions': ['error', {allowShortCircuit: true, allowTernary: true}],
266
274
  'no-empty-function': 'error',
267
275
  },
268
276
  },
@@ -24,31 +24,31 @@
24
24
  "test:watch": "vitest --browser.headless=false"
25
25
  },
26
26
  "dependencies": {
27
- "lit": "^3.3.2"
27
+ "lit": "^3.3.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@blockquote/cem-to-markdown-readme": "^1.0.0",
31
- "@blockquote/rollup-plugin-total-bundlesize": "^2.3.1",
31
+ "@blockquote/rollup-plugin-total-bundlesize": "^2.4.0",
32
32
  "@blockquote/sass-style-template": "^5.1.1",
33
33
  "@custom-elements-manifest/analyzer": "^0.11.0",
34
34
  "@open-wc/semantic-dom-diff": "^0.20.1",
35
35
  "@open-wc/testing-helpers": "^3.0.1",
36
- "playwright": "^1.59.1",
36
+ "playwright": "^1.61.0",
37
37
  "postcss-html": "^1.8.1",
38
38
  "postcss-lit": "^1.4.1",
39
39
  "@types/mocha": "^10.0.10",
40
40
  "rollup-plugin-copy": "^3.5.0",
41
41
  "rollup-plugin-node-externals": "^9.0.1",
42
- "tinyglobby": "^0.2.16",
42
+ "tinyglobby": "^0.2.17",
43
43
  "chai-a11y-axe": "^1.5.0",
44
- "concurrently": "^9.2.1",
45
- "sort-package-json": "^3.6.1",
46
- "@vitest/browser-playwright": "^4.1.5",
47
- "@vitest/coverage-istanbul": "^4.1.5",
48
- "@vitest/coverage-v8": "^4.1.5",
49
- "@vitest/ui": "^4.1.5",
50
- "vitest": "^4.1.5",
51
- "vite": "^8.0.11"
44
+ "concurrently": "^10.0.3",
45
+ "sort-package-json": "^4.0.0",
46
+ "@vitest/browser-playwright": "^4.1.9",
47
+ "@vitest/coverage-istanbul": "^4.1.9",
48
+ "@vitest/coverage-v8": "^4.1.9",
49
+ "@vitest/ui": "^4.1.9",
50
+ "vitest": "^4.1.9",
51
+ "vite": "^8.1.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -1,11 +1,9 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
- <title>Demo - <%= tagName %></title>
5
4
  <meta charset="utf-8" />
6
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <link rel="icon" href="data:," />
8
- <meta name="description" content="<%= tagName %>" />
6
+ <title>Demo - <%= tagName %></title>
9
7
  <style>
10
8
  html,
11
9
  body {
@@ -14,6 +12,8 @@
14
12
  font-family: sans-serif;
15
13
  }
16
14
  </style>
15
+ <link rel="icon" href="data:," />
16
+ <meta name="description" content="<%= tagName %>" />
17
17
  </head>
18
18
  <body>
19
19
  <script type="module">
@@ -13,7 +13,7 @@
13
13
  "strict": false,
14
14
  "noImplicitThis": true,
15
15
  "alwaysStrict": true,
16
- "allowSyntheticDefaultImports": true,
16
+ "allowSyntheticDefaultImports": true
17
17
  },
18
18
  "include": ["src/**/*.js"]
19
19
  }
@@ -8,11 +8,7 @@
8
8
  "esModuleInterop": true,
9
9
  "experimentalDecorators": true,
10
10
  "forceConsistentCasingInFileNames": true,
11
- "lib": [
12
- "es2023",
13
- "DOM",
14
- "DOM.Iterable"
15
- ],
11
+ "lib": ["es2023", "DOM", "DOM.Iterable"],
16
12
  "module": "esnext",
17
13
  "moduleResolution": "Bundler",
18
14
  "noFallthroughCasesInSwitch": true,
@@ -30,13 +26,9 @@
30
26
  "strict": true,
31
27
  "stripInternal": true,
32
28
  "target": "es2023",
33
- "types": [
34
- "mocha"
35
- ],
29
+ "types": ["mocha"],
36
30
  "useDefineForClassFields": false,
37
31
  "verbatimModuleSyntax": true
38
32
  },
39
- "include": [
40
- "src/**/*.ts"
41
- ]
33
+ "include": ["src/**/*.ts"]
42
34
  }