Skip to content

Commit 504a094

Browse files
Add prettier (#36)
* Add prettier * Add scss to formatted files * format Co-authored-by: Paco <34928425+pacocoursey@users.noreply.github.com>
1 parent cb87e6b commit 504a094

File tree

21 files changed

+292
-279
lines changed

21 files changed

+292
-279
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
- uses: actions/setup-node@v3
1616
- run: npm install pnpm -g
1717
- run: pnpm install
18-
- run: pnpm playwright install --with-deps
1918
- run: pnpm build
19+
- run: pnpm test:format
20+
- run: pnpm playwright install --with-deps
2021
- run: pnpm test
2122
- name: Upload test results
2223
if: always()

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.next
2+
dist
3+
pnpm-lock.yaml
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
useTabs: false,
3-
semi: true,
4-
trailingComma: "all",
2+
semi: false,
53
singleQuote: true,
4+
tabWidth: 2,
5+
trailingComma: 'all',
66
printWidth: 120,
7-
};
7+
}

cmdk/src/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const Command = React.forwardRef<HTMLDivElement, CommandProps>((props, forwarded
272272
inputId,
273273
labelId,
274274
}),
275-
[]
275+
[],
276276
)
277277

278278
function score(value: string) {
@@ -568,7 +568,7 @@ const Item = React.forwardRef<HTMLDivElement, ItemProps>((props, forwardedRef) =
568568
const store = useStore()
569569
const selected = useCmdk((state) => state.value && state.value === value.current)
570570
const render = useCmdk((state) =>
571-
context.filter() === false ? true : !state.search ? true : state.filtered.items.get(id) > 0
571+
context.filter() === false ? true : !state.search ? true : state.filtered.items.get(id) > 0,
572572
)
573573

574574
React.useEffect(() => {
@@ -617,7 +617,9 @@ const Group = React.forwardRef<HTMLDivElement, GroupProps>((props, forwardedRef)
617617
const headingRef = React.useRef<HTMLDivElement>(null)
618618
const headingId = React.useId()
619619
const context = useCommand()
620-
const render = useCmdk((state) => context.filter() === false ? true : (!state.search ? true : state.filtered.groups.has(id)))
620+
const render = useCmdk((state) =>
621+
context.filter() === false ? true : !state.search ? true : state.filtered.groups.has(id),
622+
)
621623

622624
useLayoutEffect(() => {
623625
return context.group(id)
@@ -884,7 +886,7 @@ function useCmdk<T = any>(selector: (state: State) => T) {
884886
function useValue(
885887
id: string,
886888
ref: React.RefObject<HTMLElement>,
887-
deps: (string | React.ReactNode | React.RefObject<HTMLElement>)[]
889+
deps: (string | React.ReactNode | React.RefObject<HTMLElement>)[],
888890
) {
889891
const valueRef = React.useRef<string>()
890892
const context = useCommand()

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"dev": "pnpm -F cmdk build --watch",
77
"website": "pnpm -F cmdk-website dev",
88
"testsite": "pnpm -F cmdk-tests dev",
9+
"format": "prettier '**/*.{js,jsx,ts,tsx,json,md,mdx,css,scss,yaml,yml}' --write",
10+
"test:format": "prettier '**/*.{js,jsx,ts,tsx,json,md,mdx,css,scss,yaml,yml}' --check",
911
"test": "playwright test"
1012
},
1113
"devDependencies": {
1214
"@playwright/test": "1.24.1",
1315
"tsup": "6.2.1",
14-
"typescript": "4.6.4"
16+
"typescript": "4.6.4",
17+
"prettier": "2.7.1"
1518
},
1619
"packageManager": "pnpm@7.9.0"
1720
}

pnpm-lock.yaml

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

website/components/cmdk/framer.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Command } from 'cmdk';
2-
import React from 'react';
1+
import { Command } from 'cmdk'
2+
import React from 'react'
33

44
export function FramerCMDK() {
5-
const [value, setValue] = React.useState('button');
5+
const [value, setValue] = React.useState('button')
66
return (
77
<div className="framer">
88
<Command value={value} onValueChange={(v) => setValue(v)}>
@@ -51,19 +51,19 @@ export function FramerCMDK() {
5151
</Command.List>
5252
</Command>
5353
</div>
54-
);
54+
)
5555
}
5656

5757
function Button() {
58-
return <button>Primary</button>;
58+
return <button>Primary</button>
5959
}
6060

6161
function Input() {
62-
return <input type="text" placeholder="Placeholder" />;
62+
return <input type="text" placeholder="Placeholder" />
6363
}
6464

6565
function Badge() {
66-
return <div cmdk-framer-badge="">Badge</div>;
66+
return <div cmdk-framer-badge="">Badge</div>
6767
}
6868

6969
function Radio() {
@@ -72,23 +72,23 @@ function Radio() {
7272
<input type="radio" defaultChecked />
7373
Radio Button
7474
</label>
75-
);
75+
)
7676
}
7777

7878
function Slider() {
7979
return (
8080
<div cmdk-framer-slider="">
8181
<div />
8282
</div>
83-
);
83+
)
8484
}
8585

8686
function Avatar() {
87-
return <img src="/rauno.jpeg" alt="Avatar of Rauno" />;
87+
return <img src="/rauno.jpeg" alt="Avatar of Rauno" />
8888
}
8989

9090
function Container() {
91-
return <div cmdk-framer-container="" />;
91+
return <div cmdk-framer-container="" />
9292
}
9393

9494
function Item({ children, value, subtitle }: { children: React.ReactNode; value: string; subtitle: string }) {
@@ -100,7 +100,7 @@ function Item({ children, value, subtitle }: { children: React.ReactNode; value:
100100
<span cmdk-framer-item-subtitle="">{subtitle}</span>
101101
</div>
102102
</Command.Item>
103-
);
103+
)
104104
}
105105

106106
function ButtonIcon() {
@@ -113,7 +113,7 @@ function ButtonIcon() {
113113
clipRule="evenodd"
114114
></path>
115115
</svg>
116-
);
116+
)
117117
}
118118

119119
function InputIcon() {
@@ -126,7 +126,7 @@ function InputIcon() {
126126
clipRule="evenodd"
127127
></path>
128128
</svg>
129-
);
129+
)
130130
}
131131

132132
function RadioIcon() {
@@ -139,7 +139,7 @@ function RadioIcon() {
139139
clipRule="evenodd"
140140
></path>
141141
</svg>
142-
);
142+
)
143143
}
144144

145145
function BadgeIcon() {
@@ -152,7 +152,7 @@ function BadgeIcon() {
152152
clipRule="evenodd"
153153
></path>
154154
</svg>
155-
);
155+
)
156156
}
157157

