Skip to content

Commit b6a400a

Browse files
authored
chore: add prettier (#8543)
1 parent 573acf9 commit b6a400a

File tree

1,093 files changed

+13915
-10485
lines changed

Some content is hidden

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

1,093 files changed

+13915
-10485
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: '@sveltejs',
3+
extends: ['@sveltejs', 'prettier'],
44
settings: {
55
'import/core-modules': [
66
'svelte',

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
with:
4545
node-version: 16
4646
cache: pnpm
47-
- run: 'pnpm i && pnpm lint'
47+
- run: 'pnpm i && pnpm format:check && pnpm lint'
4848
Unit:
4949
runs-on: ${{ matrix.os }}
5050
timeout-minutes: 10

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
!/elements
3+
!/scripts
4+
# TODO: after launch new site, format site dir.
5+
/site
6+
!/src
7+
src/compiler/compile/internal_exports.ts
8+
!/test
9+
/test/**/*.svelte
10+
/test/**/_expected*
11+
/test/**/_actual*
12+
/test/**/expected*
13+
/types

.prettierrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte"],
7+
"overrides": [
8+
{
9+
"files": ["*.svelte"],
10+
"options": {
11+
"bracketSameLine": false
12+
}
13+
},
14+
{
15+
"files": ["README.md", "packages/*/README.md"],
16+
"options": {
17+
"useTabs": false,
18+
"tabWidth": 2
19+
}
20+
}
21+
],
22+
"pluginSearchDirs": ["."]
23+
}

elements/index.d.ts

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ type Booleanish = boolean | 'true' | 'false';
3939
// Event Handler Types
4040
// ----------------------------------------------------------------------
4141

42-
type EventHandler<E extends Event = Event, T extends EventTarget = Element> =
43-
(event: E & { currentTarget: EventTarget & T}) => any;
42+
type EventHandler<E extends Event = Event, T extends EventTarget = Element> = (
43+
event: E & { currentTarget: EventTarget & T }
44+
) => any;
4445

4546
export type ClipboardEventHandler<T extends EventTarget> = EventHandler<ClipboardEvent, T>;
4647
export type CompositionEventHandler<T extends EventTarget> = EventHandler<CompositionEvent, T>;
@@ -196,7 +197,7 @@ export interface DOMAttributes<T extends EventTarget> {
196197
// Message Events
197198
'on:message'?: MessageEventHandler<T> | undefined | null;
198199
'on:messageerror'?: MessageEventHandler<T> | undefined | null;
199-
200+
200201
// Document Events
201202
'on:visibilitychange'?: EventHandler<Event, T> | undefined | null;
202203

@@ -350,7 +351,19 @@ export interface AriaAttributes {
350351
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
351352
* @see aria-atomic.
352353
*/
353-
'aria-relevant'?: 'additions' | 'additions removals' | 'additions text' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals' | undefined | null;
354+
'aria-relevant'?:
355+
| 'additions'
356+
| 'additions removals'
357+
| 'additions text'
358+
| 'all'
359+
| 'removals'
360+
| 'removals additions'
361+
| 'removals text'
362+
| 'text'
363+
| 'text additions'
364+
| 'text removals'
365+
| undefined
366+
| null;
354367
/** Indicates that user input is required on the element before a form may be submitted. */
355368
'aria-required'?: Booleanish | undefined | null;
356369
/** Defines a human-readable, author-localized description for the role of an element. */
@@ -470,14 +483,23 @@ export type AriaRole =
470483

471484
export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, DOMAttributes<T> {
472485
// Standard HTML Attributes
473-
accesskey?: string | undefined | null;
486+
accesskey?: string | undefined | null;
474487
autofocus?: boolean | undefined | null;
475488
class?: string | undefined | null;
476489
contenteditable?: Booleanish | 'inherit' | undefined | null;
477490
contextmenu?: string | undefined | null;
478491
dir?: string | undefined | null;
479492
draggable?: Booleanish | undefined | null;
480-
enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined | null;
493+
enterkeyhint?:
494+
| 'enter'
495+
| 'done'
496+
| 'go'
497+
| 'next'
498+
| 'previous'
499+
| 'search'
500+
| 'send'
501+
| undefined
502+
| null;
481503
hidden?: boolean | undefined | null;
482504
id?: string | undefined | null;
483505
lang?: string | undefined | null;
@@ -526,7 +548,17 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
526548
* Hints at the type of data that might be entered by the user while editing the element or its contents
527549
* @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
528550
*/
529-
inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' | undefined | null;
551+
inputmode?:
552+
| 'none'
553+
| 'text'
554+
| 'tel'
555+
| 'url'
556+
| 'email'
557+
| 'numeric'
558+
| 'decimal'
559+
| 'search'
560+
| undefined
561+
| null;
530562
/**
531563
* Specify that a standard HTML element should behave like a defined custom built-in element
532564
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
@@ -554,7 +586,16 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
554586
// SvelteKit
555587
'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null;
556588
'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null;
557-
'data-sveltekit-preload-code'?: true | '' | 'eager' | 'viewport' | 'hover' | 'tap' | 'off' | undefined | null;
589+
'data-sveltekit-preload-code'?:
590+
| true
591+
| ''
592+
| 'eager'
593+
| 'viewport'
594+
| 'hover'
595+
| 'tap'
596+
| 'off'
597+
| undefined
598+
| null;
558599
'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null;
559600
'data-sveltekit-reload'?: true | '' | 'off' | undefined | null;
560601
'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null;
@@ -563,12 +604,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
563604
[key: `data-${string}`]: any;
564605
}
565606

566-
export type HTMLAttributeAnchorTarget =
567-
| '_self'
568-
| '_blank'
569-
| '_parent'
570-
| '_top'
571-
| (string & {});
607+
export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});
572608

573609
export interface HTMLAnchorAttributes extends HTMLAttributes<HTMLAnchorElement> {
574610
download?: any;
@@ -844,7 +880,14 @@ export interface HTMLMenuAttributes extends HTMLAttributes<HTMLMenuElement> {
844880
export interface HTMLMediaAttributes<T extends HTMLMediaElement> extends HTMLAttributes<T> {
845881
autoplay?: boolean | undefined | null;
846882
controls?: boolean | undefined | null;
847-
controlslist?: 'nodownload' | 'nofullscreen' | 'noplaybackrate' | 'noremoteplayback' | (string & {}) | undefined | null;
883+
controlslist?:
884+
| 'nodownload'
885+
| 'nofullscreen'
886+
| 'noplaybackrate'
887+
| 'noremoteplayback'
888+
| (string & {})
889+
| undefined
890+
| null;
848891
crossorigin?: string | undefined | null;
849892
currenttime?: number | undefined | null;
850893
defaultmuted?: boolean | undefined | null;
@@ -1155,9 +1198,22 @@ export interface SVGAttributes<T extends EventTarget> extends AriaAttributes, DO
11551198
'accent-height'?: number | string | undefined | null;
11561199
accumulate?: 'none' | 'sum' | undefined | null;
11571200
additive?: 'replace' | 'sum' | undefined | null;
1158-
'alignment-baseline'?: 'auto' | 'baseline' | 'before-edge' | 'text-before-edge' | 'middle' |
1159-
'central' | 'after-edge' | 'text-after-edge' | 'ideographic' | 'alphabetic' | 'hanging' |
1160-
'mathematical' | 'inherit' | undefined | null;
1201+
'alignment-baseline'?:
1202+
| 'auto'
1203+
| 'baseline'
1204+
| 'before-edge'
1205+
| 'text-before-edge'
1206+
| 'middle'
1207+
| 'central'
1208+
| 'after-edge'
1209+
| 'text-after-edge'
1210+
| 'ideographic'
1211+
| 'alphabetic'
1212+
| 'hanging'
1213+
| 'mathematical'
1214+
| 'inherit'
1215+
| undefined
1216+
| null;
11611217
allowReorder?: 'no' | 'yes' | undefined | null;
11621218
alphabetic?: number | string | undefined | null;
11631219
amplitude?: number | string | undefined | null;
@@ -1604,15 +1660,27 @@ export interface SvelteHTMLElements {
16041660
'svelte:body': HTMLAttributes<HTMLElement>;
16051661
'svelte:fragment': { slot?: string };
16061662
'svelte:options': {
1607-
customElement?: string | undefined | {
1608-
tag: string;
1609-
shadow?: 'open' | 'none' | undefined;
1610-
props?: Record<string, { attribute?: string; reflect?: boolean; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object' }> | undefined;
1611-
};
1663+
customElement?:
1664+
| string
1665+
| undefined
1666+
| {
1667+
tag: string;
1668+
shadow?: 'open' | 'none' | undefined;
1669+
props?:
1670+
| Record<
1671+
string,
1672+
{
1673+
attribute?: string;
1674+
reflect?: boolean;
1675+
type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object';
1676+
}
1677+
>
1678+
| undefined;
1679+
};
16121680
immutable?: boolean | undefined;
16131681
accessors?: boolean | undefined;
16141682
namespace?: string | undefined;
1615-
[name: string]: any
1683+
[name: string]: any;
16161684
};
16171685
'svelte:head': { [name: string]: any };
16181686

elements/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"types": "./index.d.ts"
2+
"types": "./index.d.ts"
33
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
},
8282
"types": "types/runtime/index.d.ts",
8383
"scripts": {
84+
"format:fix": "prettier . --cache --plugin-search-dir=. --write",
85+
"format:check": "prettier . --cache --plugin-search-dir=. --check",
8486
"test": "npm run test:unit && npm run test:integration && echo \"manually check that there are no type errors in test/types by opening the files in there\"",
8587
"test:integration": "mocha --exit",
8688
"test:unit": "mocha --config .mocharc.unit.js --exit",
@@ -133,6 +135,7 @@
133135
"code-red": "^1.0.0",
134136
"css-tree": "^2.3.1",
135137
"eslint": "^8.35.0",
138+
"eslint-config-prettier": "^8.8.0",
136139
"eslint-plugin-import": "^2.27.5",
137140
"eslint-plugin-svelte3": "^4.0.0",
138141
"estree-walker": "^3.0.3",
@@ -143,6 +146,8 @@
143146
"magic-string": "^0.30.0",
144147
"mocha": "^10.2.0",
145148
"periscopic": "^3.1.0",
149+
"prettier": "^2.8.8",
150+
"prettier-plugin-svelte": "^2.10.0",
146151
"puppeteer": "^19.8.5",
147152
"rollup": "^3.20.2",
148153
"source-map": "^0.7.4",

pnpm-lock.yaml

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)