@pfern/create-elements 1.0.3 → 1.0.4
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/index.js +5 -2
- package/package.json +1 -1
- package/template/README.md +5 -0
- package/template/eslint.config.js +71 -0
- package/template/package.json +3 -1
- package/template/src/components/app.js +11 -15
- package/template/src/components/todos.js +10 -10
- package/template/src/router.js +1 -1
- package/template/.eslintrc.json +0 -205
package/index.js
CHANGED
|
@@ -30,7 +30,11 @@ async function init() {
|
|
|
30
30
|
console.log(`\nScaffolding project in ${targetDir}...`);
|
|
31
31
|
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
const ignoredDirs = new Set(['node_modules', 'dist']);
|
|
34
|
+
fs.cpSync(templateDir, targetDir, {
|
|
35
|
+
recursive: true,
|
|
36
|
+
filter: src => !ignoredDirs.has(path.basename(src)),
|
|
37
|
+
});
|
|
34
38
|
|
|
35
39
|
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
36
40
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
@@ -52,4 +56,3 @@ async function init() {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
init().catch(console.error);
|
|
55
|
-
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -29,3 +29,8 @@ npm test
|
|
|
29
29
|
|
|
30
30
|
Routes are defined in `src/router.js` and used from `src/components/app.js`.
|
|
31
31
|
Navigation uses the History API so the address bar stays in sync.
|
|
32
|
+
|
|
33
|
+
## Linting & Formatting
|
|
34
|
+
|
|
35
|
+
The rules in `eslint.config.json` are there to allow for the Formatting style
|
|
36
|
+
used in the examples. Feel free to remove or edit them if preferred.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
files: ['**/*.js'],
|
|
4
|
+
languageOptions: {
|
|
5
|
+
ecmaVersion: 'latest',
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
'array-bracket-newline': ['warn', 'consistent'],
|
|
10
|
+
'arrow-parens': ['warn', 'as-needed'],
|
|
11
|
+
'arrow-spacing': 'warn',
|
|
12
|
+
'comma-spacing': ['warn', { before: false, after: true }],
|
|
13
|
+
'comma-style': ['warn', 'last'],
|
|
14
|
+
'computed-property-spacing': ['warn', 'never'],
|
|
15
|
+
'eol-last': ['warn', 'always'],
|
|
16
|
+
'indent': ['warn', 2, {
|
|
17
|
+
CallExpression: { arguments: 'first' },
|
|
18
|
+
ImportDeclaration: 'first',
|
|
19
|
+
ObjectExpression: 'first',
|
|
20
|
+
VariableDeclarator: {
|
|
21
|
+
var: 2,
|
|
22
|
+
let: 2,
|
|
23
|
+
const: 3,
|
|
24
|
+
},
|
|
25
|
+
}],
|
|
26
|
+
'key-spacing': ['warn', { mode: 'minimum' }],
|
|
27
|
+
'linebreak-style': ['error', 'unix'],
|
|
28
|
+
'no-extra-parens': 'warn',
|
|
29
|
+
'no-multi-spaces': ['warn', {
|
|
30
|
+
ignoreEOLComments: true,
|
|
31
|
+
exceptions: { Property: false },
|
|
32
|
+
}],
|
|
33
|
+
'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 1 }],
|
|
34
|
+
'no-trailing-spaces': 'warn',
|
|
35
|
+
'no-undef': 'warn',
|
|
36
|
+
'no-unused-vars': ['warn', {
|
|
37
|
+
args: 'all',
|
|
38
|
+
varsIgnorePattern: '^_',
|
|
39
|
+
argsIgnorePattern: '^_',
|
|
40
|
+
}],
|
|
41
|
+
'object-curly-newline': ['warn', { consistent: true }],
|
|
42
|
+
'object-curly-spacing': ['warn', 'always'],
|
|
43
|
+
'operator-linebreak': ['warn', 'before', { overrides: { '=': 'ignore' } }],
|
|
44
|
+
'prefer-rest-params': 'warn',
|
|
45
|
+
'quotes': ['warn', 'single'],
|
|
46
|
+
'semi': ['warn', 'never'],
|
|
47
|
+
'sort-imports': 'warn',
|
|
48
|
+
'space-before-function-paren': ['warn', {
|
|
49
|
+
anonymous: 'never',
|
|
50
|
+
asyncArrow: 'always',
|
|
51
|
+
named: 'never',
|
|
52
|
+
}],
|
|
53
|
+
'spaced-comment': ['warn', 'always'],
|
|
54
|
+
'space-in-parens': 'warn',
|
|
55
|
+
'space-infix-ops': 'warn',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
files: ['src/**/*.js'],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
globals: {
|
|
62
|
+
console: 'readonly',
|
|
63
|
+
URL: 'readonly',
|
|
64
|
+
Event: 'readonly',
|
|
65
|
+
PopStateEvent: 'readonly',
|
|
66
|
+
document: 'readonly',
|
|
67
|
+
window: 'readonly',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
]
|
package/template/package.json
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"build": "vite build",
|
|
11
11
|
"preview": "vite preview",
|
|
12
|
-
"test": "node --test test/*.test.* --test-reporter spec"
|
|
12
|
+
"test": "node --test test/*.test.* --test-reporter spec",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"lint:fix": "eslint . --fix"
|
|
13
15
|
},
|
|
14
16
|
"repository": {
|
|
15
17
|
"type": "git",
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { a, component, div, h2, main, nav, section } from '@pfern/elements'
|
|
2
|
+
import { currentPath, go, normalizePath } from '../router.js'
|
|
2
3
|
import { counter } from './counter.js'
|
|
3
4
|
import { todos } from './todos.js'
|
|
4
|
-
import { currentPath, go, normalizePath } from '../router.js'
|
|
5
5
|
|
|
6
6
|
const link = (path, label, active) =>
|
|
7
|
-
a({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, label)
|
|
7
|
+
a({ href: path,
|
|
8
|
+
class: active ? 'active' : '',
|
|
9
|
+
onclick: () => app(go(path, { force: true })) },
|
|
10
|
+
label)
|
|
12
11
|
|
|
13
12
|
const navbar = path =>
|
|
14
13
|
nav(
|
|
@@ -23,21 +22,18 @@ const home = () =>
|
|
|
23
22
|
and independent counters.`))
|
|
24
23
|
|
|
25
24
|
const counters = () =>
|
|
26
|
-
section(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
div(
|
|
31
|
-
h2('Counter 2'),
|
|
32
|
-
counter()))
|
|
25
|
+
section(
|
|
26
|
+
{ class: 'grid' },
|
|
27
|
+
div(h2('Counter 1'), counter()),
|
|
28
|
+
div(h2('Counter 2'), counter()))
|
|
33
29
|
|
|
34
30
|
export const app = component((path = currentPath()) => {
|
|
35
31
|
path = normalizePath(path)
|
|
36
32
|
|
|
37
33
|
const view =
|
|
38
34
|
path === '/todos' ? todos()
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
: path === '/counters' ? counters()
|
|
36
|
+
: home()
|
|
41
37
|
|
|
42
38
|
return main(
|
|
43
39
|
navbar(path),
|
|
@@ -15,14 +15,14 @@ export const todos = component(
|
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
div({ class: 'todos' },
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
form({ onsubmit: add },
|
|
19
|
+
input({ name: 'todo', placeholder: 'What needs doing?' }),
|
|
20
|
+
button({ type: 'submit' }, 'Add')),
|
|
21
|
+
|
|
22
|
+
ul(...items.map(item =>
|
|
23
|
+
li({ style:
|
|
24
|
+
{ 'text-decoration': item.done ? 'line-through' : 'none' } },
|
|
25
|
+
span({ onclick: () => toggle(item) }, item.value),
|
|
26
|
+
button({ onclick: () => remove(item) }, '✕'))))))
|
|
27
|
+
})
|
|
28
28
|
|
package/template/src/router.js
CHANGED
package/template/.eslintrc.json
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
{ "root": true,
|
|
2
|
-
"parserOptions": { "ecmaVersion": "latest", "sourceType": "module" },
|
|
3
|
-
"env": { "browser": true, "es2021": true },
|
|
4
|
-
|
|
5
|
-
"rules": {
|
|
6
|
-
"array-bracket-newline": [ "warn", "consistent" ],
|
|
7
|
-
"arrow-parens": [ "warn", "as-needed" ],
|
|
8
|
-
"arrow-spacing": "warn",
|
|
9
|
-
"comma-spacing": [ "warn", { "before": false, "after": true } ],
|
|
10
|
-
"comma-style": [ "warn", "last" ],
|
|
11
|
-
"computed-property-spacing": [ "warn", "never" ],
|
|
12
|
-
"eol-last": [ "warn", "always" ],
|
|
13
|
-
"indent": [ "warn", 2, {
|
|
14
|
-
"ImportDeclaration": "first",
|
|
15
|
-
"ObjectExpression": "first",
|
|
16
|
-
"VariableDeclarator": {
|
|
17
|
-
"var": 2,
|
|
18
|
-
"let": 2,
|
|
19
|
-
"const": 3 } } ],
|
|
20
|
-
"key-spacing": [ "warn", { "mode": "minimum" } ],
|
|
21
|
-
"linebreak-style": [ "error", "unix" ],
|
|
22
|
-
"no-extra-parens": "warn",
|
|
23
|
-
"no-multiple-empty-lines": [ "warn", { "max": 2, "maxEOF": 1 } ],
|
|
24
|
-
"no-multi-spaces": [ "warn", {
|
|
25
|
-
"ignoreEOLComments": true,
|
|
26
|
-
"exceptions": { "Property": false } } ],
|
|
27
|
-
"no-trailing-spaces": "warn",
|
|
28
|
-
"no-undef": "warn",
|
|
29
|
-
"no-unused-vars": [ "warn", {
|
|
30
|
-
"args": "all",
|
|
31
|
-
"varsIgnorePattern": "^_",
|
|
32
|
-
"argsIgnorePattern": "^_" } ],
|
|
33
|
-
|
|
34
|
-
"object-curly-newline": [ "warn", { "consistent": true } ],
|
|
35
|
-
"object-curly-spacing": [ "warn", "always" ],
|
|
36
|
-
"operator-linebreak": [ "warn", "before", {
|
|
37
|
-
"overrides": {
|
|
38
|
-
"=": "ignore" } } ],
|
|
39
|
-
"prefer-rest-params": "warn",
|
|
40
|
-
"quote-props": [ "warn", "as-needed" ],
|
|
41
|
-
"quotes": [ "warn", "single" ],
|
|
42
|
-
"semi": [ "warn", "never" ],
|
|
43
|
-
"sort-imports": "warn",
|
|
44
|
-
"space-before-function-paren": [ "warn", {
|
|
45
|
-
"anonymous": "never",
|
|
46
|
-
"asyncArrow": "always",
|
|
47
|
-
"named": "never" } ],
|
|
48
|
-
"spaced-comment": [ "warn", "always" ],
|
|
49
|
-
"space-in-parens": "warn",
|
|
50
|
-
"space-infix-ops": "warn" },
|
|
51
|
-
|
|
52
|
-
"globals": {
|
|
53
|
-
"process": "readonly",
|
|
54
|
-
"test": "readonly",
|
|
55
|
-
|
|
56
|
-
"apply": "readonly",
|
|
57
|
-
"bool": "readonly",
|
|
58
|
-
"deepMap": "readonly",
|
|
59
|
-
"each": "readonly",
|
|
60
|
-
"entries": "readonly",
|
|
61
|
-
"eq": "readonly",
|
|
62
|
-
"evaluate": "readonly",
|
|
63
|
-
"exists": "readonly",
|
|
64
|
-
"filter": "readonly",
|
|
65
|
-
"first": "readonly",
|
|
66
|
-
"globalize": "readonly",
|
|
67
|
-
"identity": "readonly",
|
|
68
|
-
"instance": "readonly",
|
|
69
|
-
"isArray": "readonly",
|
|
70
|
-
"isFunction": "readonly",
|
|
71
|
-
"join": "readonly",
|
|
72
|
-
"keys": "readonly",
|
|
73
|
-
"last": "readonly",
|
|
74
|
-
"length": "readonly",
|
|
75
|
-
"log": "readonly",
|
|
76
|
-
"omap": "readonly",
|
|
77
|
-
"omit": "readonly",
|
|
78
|
-
"partial": "readonly",
|
|
79
|
-
"push": "readonly",
|
|
80
|
-
"rest": "readonly",
|
|
81
|
-
"reverse": "readonly",
|
|
82
|
-
"slice": "readonly",
|
|
83
|
-
"split": "readonly",
|
|
84
|
-
"store": "readonly",
|
|
85
|
-
"sum": "readonly",
|
|
86
|
-
"type": "readonly",
|
|
87
|
-
"walk": "readonly",
|
|
88
|
-
|
|
89
|
-
"a": "readonly",
|
|
90
|
-
"abbr": "readonly",
|
|
91
|
-
"address": "readonly",
|
|
92
|
-
"area": "readonly",
|
|
93
|
-
"article": "readonly",
|
|
94
|
-
"aside": "readonly",
|
|
95
|
-
"audio": "readonly",
|
|
96
|
-
"b": "readonly",
|
|
97
|
-
"base": "readonly",
|
|
98
|
-
"bdi": "readonly",
|
|
99
|
-
"bdo": "readonly",
|
|
100
|
-
"blockquote": "readonly",
|
|
101
|
-
"body": "readonly",
|
|
102
|
-
"br": "readonly",
|
|
103
|
-
"button": "readonly",
|
|
104
|
-
"canvas": "readonly",
|
|
105
|
-
"caption": "readonly",
|
|
106
|
-
"cite": "readonly",
|
|
107
|
-
"code": "readonly",
|
|
108
|
-
"col": "readonly",
|
|
109
|
-
"colgroup": "readonly",
|
|
110
|
-
"data": "readonly",
|
|
111
|
-
"datalist": "readonly",
|
|
112
|
-
"dd": "readonly",
|
|
113
|
-
"del": "readonly",
|
|
114
|
-
"details": "readonly",
|
|
115
|
-
"dfn": "readonly",
|
|
116
|
-
"dialog": "readonly",
|
|
117
|
-
"div": "readonly",
|
|
118
|
-
"dl": "readonly",
|
|
119
|
-
"doctype": "readonly",
|
|
120
|
-
"dt": "readonly",
|
|
121
|
-
"el": "readonly",
|
|
122
|
-
"element": "readonly",
|
|
123
|
-
"em": "readonly",
|
|
124
|
-
"embed": "readonly",
|
|
125
|
-
"fieldset": "readonly",
|
|
126
|
-
"figcaption": "readonly",
|
|
127
|
-
"figure": "readonly",
|
|
128
|
-
"footer": "readonly",
|
|
129
|
-
"form": "readonly",
|
|
130
|
-
"fragment": "readonly",
|
|
131
|
-
"h1": "readonly",
|
|
132
|
-
"h2": "readonly",
|
|
133
|
-
"h3": "readonly",
|
|
134
|
-
"h4": "readonly",
|
|
135
|
-
"h5": "readonly",
|
|
136
|
-
"h6": "readonly",
|
|
137
|
-
"head": "readonly",
|
|
138
|
-
"header": "readonly",
|
|
139
|
-
"hgroup": "readonly",
|
|
140
|
-
"hr": "readonly",
|
|
141
|
-
"html": "readonly",
|
|
142
|
-
"i": "readonly",
|
|
143
|
-
"iframe": "readonly",
|
|
144
|
-
"img": "readonly",
|
|
145
|
-
"input": "readonly",
|
|
146
|
-
"ins": "readonly",
|
|
147
|
-
"kbd": "readonly",
|
|
148
|
-
"label": "readonly",
|
|
149
|
-
"legend": "readonly",
|
|
150
|
-
"li": "readonly",
|
|
151
|
-
"link": "readonly",
|
|
152
|
-
"main": "readonly",
|
|
153
|
-
"map": "readonly",
|
|
154
|
-
"mark": "readonly",
|
|
155
|
-
"menu": "readonly",
|
|
156
|
-
"meta": "readonly",
|
|
157
|
-
"meter": "readonly",
|
|
158
|
-
"nav": "readonly",
|
|
159
|
-
"noscript": "readonly",
|
|
160
|
-
"object": "readonly",
|
|
161
|
-
"ol": "readonly",
|
|
162
|
-
"optgroup": "readonly",
|
|
163
|
-
"option": "readonly",
|
|
164
|
-
"output": "readonly",
|
|
165
|
-
"p": "readonly",
|
|
166
|
-
"param": "readonly",
|
|
167
|
-
"picture": "readonly",
|
|
168
|
-
"pre": "readonly",
|
|
169
|
-
"progress": "readonly",
|
|
170
|
-
"q": "readonly",
|
|
171
|
-
"rp": "readonly",
|
|
172
|
-
"rt": "readonly",
|
|
173
|
-
"ruby": "readonly",
|
|
174
|
-
"s": "readonly",
|
|
175
|
-
"samp": "readonly",
|
|
176
|
-
"script": "readonly",
|
|
177
|
-
"section": "readonly",
|
|
178
|
-
"select": "readonly",
|
|
179
|
-
"slot": "readonly",
|
|
180
|
-
"small": "readonly",
|
|
181
|
-
"source": "readonly",
|
|
182
|
-
"span": "readonly",
|
|
183
|
-
"strong": "readonly",
|
|
184
|
-
"style": "readonly",
|
|
185
|
-
"sub": "readonly",
|
|
186
|
-
"summary": "readonly",
|
|
187
|
-
"sup": "readonly",
|
|
188
|
-
"table": "readonly",
|
|
189
|
-
"tbody": "readonly",
|
|
190
|
-
"td": "readonly",
|
|
191
|
-
"template": "readonly",
|
|
192
|
-
"textarea": "readonly",
|
|
193
|
-
"tfoot": "readonly",
|
|
194
|
-
"th": "readonly",
|
|
195
|
-
"thead": "readonly",
|
|
196
|
-
"time": "readonly",
|
|
197
|
-
"title": "readonly",
|
|
198
|
-
"tr": "readonly",
|
|
199
|
-
"track": "readonly",
|
|
200
|
-
"u": "readonly",
|
|
201
|
-
"ul": "readonly",
|
|
202
|
-
"var": "readonly",
|
|
203
|
-
"video": "readonly",
|
|
204
|
-
"wbr": "readonly" } }
|
|
205
|
-
|