158158
function ToggleIcon() {
@@ -165,7 +165,7 @@ function ToggleIcon() {
165165
clipRule="evenodd"
166166
></path>
167167
</svg>
168-
);
168+
)
169169
}
170170

171171
function AvatarIcon() {
@@ -178,7 +178,7 @@ function AvatarIcon() {
178178
clipRule="evenodd"
179179
></path>
180180
</svg>
181-
);
181+
)
182182
}
183183

184184
function ContainerIcon() {
@@ -191,7 +191,7 @@ function ContainerIcon() {
191191
clipRule="evenodd"
192192
></path>
193193
</svg>
194-
);
194+
)
195195
}
196196

197197
function SearchIcon() {
@@ -206,7 +206,7 @@ function SearchIcon() {
206206
>
207207
<path strokeLinecap="round" strokeLinejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
208208
</svg>
209-
);
209+
)
210210
}
211211

212212
function SliderIcon() {
@@ -219,5 +219,5 @@ function SliderIcon() {
219219
clipRule="evenodd"
220220
></path>
221221
</svg>
222-
);
222+
)
223223
}

website/components/cmdk/linear.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Command } from 'cmdk';
1+
import { Command } from 'cmdk'
22

33
export function LinearCMDK() {
44
return (
@@ -15,16 +15,16 @@ export function LinearCMDK() {
1515
{label}
1616
<div cmdk-linear-shortcuts="">
1717
{shortcut.map((key) => {
18-
return <kbd key={key}>{key}</kbd>;
18+
return <kbd key={key}>{key}</kbd>
1919
})}
2020
</div>
2121
</Command.Item>
22-
);
22+
)
2323
})}
2424
</Command.List>
2525
</Command>
2626
</div>
27-
);
27+
)
2828
}
2929

3030
const items = [
@@ -63,14 +63,14 @@ const items = [
6363
label: 'Set due date...',
6464
shortcut: ['⇧', 'D'],
6565
},
66-
];
66+
]
6767

6868
function AssignToIcon() {
6969
return (
7070
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
7171
<path d="M7 7a2.5 2.5 0 10.001-4.999A2.5 2.5 0 007 7zm0 1c-1.335 0-4 .893-4 2.667v.666c0 .367.225.667.5.667h2.049c.904-.909 2.417-1.911 4.727-2.009v-.72a.27.27 0 01.007-.063C9.397 8.404 7.898 8 7 8zm4.427 2.028a.266.266 0 01.286.032l2.163 1.723a.271.271 0 01.013.412l-2.163 1.97a.27.27 0 01-.452-.2v-.956c-3.328.133-5.282 1.508-5.287 1.535a.27.27 0 01-.266.227h-.022a.27.27 0 01-.249-.271c0-.046 1.549-3.328 5.824-3.509v-.72a.27.27 0 01.153-.243z" />
7272
</svg>
73-
);
73+
)
7474
}
7575

