From 6ac6829beef3fb319ad843e74ea586ac92d8676f Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 23 Oct 2024 09:51:45 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Robin Malfait --- packages/tailwindcss/src/candidate.test.ts | 2 +- packages/tailwindcss/src/index.ts | 2 +- packages/tailwindcss/src/intellisense.ts | 6 +++--- packages/tailwindcss/src/variants.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/tailwindcss/src/candidate.test.ts b/packages/tailwindcss/src/candidate.test.ts index baf0c500680e..05f87246ed67 100644 --- a/packages/tailwindcss/src/candidate.test.ts +++ b/packages/tailwindcss/src/candidate.test.ts @@ -1204,7 +1204,7 @@ it('should not parse compound group with a non-compoundable variant', () => { utilities.static('flex', () => []) let variants = new Variants() - variants.compoundWith('group', ['selector'], () => {}) + variants.compoundWith('group', Compounds.StyleRules, () => {}) expect(run('group-*:flex', { utilities, variants })).toMatchInlineSnapshot(`[]`) }) diff --git a/packages/tailwindcss/src/index.ts b/packages/tailwindcss/src/index.ts index 72aab861d42f..743e713f23f5 100644 --- a/packages/tailwindcss/src/index.ts +++ b/packages/tailwindcss/src/index.ts @@ -171,7 +171,7 @@ async function parseCss( for (let selector of selectors) { selector = selector.trim() - if (selector.startsWith('@')) { + if (selector[0] === '@') { atRuleSelectors.push(selector) } else { styleRuleSelectors.push(selector) diff --git a/packages/tailwindcss/src/intellisense.ts b/packages/tailwindcss/src/intellisense.ts index 41fddea5814c..815aa1cc04cb 100644 --- a/packages/tailwindcss/src/intellisense.ts +++ b/packages/tailwindcss/src/intellisense.ts @@ -80,7 +80,7 @@ export function getVariants(design: DesignSystem) { let selectors: string[] = [] // Produce v3-style selector strings in the face of nested rules - // This is more visible for things like group-*, not-*, etc… + // this is more visible for things like group-*, not-*, etc… walkDepth(node.nodes, (node, { path }) => { if (node.kind !== 'rule') return if (node.nodes.length > 0) return @@ -90,8 +90,8 @@ export function getVariants(design: DesignSystem) { // This won't actually happen, but it's here to make TypeScript happy if (a.kind !== 'rule' || b.kind !== 'rule') return 0 - let aIsAtRule = a.selector.startsWith('@') - let bIsAtRule = b.selector.startsWith('@') + let aIsAtRule = a.selector[0] === '@' + let bIsAtRule = b.selector[0] === '@' if (aIsAtRule && !bIsAtRule) return -1 if (!aIsAtRule && bIsAtRule) return 1 diff --git a/packages/tailwindcss/src/variants.ts b/packages/tailwindcss/src/variants.ts index 8d24fd9b0171..39c089eb4dd6 100644 --- a/packages/tailwindcss/src/variants.ts +++ b/packages/tailwindcss/src/variants.ts @@ -335,7 +335,7 @@ export function createVariants(theme: Theme): Variants { if (ruleName === 'container') { // @container {query} - if (parts[0].startsWith('(')) { + if (parts[0][0] === '(') { return `not ${condition}` } @@ -377,7 +377,7 @@ export function createVariants(theme: Theme): Variants { if (selector.includes('::')) return null let selectors = segment(selector, ',').map((sel) => { - // Remove unncessary wrapping &:is(…) to reduce the selector size + // Remove unnecessary wrapping &:is(…) to reduce the selector size if (sel.startsWith('&:is(') && sel.endsWith(')')) { sel = sel.slice(5, -1) }