Skip to content

Commit 52acec1

Browse files
committed
Change prettier config trailingComma to all
Prettier is setting it as the default in v3 https://github.com/prettier/prettier/releases/tag/3.0.0-alpha.0 prettier/prettier#11465
1 parent 4f659be commit 52acec1

25 files changed

+87
-86
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"tabWidth": 4,
33
"semi": false,
44
"singleQuote": true,
5-
"printWidth": 100
5+
"printWidth": 100,
6+
"trailingComma": "all"
67
}

docs/api-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ join(
2929
'border border-red-500',
3030
hasBackground && 'bg-red-100',
3131
hasLargeText && 'text-lg',
32-
hasLargeSpacing && ['p-2', hasLargeText ? 'leading-8' : 'leading-7']
32+
hasLargeSpacing && ['p-2', hasLargeText ? 'leading-8' : 'leading-7'],
3333
)
3434
```
3535

@@ -185,7 +185,7 @@ const customTwMerge = createTailwindMerge(getDefaultConfig, (config) =>
185185
// ↓ Adding value to existing class group
186186
animate: ['animate-magic'],
187187
},
188-
})
188+
}),
189189
)
190190
```
191191

scripts/helpers/apply-versioned-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function applyVersionedText(text, packageJson) {
1111
const hasPartsToUpdate = !resolvedVersion || AUTOGENERATED_VERSION_REGEX.test(text)
1212

1313
const updatedText = text.replace(AUTOGENERATED_VERSION_REGEX, (match) =>
14-
match.replace(VERSION_REGEX, resolvedVersion)
14+
match.replace(VERSION_REGEX, resolvedVersion),
1515
)
1616

1717
return {

scripts/test-built-package-exports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { twMerge } = require('..')
55
assert(twMerge() === '')
66
assert(
77
twMerge('px-2 py-1 bg-red hover:bg-dark-red', 'p-3 bg-[#B91C1C]') ===
8-
'hover:bg-dark-red p-3 bg-[#B91C1C]'
8+
'hover:bg-dark-red p-3 bg-[#B91C1C]',
99
)
1010

1111
console.log('[tailwind-merge] Tests for built CJS package exports passed.')

scripts/test-built-package-exports.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { twMerge } from '../dist/tailwind-merge.mjs'
66
assert(twMerge() === '')
77
assert(
88
twMerge('px-2 py-1 bg-red hover:bg-dark-red', 'p-3 bg-[#B91C1C]') ===
9-
'hover:bg-dark-red p-3 bg-[#B91C1C]'
9+
'hover:bg-dark-red p-3 bg-[#B91C1C]',
1010
)
1111

1212
console.log('[tailwind-merge] Tests for built ESM package exports passed.')

scripts/update-readme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async function run() {
1818

1919
if (!hasPartsToUpdate) {
2020
throw Error(
21-
`${chalk.red('[ERROR]')} Could not find versioned logo image to update in README`
21+
`${chalk.red('[ERROR]')} Could not find versioned logo image to update in README`,
2222
)
2323
}
2424

src/lib/class-utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function createClassUtils(config: Config) {
3939

4040
function getGroupRecursive(
4141
classParts: string[],
42-
classPartObject: ClassPartObject
42+
classPartObject: ClassPartObject,
4343
): ClassGroupId | undefined {
4444
if (classParts.length === 0) {
4545
return classPartObject.classGroupId
@@ -71,7 +71,7 @@ function getGroupIdForArbitraryProperty(className: string) {
7171
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)![1]
7272
const property = arbitraryPropertyClassName?.substring(
7373
0,
74-
arbitraryPropertyClassName.indexOf(':')
74+
arbitraryPropertyClassName.indexOf(':'),
7575
)
7676

7777
if (property) {
@@ -93,7 +93,7 @@ export function createClassMap(config: Config) {
9393

9494
const prefixedClassGroupEntries = getPrefixedClassGroupEntries(
9595
Object.entries(config.classGroups),
96-
prefix
96+
prefix,
9797
)
9898

9999
prefixedClassGroupEntries.forEach(([classGroupId, classGroup]) => {
@@ -107,7 +107,7 @@ function processClassesRecursively(
107107
classGroup: ClassGroup,
108108
classPartObject: ClassPartObject,
109109
classGroupId: ClassGroupId,
110-
theme: ThemeObject
110+
theme: ThemeObject,
111111
) {
112112
classGroup.forEach((classDefinition) => {
113113
if (typeof classDefinition === 'string') {
@@ -123,7 +123,7 @@ function processClassesRecursively(
123123
classDefinition(theme),
124124
classPartObject,
125125
classGroupId,
126-
theme
126+
theme,
127127
)
128128
return
129129
}
@@ -141,7 +141,7 @@ function processClassesRecursively(
141141
classGroup,
142142
getPart(classPartObject, key),
143143
classGroupId,
144-
theme
144+
theme,
145145
)
146146
})
147147
})
@@ -170,7 +170,7 @@ function isThemeGetter(func: ClassValidator | ThemeGetter): func is ThemeGetter
170170

171171
function getPrefixedClassGroupEntries(
172172
classGroupEntries: Array<[classGroupId: string, classGroup: ClassGroup]>,
173-
prefix: string | undefined
173+
prefix: string | undefined,
174174
): Array<[classGroupId: string, classGroup: ClassGroup]> {
175175
if (!prefix) {
176176
return classGroupEntries
@@ -184,7 +184,7 @@ function getPrefixedClassGroupEntries(
184184

185185
if (typeof classDefinition === 'object') {
186186
return Object.fromEntries(
187-
Object.entries(classDefinition).map(([key, value]) => [prefix + key, value])
187+
Object.entries(classDefinition).map(([key, value]) => [prefix + key, value]),
188188
)
189189
}
190190

src/lib/create-tailwind-merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function createTailwindMerge(
2121

2222
const config = restCreateConfig.reduce(
2323
(previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig),
24-
firstCreateConfig()
24+
firstCreateConfig(),
2525
)
2626

2727
configUtils = createConfigUtils(config)

src/lib/extend-tailwind-merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export function extendTailwindMerge(
1313
? createTailwindMerge(getDefaultConfig, configExtension, ...createConfig)
1414
: createTailwindMerge(
1515
() => mergeConfigs(getDefaultConfig(), configExtension),
16-
...createConfig
16+
...createConfig,
1717
)
1818
}

src/lib/merge-classlist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function mergeClassList(classList: string, configUtils: ConfigUtils) {
6363
classGroupsInConflict.add(classId)
6464

6565
getConflictingClassGroupIds(classGroupId).forEach((group) =>
66-
classGroupsInConflict.add(modifierId + group)
66+
classGroupsInConflict.add(modifierId + group),
6767
)
6868

6969
return true

src/lib/merge-configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const overrideTypes = new Set(['string', 'number', 'boolean'])
1818
function mergePropertyRecursively(
1919
baseObject: Record<string, unknown>,
2020
mergeKey: string,
21-
mergeValue: unknown
21+
mergeValue: unknown,
2222
) {
2323
if (
2424
!hasOwnProperty.call(baseObject, mergeKey) ||
@@ -44,7 +44,7 @@ function mergePropertyRecursively(
4444
mergePropertyRecursively(
4545
baseObject[mergeKey] as Record<string, unknown>,
4646
nextKey,
47-
mergeValue[nextKey as keyof object]
47+
mergeValue[nextKey as keyof object],
4848
)
4949
}
5050
}

tests/arbitrary-properties.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ import { twMerge } from '../src'
33
test('handles arbitrary property conflicts correctly', () => {
44
expect(twMerge('[paint-order:markers] [paint-order:normal]')).toBe('[paint-order:normal]')
55
expect(
6-
twMerge('[paint-order:markers] [--my-var:2rem] [paint-order:normal] [--my-var:4px]')
6+
twMerge('[paint-order:markers] [--my-var:2rem] [paint-order:normal] [--my-var:4px]'),
77
).toBe('[paint-order:normal] [--my-var:4px]')
88
})
99

1010
test('handles arbitrary property conflicts with modifiers correctly', () => {
1111
expect(twMerge('[paint-order:markers] hover:[paint-order:normal]')).toBe(
12-
'[paint-order:markers] hover:[paint-order:normal]'
12+
'[paint-order:markers] hover:[paint-order:normal]',
1313
)
1414
expect(twMerge('hover:[paint-order:markers] hover:[paint-order:normal]')).toBe(
15-
'hover:[paint-order:normal]'
15+
'hover:[paint-order:normal]',
1616
)
1717
expect(twMerge('hover:focus:[paint-order:markers] focus:hover:[paint-order:normal]')).toBe(
18-
'focus:hover:[paint-order:normal]'
18+
'focus:hover:[paint-order:normal]',
1919
)
2020
expect(
21-
twMerge('[paint-order:markers] [paint-order:normal] [--my-var:2rem] lg:[--my-var:4px]')
21+
twMerge('[paint-order:markers] [paint-order:normal] [--my-var:2rem] lg:[--my-var:4px]'),
2222
).toBe('[paint-order:normal] [--my-var:2rem] lg:[--my-var:4px]')
2323
})
2424

2525
test('handles complex arbitrary property conflicts correctly', () => {
2626
expect(twMerge('[-unknown-prop:::123:::] [-unknown-prop:url(https://hi.com)]')).toBe(
27-
'[-unknown-prop:url(https://hi.com)]'
27+
'[-unknown-prop:url(https://hi.com)]',
2828
)
2929
})
3030

3131
test('handles important modifier correctly', () => {
3232
expect(twMerge('![some:prop] [some:other]')).toBe('![some:prop] [some:other]')
3333
expect(twMerge('![some:prop] [some:other] [some:one] ![some:another]')).toBe(
34-
'[some:one] ![some:another]'
34+
'[some:one] ![some:another]',
3535
)
3636
})

tests/arbitrary-values.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ test('handles simple conflicts with arbitrary values correctly', () => {
66
expect(twMerge('my-[2px] m-[10rem]')).toBe('m-[10rem]')
77
expect(twMerge('cursor-pointer cursor-[grab]')).toBe('cursor-[grab]')
88
expect(twMerge('m-[2px] m-[calc(100%-var(--arbitrary))]')).toBe(
9-
'm-[calc(100%-var(--arbitrary))]'
9+
'm-[calc(100%-var(--arbitrary))]',
1010
)
1111
expect(twMerge('m-[2px] m-[length:var(--mystery-var)]')).toBe('m-[length:var(--mystery-var)]')
1212
})
1313

1414
test('handles arbitrary length conflicts with labels and modifiers correctly', () => {
1515
expect(twMerge('hover:m-[2px] hover:m-[length:var(--c)]')).toBe('hover:m-[length:var(--c)]')
1616
expect(twMerge('hover:focus:m-[2px] focus:hover:m-[length:var(--c)]')).toBe(
17-
'focus:hover:m-[length:var(--c)]'
17+
'focus:hover:m-[length:var(--c)]',
1818
)
1919
})
2020

tests/arbitrary-variants.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,81 @@ import { twMerge } from '../src'
33
test('basic arbitrary variants', () => {
44
expect(twMerge('[&>*]:underline [&>*]:line-through')).toBe('[&>*]:line-through')
55
expect(twMerge('[&>*]:underline [&>*]:line-through [&_div]:line-through')).toBe(
6-
'[&>*]:line-through [&_div]:line-through'
6+
'[&>*]:line-through [&_div]:line-through',
77
)
88
})
99

1010
test('arbitrary variants with modifiers', () => {
1111
expect(twMerge('dark:lg:hover:[&>*]:underline dark:lg:hover:[&>*]:line-through')).toBe(
12-
'dark:lg:hover:[&>*]:line-through'
12+
'dark:lg:hover:[&>*]:line-through',
1313
)
1414
expect(twMerge('dark:lg:hover:[&>*]:underline dark:hover:lg:[&>*]:line-through')).toBe(
15-
'dark:hover:lg:[&>*]:line-through'
15+
'dark:hover:lg:[&>*]:line-through',
1616
)
1717
// Whether a modifier is before or after arbitrary variant matters
1818
expect(twMerge('hover:[&>*]:underline [&>*]:hover:line-through')).toBe(
19-
'hover:[&>*]:underline [&>*]:hover:line-through'
19+
'hover:[&>*]:underline [&>*]:hover:line-through',
2020
)
2121
expect(
2222
twMerge(
23-
'hover:dark:[&>*]:underline dark:hover:[&>*]:underline dark:[&>*]:hover:line-through'
24-
)
23+
'hover:dark:[&>*]:underline dark:hover:[&>*]:underline dark:[&>*]:hover:line-through',
24+
),
2525
).toBe('dark:hover:[&>*]:underline dark:[&>*]:hover:line-through')
2626
})
2727

2828
test('arbitrary variants with complex syntax in them', () => {
2929
expect(
3030
twMerge(
31-
'[@media_screen{@media(hover:hover)}]:underline [@media_screen{@media(hover:hover)}]:line-through'
32-
)
31+
'[@media_screen{@media(hover:hover)}]:underline [@media_screen{@media(hover:hover)}]:line-through',
32+
),
3333
).toBe('[@media_screen{@media(hover:hover)}]:line-through')
3434
expect(
3535
twMerge(
36-
'hover:[@media_screen{@media(hover:hover)}]:underline hover:[@media_screen{@media(hover:hover)}]:line-through'
37-
)
36+
'hover:[@media_screen{@media(hover:hover)}]:underline hover:[@media_screen{@media(hover:hover)}]:line-through',
37+
),
3838
).toBe('hover:[@media_screen{@media(hover:hover)}]:line-through')
3939
})
4040

4141
test('arbitrary variants with attribute selectors', () => {
4242
expect(twMerge('[&[data-open]]:underline [&[data-open]]:line-through')).toBe(
43-
'[&[data-open]]:line-through'
43+
'[&[data-open]]:line-through',
4444
)
4545
})
4646

4747
test('arbitrary variants with multiple attribute selectors', () => {
4848
expect(
4949
twMerge(
50-
'[&[data-foo][data-bar]:not([data-baz])]:underline [&[data-foo][data-bar]:not([data-baz])]:line-through'
51-
)
50+
'[&[data-foo][data-bar]:not([data-baz])]:underline [&[data-foo][data-bar]:not([data-baz])]:line-through',
51+
),
5252
).toBe('[&[data-foo][data-bar]:not([data-baz])]:line-through')
5353
})
5454

5555
test('multiple arbitrary variants', () => {
5656
expect(twMerge('[&>*]:[&_div]:underline [&>*]:[&_div]:line-through')).toBe(
57-
'[&>*]:[&_div]:line-through'
57+
'[&>*]:[&_div]:line-through',
5858
)
5959
expect(twMerge('[&>*]:[&_div]:underline [&_div]:[&>*]:line-through')).toBe(
60-
'[&>*]:[&_div]:underline [&_div]:[&>*]:line-through'
60+
'[&>*]:[&_div]:underline [&_div]:[&>*]:line-through',
6161
)
6262
expect(
6363
twMerge(
64-
'hover:dark:[&>*]:focus:disabled:[&_div]:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through'
65-
)
64+
'hover:dark:[&>*]:focus:disabled:[&_div]:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through',
65+
),
6666
).toBe('dark:hover:[&>*]:disabled:focus:[&_div]:line-through')
6767
expect(
6868
twMerge(
69-
'hover:dark:[&>*]:focus:[&_div]:disabled:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through'
70-
)
69+
'hover:dark:[&>*]:focus:[&_div]:disabled:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through',
70+
),
7171
).toBe(
72-
'hover:dark:[&>*]:focus:[&_div]:disabled:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through'
72+
'hover:dark:[&>*]:focus:[&_div]:disabled:underline dark:hover:[&>*]:disabled:focus:[&_div]:line-through',
7373
)
7474
})
7575

7676
test('arbitrary variants with arbitrary properties', () => {
7777
expect(twMerge('[&>*]:[color:red] [&>*]:[color:blue]')).toBe('[&>*]:[color:blue]')
7878
expect(
7979
twMerge(
80-
'[&[data-foo][data-bar]:not([data-baz])]:nod:noa:[color:red] [&[data-foo][data-bar]:not([data-baz])]:noa:nod:[color:blue]'
81-
)
80+
'[&[data-foo][data-bar]:not([data-baz])]:nod:noa:[color:red] [&[data-foo][data-bar]:not([data-baz])]:noa:nod:[color:blue]',
81+
),
8282
).toBe('[&[data-foo][data-bar]:not([data-baz])]:noa:nod:[color:blue]')
8383
})

tests/class-group-conflicts.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ test('merges classes from same group correctly', () => {
55
expect(twMerge('w-full w-fit')).toBe('w-fit')
66
expect(twMerge('overflow-x-auto overflow-x-hidden overflow-x-scroll')).toBe('overflow-x-scroll')
77
expect(twMerge('overflow-x-auto hover:overflow-x-hidden overflow-x-scroll')).toBe(
8-
'hover:overflow-x-hidden overflow-x-scroll'
8+
'hover:overflow-x-hidden overflow-x-scroll',
99
)
1010
expect(
11-
twMerge('overflow-x-auto hover:overflow-x-hidden hover:overflow-x-auto overflow-x-scroll')
11+
twMerge('overflow-x-auto hover:overflow-x-hidden hover:overflow-x-auto overflow-x-scroll'),
1212
).toBe('hover:overflow-x-auto overflow-x-scroll')
1313
})
1414

1515
test('merges classes from Font Variant Numeric section correctly', () => {
1616
expect(twMerge('lining-nums tabular-nums diagonal-fractions')).toBe(
17-
'lining-nums tabular-nums diagonal-fractions'
17+
'lining-nums tabular-nums diagonal-fractions',
1818
)
1919
expect(twMerge('normal-nums tabular-nums diagonal-fractions')).toBe(
20-
'tabular-nums diagonal-fractions'
20+
'tabular-nums diagonal-fractions',
2121
)
2222
expect(twMerge('tabular-nums diagonal-fractions normal-nums')).toBe('normal-nums')
2323
expect(twMerge('tabular-nums proportional-nums')).toBe('proportional-nums')

tests/class-map.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('class map has correct class groups at first part', () => {
88
Array.from(classMap.nextPart.entries()).map(([key, value]) => [
99
key,
1010
Array.from(getClassGroupsInClassPart(value)).sort(),
11-
])
11+
]),
1212
)
1313

1414
expect(classMap.classGroupId).toBeUndefined()

tests/content-utilities.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { twMerge } from '../src'
22

33
test('merges content utilities correctly', () => {
44
expect(twMerge("content-['hello'] content-[attr(data-content)]")).toBe(
5-
'content-[attr(data-content)]'
5+
'content-[attr(data-content)]',
66
)
77
})

0 commit comments

Comments
 (0)