7676
function AssignToMeIcon() {
@@ -84,7 +84,7 @@ function AssignToMeIcon() {
8484
/>
8585
<path d="M6.72511 14.718C6.80609 14.7834 6.91767 14.7955 7.01074 14.749C7.10407 14.7036 7.16321 14.6087 7.16295 14.5047L7.1605 13.7849C11.4352 13.5894 12.9723 10.3023 12.9722 10.2563C12.9722 10.1147 12.8634 9.9971 12.7225 9.98626L12.7009 9.98634C12.5685 9.98689 12.4561 10.0833 12.4351 10.2142C12.4303 10.2413 10.4816 11.623 7.15364 11.7666L7.1504 10.8116C7.14981 10.662 7.02829 10.5412 6.87896 10.5418C6.81184 10.5421 6.74721 10.5674 6.69765 10.6127L4.54129 12.5896C4.43117 12.6906 4.42367 12.862 4.52453 12.9723C4.53428 12.9829 4.54488 12.9928 4.55621 13.0018L6.72511 14.718Z" />
8686
</svg>
87-
);
87+
)
8888
}
8989

9090
function ChangeStatusIcon() {
@@ -97,7 +97,7 @@ function ChangeStatusIcon() {
9797
d="M7 12.5C10.0376 12.5 12.5 10.0376 12.5 7C12.5 3.96243 10.0376 1.5 7 1.5C3.96243 1.5 1.5 3.96243 1.5 7C1.5 10.0376 3.96243 12.5 7 12.5ZM7 14C10.866 14 14 10.866 14 7C14 3.13401 10.866 0 7 0C3.13401 0 0 3.13401 0 7C0 10.866 3.13401 14 7 14Z"
9898
/>
9999
</svg>
100-
);
100+
)
101101
}
102102

103103
function ChangePriorityIcon() {
@@ -107,7 +107,7 @@ function ChangePriorityIcon() {
107107
<rect x="6" y="5" width="3" height="9" rx="1"></rect>
108108
<rect x="11" y="2" width="3" height="12" rx="1"></rect>
109109
</svg>
110-
);
110+
)
111111
}
112112

113113
function ChangeLabelsIcon() {
@@ -119,7 +119,7 @@ function ChangeLabelsIcon() {
119119
d="M10.2105 4C10.6337 4 11.0126 4.18857 11.24 4.48L14 8L11.24 11.52C11.0126 11.8114 10.6337 12 10.2105 12L3.26316 11.9943C2.56842 11.9943 2 11.4857 2 10.8571V5.14286C2 4.51429 2.56842 4.00571 3.26316 4.00571L10.2105 4ZM11.125 9C11.6773 9 12.125 8.55228 12.125 8C12.125 7.44772 11.6773 7 11.125 7C10.5727 7 10.125 7.44772 10.125 8C10.125 8.55228 10.5727 9 11.125 9Z"
120120
/>
121121
</svg>
122-
);
122+
)
123123
}
124124

125125
function RemoveLabelIcon() {
@@ -131,7 +131,7 @@ function RemoveLabelIcon() {
131131
d="M10.2105 4C10.6337 4 11.0126 4.18857 11.24 4.48L14 8L11.24 11.52C11.0126 11.8114 10.6337 12 10.2105 12L3.26316 11.9943C2.56842 11.9943 2 11.4857 2 10.8571V5.14286C2 4.51429 2.56842 4.00571 3.26316 4.00571L10.2105 4ZM11.125 9C11.6773 9 12.125 8.55228 12.125 8C12.125 7.44772 11.6773 7 11.125 7C10.5727 7 10.125 7.44772 10.125 8C10.125 8.55228 10.5727 9 11.125 9Z"
132132
/>
133133
</svg>
134-
);
134+
)
135135
}
136136

137137
function SetDueDateIcon() {
@@ -143,5 +143,5 @@ function SetDueDateIcon() {
143143
d="M15 5C15 2.79086 13.2091 1 11 1H5C2.79086 1 1 2.79086 1 5V11C1 13.2091 2.79086 15 5 15H6.25C6.66421 15 7 14.6642 7 14.25C7 13.8358 6.66421 13.5 6.25 13.5H5C3.61929 13.5 2.5 12.3807 2.5 11V6H13.5V6.25C13.5 6.66421 13.8358 7 14.25 7C14.6642 7 15 6.66421 15 6.25V5ZM11.5001 8C11.9143 8 12.2501 8.33579 12.2501 8.75V10.75L14.2501 10.75C14.6643 10.75 15.0001 11.0858 15.0001 11.5C15.0001 11.9142 14.6643 12.25 14.2501 12.25L12.2501 12.25V14.25C12.2501 14.6642 11.9143 15 11.5001 15C11.0859 15 10.7501 14.6642 10.7501 14.25V12.25H8.75C8.33579 12.25 8 11.9142 8 11.5C8 11.0858 8.33579 10.75 8.75 10.75L10.7501 10.75V8.75C10.7501 8.33579 11.0859 8 11.5001 8Z"
144144
/>
145145
</svg>
146-
);
146+
)
147147
}

0 commit comments

Comments
 (0)