@vanilla-bean/components 1.0.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/Component/Component.js +598 -0
- package/Component/Component.scenarios.js +88 -0
- package/Component/Component.test.js +717 -0
- package/Component/README.md +455 -0
- package/Component/index.js +3 -0
- package/Component/observeElementConnection.js +52 -0
- package/Component/observeElementConnection.test.js +121 -0
- package/Elem/Elem.js +304 -0
- package/Elem/Elem.test.js +679 -0
- package/Elem/README.md +373 -0
- package/Elem/index.js +1 -0
- package/FontWithASyntaxHighlighter-Regular.woff2 +0 -0
- package/LICENSE +21 -0
- package/README.md +413 -0
- package/components/BottomSheet/BottomSheet.js +192 -0
- package/components/BottomSheet/BottomSheet.lld.md +25 -0
- package/components/BottomSheet/README.md +66 -0
- package/components/BottomSheet/index.js +1 -0
- package/components/Button/Button.js +53 -0
- package/components/Button/Button.lld.md +21 -0
- package/components/Button/index.js +1 -0
- package/components/Calendar/Calendar.js +720 -0
- package/components/Calendar/Calendar.lld.md +22 -0
- package/components/Calendar/CalendarEvent.js +102 -0
- package/components/Calendar/Toolbar.js +78 -0
- package/components/Calendar/index.js +2 -0
- package/components/Calendar/utils.js +56 -0
- package/components/Code/Code.js +84 -0
- package/components/Code/Code.lld.md +21 -0
- package/components/Code/index.js +1 -0
- package/components/ColorPicker/ColorPicker.js +445 -0
- package/components/ColorPicker/ColorPicker.lld.md +21 -0
- package/components/ColorPicker/index.js +1 -0
- package/components/ColorPicker/svg.js +5 -0
- package/components/Dialog/Dialog.js +278 -0
- package/components/Dialog/Dialog.lld.md +20 -0
- package/components/Dialog/README.md +96 -0
- package/components/Dialog/index.js +1 -0
- package/components/Form/Form.js +257 -0
- package/components/Form/Form.lld.md +21 -0
- package/components/Form/README.md +87 -0
- package/components/Form/index.js +1 -0
- package/components/Icon/Icon.js +54 -0
- package/components/Icon/Icon.lld.md +21 -0
- package/components/Icon/index.js +1 -0
- package/components/Input/Input.js +173 -0
- package/components/Input/Input.lld.md +28 -0
- package/components/Input/README.md +97 -0
- package/components/Input/index.js +2 -0
- package/components/Input/utils.js +122 -0
- package/components/Keyboard/Key.js +38 -0
- package/components/Keyboard/Keyboard.js +173 -0
- package/components/Keyboard/Keyboard.lld.md +21 -0
- package/components/Keyboard/index.js +1 -0
- package/components/Label/Label.js +214 -0
- package/components/Label/Label.lld.md +20 -0
- package/components/Label/index.js +1 -0
- package/components/Link/Link.js +43 -0
- package/components/Link/Link.lld.md +15 -0
- package/components/Link/index.js +1 -0
- package/components/List/List.js +82 -0
- package/components/List/List.lld.md +19 -0
- package/components/List/index.js +1 -0
- package/components/Menu/Menu.js +93 -0
- package/components/Menu/Menu.lld.md +15 -0
- package/components/Menu/index.js +1 -0
- package/components/Notify/Notify.js +96 -0
- package/components/Notify/Notify.lld.md +20 -0
- package/components/Notify/index.js +1 -0
- package/components/Page/Page.js +67 -0
- package/components/Page/Page.lld.md +20 -0
- package/components/Page/index.js +1 -0
- package/components/Popover/Popover.js +175 -0
- package/components/Popover/Popover.lld.md +19 -0
- package/components/Popover/index.js +1 -0
- package/components/RadioButton/RadioButton.js +108 -0
- package/components/RadioButton/RadioButton.lld.md +15 -0
- package/components/RadioButton/index.js +1 -0
- package/components/Router/README.md +160 -0
- package/components/Router/Router.js +150 -0
- package/components/Router/Router.lld.md +31 -0
- package/components/Router/View.js +15 -0
- package/components/Router/index.js +2 -0
- package/components/Router/utils.js +17 -0
- package/components/Select/README.md +88 -0
- package/components/Select/Select.js +74 -0
- package/components/Select/Select.lld.md +20 -0
- package/components/Select/index.js +1 -0
- package/components/Table/README.md +94 -0
- package/components/Table/Table.js +171 -0
- package/components/Table/Table.lld.md +21 -0
- package/components/Table/index.js +1 -0
- package/components/TagList/Tag.js +84 -0
- package/components/TagList/TagList.js +118 -0
- package/components/TagList/TagList.lld.md +30 -0
- package/components/TagList/design.excalidraw.png +0 -0
- package/components/TagList/index.js +2 -0
- package/components/Tooltip/Tooltip.js +139 -0
- package/components/Tooltip/Tooltip.lld.md +22 -0
- package/components/Tooltip/index.js +1 -0
- package/components/TooltipWrapper/TooltipWrapper.js +89 -0
- package/components/TooltipWrapper/TooltipWrapper.lld.md +21 -0
- package/components/TooltipWrapper/index.js +1 -0
- package/components/Whiteboard/Whiteboard.js +198 -0
- package/components/Whiteboard/Whiteboard.lld.md +35 -0
- package/components/Whiteboard/index.js +1 -0
- package/components/index.js +27 -0
- package/eslint.config.cjs +118 -0
- package/index.d.ts +635 -0
- package/index.js +19 -0
- package/package.json +123 -0
- package/plugins/asText.js +38 -0
- package/plugins/loadPlugins.js +5 -0
- package/plugins/markdownLoader.js +121 -0
- package/prettier.config.cjs +7 -0
- package/spellcheck.config.cjs +227 -0
- package/styled/README.md +329 -0
- package/styled/appendStyles.js +26 -0
- package/styled/appendStyles.test.js +45 -0
- package/styled/index.js +4 -0
- package/styled/shimCSS.js +31 -0
- package/styled/shimCSS.test.js +103 -0
- package/styled/styled.js +91 -0
- package/styled/styled.test.js +586 -0
- package/styled/themeStyles.js +36 -0
- package/styled/themeStyles.test.js +135 -0
- package/test-setup.js +123 -0
- package/theme/.test.js +69 -0
- package/theme/README.md +607 -0
- package/theme/button.js +100 -0
- package/theme/code.js +123 -0
- package/theme/colors.js +42 -0
- package/theme/fonts.js +42 -0
- package/theme/index.js +33 -0
- package/theme/input.js +64 -0
- package/theme/page.js +208 -0
- package/theme/scrollbar.js +24 -0
- package/theme/table.js +53 -0
- package/utils/README.md +176 -0
- package/utils/browser.js +92 -0
- package/utils/class.js +30 -0
- package/utils/color.js +81 -0
- package/utils/data.js +164 -0
- package/utils/element.js +55 -0
- package/utils/index.js +7 -0
- package/utils/rand.js +12 -0
- package/utils/string.js +72 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TooltipWrapper
|
|
2
|
+
|
|
3
|
+
> ./TooltipWrapper.js
|
|
4
|
+
|
|
5
|
+
Component that adds a tooltip to whatever it wraps. The Tooltip is created during the first `_setOption('tooltip', ...)` call, which runs during render, so it exists after construction but is only shown on hover after a 700ms delay.
|
|
6
|
+
|
|
7
|
+
## The tooltip exists after construction with a tooltip option
|
|
8
|
+
|
|
9
|
+
- the Tooltip component is created when the `tooltip` option is processed during render; after construction it exists as `this._tooltip`
|
|
10
|
+
- does the Tooltip component exist after construction with a tooltip option?
|
|
11
|
+
|
|
12
|
+
## Hover shows after a delay — brief mouse-overs do not trigger the tooltip
|
|
13
|
+
|
|
14
|
+
- pointerover registers a 700ms timer; pointerout cancels it and hides immediately; hovering for longer than 700ms shows the tooltip
|
|
15
|
+
- does hovering for longer than 700ms show the tooltip?
|
|
16
|
+
- does leaving before 700ms prevent the tooltip from appearing?
|
|
17
|
+
|
|
18
|
+
## Cleanup removes the tooltip element — nothing outlives the component
|
|
19
|
+
|
|
20
|
+
- when the TooltipWrapper is destroyed, the Tooltip component is also destroyed and removed from the DOM
|
|
21
|
+
- does destroying the wrapper also remove the tooltip from the DOM?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TooltipWrapper } from './TooltipWrapper';
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { throttle } from '../../utils/data';
|
|
2
|
+
import { Component } from '../../Component';
|
|
3
|
+
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
tag: 'canvas',
|
|
6
|
+
background: '#FFF',
|
|
7
|
+
color: '#000',
|
|
8
|
+
lineWidth: 3,
|
|
9
|
+
width: '200px',
|
|
10
|
+
height: '200px',
|
|
11
|
+
readOnly: false,
|
|
12
|
+
registeredEvents: new Set(['line', 'draw']),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Interactive drawing canvas component with multi-touch support and line rendering.
|
|
17
|
+
*
|
|
18
|
+
* Provides a drawing surface with pointer event handling, configurable drawing settings,
|
|
19
|
+
* and the ability to render predefined lines. Supports multiple simultaneous drawing pointers.
|
|
20
|
+
* @param {object} [options={}] - Whiteboard configuration options
|
|
21
|
+
* @param {string} [options.tag='canvas'] - HTML tag, uses canvas element
|
|
22
|
+
* @param {string} [options.background='#FFF'] - Canvas background color
|
|
23
|
+
* @param {string} [options.color='#000'] - Default drawing color
|
|
24
|
+
* @param {number} [options.lineWidth=3] - Default line width for drawing
|
|
25
|
+
* @param {string} [options.width='200px'] - Canvas width
|
|
26
|
+
* @param {string} [options.height='200px'] - Canvas height
|
|
27
|
+
* @param {boolean} [options.readOnly=false] - Whether drawing is disabled
|
|
28
|
+
* @param {Array<object>} [options.lines] - Predefined lines to render on the canvas
|
|
29
|
+
* @param {number} [options.drawThrottle] - Custom throttle delay for draw events
|
|
30
|
+
* @param {...(Component|HTMLElement|string)} children - Child elements to append
|
|
31
|
+
* @returns {Whiteboard} Whiteboard component instance
|
|
32
|
+
*/
|
|
33
|
+
export default class Whiteboard extends Component {
|
|
34
|
+
defaultOptions = { ...super.defaultOptions, ...defaultOptions };
|
|
35
|
+
|
|
36
|
+
constructor(options = {}, ...children) {
|
|
37
|
+
super(
|
|
38
|
+
{
|
|
39
|
+
...defaultOptions,
|
|
40
|
+
...options,
|
|
41
|
+
style: {
|
|
42
|
+
cursor: 'crosshair',
|
|
43
|
+
touchAction: 'none',
|
|
44
|
+
borderRadius: '3px',
|
|
45
|
+
...options.style,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
...children,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
build() {
|
|
53
|
+
this.canvas = this.elem.getContext('2d');
|
|
54
|
+
|
|
55
|
+
this.pointers = {};
|
|
56
|
+
|
|
57
|
+
const boundInteractionInit = this.interactionInit.bind(this);
|
|
58
|
+
this.elem.addEventListener('pointerdown', boundInteractionInit);
|
|
59
|
+
this.replaceCleanup('pointerdown', () => this.elem.removeEventListener('pointerdown', boundInteractionInit));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static handlers = {
|
|
63
|
+
width(value) {
|
|
64
|
+
this.elem.width = Number.parseInt(value);
|
|
65
|
+
this.elem.style.width = value;
|
|
66
|
+
},
|
|
67
|
+
height(value) {
|
|
68
|
+
this.elem.height = Number.parseInt(value);
|
|
69
|
+
this.elem.style.height = value;
|
|
70
|
+
},
|
|
71
|
+
lines(value) {
|
|
72
|
+
value.forEach(line => this.drawLine(line));
|
|
73
|
+
},
|
|
74
|
+
background(value) {
|
|
75
|
+
this.elem.style.background = value;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
getPosition({ offsetX, offsetY }) {
|
|
80
|
+
return { x: offsetX.toFixed(3), y: offsetY.toFixed(3) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interactionInit(event) {
|
|
84
|
+
if (this.options.readOnly) return;
|
|
85
|
+
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
|
|
88
|
+
const { pointerId } = event;
|
|
89
|
+
const { x, y } = this.getPosition(event);
|
|
90
|
+
|
|
91
|
+
this.pointers[pointerId] = { x, y, line: [{ x, y }] };
|
|
92
|
+
|
|
93
|
+
this.activePointerCount = Object.values(this.pointers).filter(_ => !!_).length;
|
|
94
|
+
|
|
95
|
+
if (this.pointerInteracting) return;
|
|
96
|
+
|
|
97
|
+
this.pointers[pointerId].initiator = true;
|
|
98
|
+
this.pointerInteracting = true;
|
|
99
|
+
|
|
100
|
+
const move = throttle(
|
|
101
|
+
(event => {
|
|
102
|
+
if (this.options.readOnly || !this.pointers[event.pointerId]) return;
|
|
103
|
+
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
|
|
106
|
+
this.drawEvent.call(this, event);
|
|
107
|
+
}).bind(this),
|
|
108
|
+
this.options.drawThrottle || Math.max(Math.min(this.options.lineWidth + 3, 24), 6),
|
|
109
|
+
);
|
|
110
|
+
const removePointer = event => {
|
|
111
|
+
if (!this.pointers[event.pointerId]) return;
|
|
112
|
+
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
|
|
115
|
+
this.emit('line', {
|
|
116
|
+
event,
|
|
117
|
+
color: this.options.color,
|
|
118
|
+
width: this.options.lineWidth,
|
|
119
|
+
line: this.pointers[event.pointerId].line,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (this.pointers[event.pointerId].line.length === 0) this.drawEvent(event, true);
|
|
123
|
+
|
|
124
|
+
delete this.pointers[event.pointerId];
|
|
125
|
+
this.activePointerCount = Object.values(this.pointers).filter(_ => !!_).length;
|
|
126
|
+
|
|
127
|
+
if (this.activePointerCount === 0) {
|
|
128
|
+
this.pointerInteracting = false;
|
|
129
|
+
|
|
130
|
+
document.removeEventListener('pointermove', move);
|
|
131
|
+
document.removeEventListener('pointerup', removePointer);
|
|
132
|
+
document.removeEventListener('pointerleave', removePointer);
|
|
133
|
+
document.removeEventListener('pointercancel', removePointer);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
document.addEventListener('pointermove', move);
|
|
138
|
+
document.addEventListener('pointerup', removePointer);
|
|
139
|
+
document.addEventListener('pointerleave', removePointer);
|
|
140
|
+
document.addEventListener('pointercancel', removePointer);
|
|
141
|
+
|
|
142
|
+
this.replaceCleanup('gestureListeners', () => {
|
|
143
|
+
document.removeEventListener('pointermove', move);
|
|
144
|
+
document.removeEventListener('pointerup', removePointer);
|
|
145
|
+
document.removeEventListener('pointerleave', removePointer);
|
|
146
|
+
document.removeEventListener('pointercancel', removePointer);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
drawEvent(event, cap = false) {
|
|
151
|
+
const { pointerId } = event;
|
|
152
|
+
|
|
153
|
+
if (!this.pointers[pointerId]) return;
|
|
154
|
+
|
|
155
|
+
const to = this.getPosition(event);
|
|
156
|
+
const { x, y } = this.pointers[pointerId];
|
|
157
|
+
const from = { x, y };
|
|
158
|
+
|
|
159
|
+
this.drawLine({ color: this.options.color, width: this.options.lineWidth, line: [from, to], cap });
|
|
160
|
+
|
|
161
|
+
this.pointers[pointerId].line.push(to);
|
|
162
|
+
|
|
163
|
+
this.emit('draw', { event, cap, from, to });
|
|
164
|
+
|
|
165
|
+
this.pointers[pointerId].x = to.x;
|
|
166
|
+
this.pointers[pointerId].y = to.y;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Draws a line on the canvas with specified properties.
|
|
171
|
+
* @param {object} options - Line drawing options
|
|
172
|
+
* @param {string} options.color - Line color
|
|
173
|
+
* @param {number} options.width - Line width
|
|
174
|
+
* @param {Array<object>} options.line - Array of {x, y} points defining the line
|
|
175
|
+
* @param {boolean} [options.cap] - Whether to close the path after drawing
|
|
176
|
+
*/
|
|
177
|
+
drawLine({ color, width, line, cap = true }) {
|
|
178
|
+
if (line.length === 0) return;
|
|
179
|
+
|
|
180
|
+
this.canvas.strokeStyle = color;
|
|
181
|
+
this.canvas.lineWidth = width;
|
|
182
|
+
this.canvas.lineJoin = 'round';
|
|
183
|
+
this.canvas.lineCap = 'round';
|
|
184
|
+
|
|
185
|
+
this.canvas.beginPath();
|
|
186
|
+
this.canvas.moveTo(line[0].x, line[0].y);
|
|
187
|
+
line.forEach(({ x, y }) => this.canvas.lineTo(x, y));
|
|
188
|
+
this.canvas.stroke();
|
|
189
|
+
if (cap) this.canvas.closePath();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Clears the entire canvas.
|
|
194
|
+
*/
|
|
195
|
+
clearCanvas() {
|
|
196
|
+
this.canvas.clearRect(0, 0, this.elem.width, this.elem.height);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Whiteboard
|
|
2
|
+
|
|
3
|
+
> ./Whiteboard.js
|
|
4
|
+
|
|
5
|
+
Multi-touch drawing canvas that tracks each pointer independently. The design decision: draw throttle adapts to brush size; thicker lines need fewer intermediate points to look smooth, so the throttle rate derives from `lineWidth` rather than being a fixed value.
|
|
6
|
+
|
|
7
|
+
## Each pointer draws an independent line
|
|
8
|
+
|
|
9
|
+
- two simultaneous touches produce two independent strokes; neither interferes with the other
|
|
10
|
+
- the whiteboard tracks each active pointer by its ID
|
|
11
|
+
- does a second finger touching the canvas start a separate line from the first?
|
|
12
|
+
|
|
13
|
+
## Draw throttle rate adapts to line width — no separate configuration needed
|
|
14
|
+
|
|
15
|
+
- the throttle delay is derived from `lineWidth + 3` (clamped to a range); thicker lines are visually coarser and tolerate a longer delay
|
|
16
|
+
- callers set `lineWidth` and the draw rate adjusts automatically; they do not configure throttle separately
|
|
17
|
+
- explicitly setting `drawThrottle` overrides the derived rate when the default does not fit the use case
|
|
18
|
+
|
|
19
|
+
## Completed strokes are emitted as complete lines, not as individual points
|
|
20
|
+
|
|
21
|
+
- when a pointer lifts, the full array of points recorded during that stroke is emitted as a line event
|
|
22
|
+
- callers receive whole lines for persistence or replay, not a stream of coordinate events
|
|
23
|
+
- does lifting a pointer emit all the points recorded during that stroke?
|
|
24
|
+
|
|
25
|
+
## readOnly prevents new strokes without clearing the canvas
|
|
26
|
+
|
|
27
|
+
- existing content remains visible; only new pointer interactions are blocked
|
|
28
|
+
- the whiteboard is non-destructive in read-only mode; content survives the mode switch
|
|
29
|
+
- does enabling readOnly prevent a new stroke from starting while preserving existing content?
|
|
30
|
+
|
|
31
|
+
## clearCanvas wipes content without removing the element
|
|
32
|
+
|
|
33
|
+
- `clearCanvas()` clears the 2D context and resets stroke state
|
|
34
|
+
- the canvas element itself remains in the DOM, reusable for new drawing
|
|
35
|
+
- does clearCanvas produce a blank canvas without removing it from the page?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Whiteboard } from './Whiteboard';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* This file is automatically managed (bun build:index) (updateComponentIndex.js), do not edit by hand */
|
|
2
|
+
|
|
3
|
+
export * from './BottomSheet';
|
|
4
|
+
export * from './Button';
|
|
5
|
+
export * from './Calendar';
|
|
6
|
+
export * from './Code';
|
|
7
|
+
export * from './ColorPicker';
|
|
8
|
+
export * from './Dialog';
|
|
9
|
+
export * from './Form';
|
|
10
|
+
export * from './Icon';
|
|
11
|
+
export * from './Input';
|
|
12
|
+
export * from './Keyboard';
|
|
13
|
+
export * from './Label';
|
|
14
|
+
export * from './Link';
|
|
15
|
+
export * from './List';
|
|
16
|
+
export * from './Menu';
|
|
17
|
+
export * from './Notify';
|
|
18
|
+
export * from './Page';
|
|
19
|
+
export * from './Popover';
|
|
20
|
+
export * from './RadioButton';
|
|
21
|
+
export * from './Router';
|
|
22
|
+
export * from './Select';
|
|
23
|
+
export * from './Table';
|
|
24
|
+
export * from './TagList';
|
|
25
|
+
export * from './Tooltip';
|
|
26
|
+
export * from './TooltipWrapper';
|
|
27
|
+
export * from './Whiteboard';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const globals = require('globals');
|
|
2
|
+
const { fixupConfigRules, fixupPluginRules } = require('@eslint/compat');
|
|
3
|
+
const js = require('@eslint/js');
|
|
4
|
+
const jsdoc = require('eslint-plugin-jsdoc');
|
|
5
|
+
|
|
6
|
+
const compat = require('eslint-plugin-compat');
|
|
7
|
+
const importPlugin = require('eslint-plugin-import');
|
|
8
|
+
const spellcheck = require('eslint-plugin-spellcheck');
|
|
9
|
+
const testingLibrary = require('eslint-plugin-testing-library');
|
|
10
|
+
const writeGoodComments = require('eslint-plugin-write-good-comments');
|
|
11
|
+
|
|
12
|
+
module.exports = [
|
|
13
|
+
{
|
|
14
|
+
ignores: ['**/node_modules', '**/build', '**/.claude'],
|
|
15
|
+
},
|
|
16
|
+
js.configs.recommended,
|
|
17
|
+
jsdoc.configs['flat/recommended'],
|
|
18
|
+
...fixupConfigRules(compat.configs['flat/recommended']),
|
|
19
|
+
{
|
|
20
|
+
languageOptions: {
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
globals: globals.builtin,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
|
|
28
|
+
plugins: {
|
|
29
|
+
import: importPlugin,
|
|
30
|
+
'write-good-comments': writeGoodComments,
|
|
31
|
+
spellcheck,
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
'no-console': 'warn',
|
|
35
|
+
'no-nested-ternary': 'error',
|
|
36
|
+
'no-var': 'error',
|
|
37
|
+
'prefer-const': 'error',
|
|
38
|
+
'comma-dangle': ['error', 'only-multiline'],
|
|
39
|
+
'no-async-promise-executor': 'off',
|
|
40
|
+
'no-prototype-builtins': 'off',
|
|
41
|
+
|
|
42
|
+
// TODO This rule doesn't work after updating to eslint 9
|
|
43
|
+
// https://github.com/import-js/eslint-plugin-import/pull/2829
|
|
44
|
+
// 'import/no-unused-modules': [1, { unusedExports: true }],
|
|
45
|
+
|
|
46
|
+
'import/no-unresolved': [1, { ignore: ['bun', 'bun:test', String.raw`\.asText$`] }],
|
|
47
|
+
'import/no-useless-path-segments': 'error',
|
|
48
|
+
'import/first': 'warn',
|
|
49
|
+
'import/order': 'warn',
|
|
50
|
+
|
|
51
|
+
'write-good-comments/write-good-comments': 'off',
|
|
52
|
+
|
|
53
|
+
'spellcheck/spell-checker': ['warn', require('./spellcheck.config.cjs')],
|
|
54
|
+
'jsdoc/no-undefined-types': ['warn', { definedTypes: ['Component', 'TemplateStringsArray'] }],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
files: ['**/*.js', '**/*.mjs'],
|
|
59
|
+
languageOptions: {
|
|
60
|
+
globals: {
|
|
61
|
+
...globals.browser,
|
|
62
|
+
process: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
files: ['**/*.cjs'],
|
|
68
|
+
languageOptions: {
|
|
69
|
+
globals: globals.node,
|
|
70
|
+
},
|
|
71
|
+
rules: {
|
|
72
|
+
'no-console': 'off',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
files: ['**/demo.js', 'demo/*', 'demo/**/*'],
|
|
77
|
+
rules: {
|
|
78
|
+
'no-console': 'off',
|
|
79
|
+
'jsdoc/require-jsdoc': 'off',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
files: ['demo/server.js', 'devTools/*', 'plugins/*'],
|
|
84
|
+
languageOptions: {
|
|
85
|
+
globals: {
|
|
86
|
+
...globals.node,
|
|
87
|
+
Bun: false,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
rules: {
|
|
91
|
+
'no-console': 'off',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
files: ['test-setup.js', '**/*.test.js', 'components/**/.test.js'],
|
|
96
|
+
languageOptions: {
|
|
97
|
+
globals: {
|
|
98
|
+
...globals.browser,
|
|
99
|
+
...globals.node,
|
|
100
|
+
...globals.jest,
|
|
101
|
+
Bun: false,
|
|
102
|
+
container: false,
|
|
103
|
+
mock: true,
|
|
104
|
+
spyOn: true,
|
|
105
|
+
setSystemTime: true,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
plugins: {
|
|
109
|
+
'testing-library': fixupPluginRules({ rules: testingLibrary.rules }),
|
|
110
|
+
},
|
|
111
|
+
rules: {
|
|
112
|
+
...testingLibrary.configs.dom.rules,
|
|
113
|
+
'no-console': 'off',
|
|
114
|
+
'testing-library/prefer-screen-queries': 'off',
|
|
115
|
+
'compat/compat': 'off',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
];
|