Skip to content

Commit 3513952

Browse files
committed
throw an error when applying the .group utility (aot mode)
1 parent 49cb426 commit 3513952

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/lib/substituteClassApplyAtRules.js

+8
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ function makeExtractUtilityRules(css, lookupTree, config) {
234234
const prefixedUtilityName = prefixSelector(config.prefix, `.${utilityName}`).slice(1)
235235

236236
const prefixedUtility = getUtility(prefixedUtilityName)
237+
if (
238+
utilityName === 'group' ||
239+
utilityName === prefixSelector(config.prefix, '.group').slice(1)
240+
) {
241+
// TODO: Link to specific documentation page with error code.
242+
throw rule.error(`@apply should not be used with the '${utilityName}' utility`)
243+
}
244+
237245
if (prefixedUtility !== undefined) {
238246
throw rule.error(
239247
`The \`${utilityName}\` class does not exist, but \`${prefixedUtilityName}\` does. Did you forget the prefix?`

tests/applyAtRule.test.js

+41
Original file line numberDiff line numberDiff line change
@@ -1403,3 +1403,44 @@ test('lookup tree is correctly cached based on used tailwind atrules', async ()
14031403
.foo { margin-top: 1rem; }
14041404
`)
14051405
})
1406+
1407+
test('@apply error when using .group utility', async () => {
1408+
let config = {
1409+
purge: [],
1410+
corePlugins: { preflight: false },
1411+
plugins: [],
1412+
}
1413+
1414+
let css = `
1415+
@layer components {
1416+
.foo {
1417+
@apply group;
1418+
}
1419+
}
1420+
`
1421+
1422+
await expect(run(css, config)).rejects.toThrowError(
1423+
`@apply should not be used with the 'group' utility`
1424+
)
1425+
})
1426+
1427+
test('@apply error when using prefixed .group utility', async () => {
1428+
let config = {
1429+
prefix: 'tw-',
1430+
purge: [],
1431+
corePlugins: { preflight: false },
1432+
plugins: [],
1433+
}
1434+
1435+
let css = `
1436+
@layer components {
1437+
.foo {
1438+
@apply tw-group;
1439+
}
1440+
}
1441+
`
1442+
1443+
await expect(run(css, config)).rejects.toThrowError(
1444+
`@apply should not be used with the 'tw-group' utility`
1445+
)
1446+
})

0 commit comments

Comments
 (0)