Skip to content

Commit 281c82c

Browse files
committed
fmt
1 parent 4e1da1b commit 281c82c

1 file changed

Lines changed: 43 additions & 10 deletions

File tree

‎src/index.ts‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ import { AggregateCollection } from './aggregate-collection.js'
4444
import { DefinedUsed } from './defined-used.js'
4545
import { endsWith, unquote } from './string-utils.js'
4646
import { getEmbedType } from './stylesheet/stylesheet.js'
47-
import { basename, SPACING_RESET_PROPERTIES, border_radius_properties, shorthand_properties } from './properties/property-utils.js'
47+
import {
48+
basename,
49+
SPACING_RESET_PROPERTIES,
50+
border_radius_properties,
51+
shorthand_properties,
52+
} from './properties/property-utils.js'
4853

4954
export type Specificity = [number, number, number]
5055

@@ -58,8 +63,14 @@ export type Options = {
5863
useLocations?: boolean
5964
}
6065

61-
export function analyze(css: string, options?: Options & { useLocations?: false | undefined }): ReturnType<typeof analyzeInternal<false>>
62-
export function analyze(css: string, options: Options & { useLocations: true }): ReturnType<typeof analyzeInternal<true>>
66+
export function analyze(
67+
css: string,
68+
options?: Options & { useLocations?: false | undefined },
69+
): ReturnType<typeof analyzeInternal<false>>
70+
export function analyze(
71+
css: string,
72+
options: Options & { useLocations: true },
73+
): ReturnType<typeof analyzeInternal<true>>
6374
export function analyze(css: string, options: Options = {}): any {
6475
const useLocations = options.useLocations === true
6576
if (useLocations) {
@@ -331,7 +342,9 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
331342
customPropsTracking.define(node.prelude.text)
332343
} else if (normalized_name === 'function') {
333344
let prelude = node.prelude.text
334-
let name = prelude.includes('(') ? prelude.slice(0, prelude.indexOf('(')).trim() : prelude.trim()
345+
let name = prelude.includes('(')
346+
? prelude.slice(0, prelude.indexOf('(')).trim()
347+
: prelude.trim()
335348
functions.p(name, toLoc(node))
336349
} else if (normalized_name === 'charset') {
337350
charsets.p(node.prelude.text.toLowerCase(), toLoc(node))
@@ -425,7 +438,11 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
425438
walk(node, (child) => {
426439
if (is_attribute_selector(child)) {
427440
attributeSelectors.p(child.name.toLowerCase(), loc)
428-
} else if (is_type_selector(child) && !child.name.startsWith('--') && child.name.includes('-')) {
441+
} else if (
442+
is_type_selector(child) &&
443+
!child.name.startsWith('--') &&
444+
child.name.includes('-')
445+
) {
429446
customElementSelectors.p(child.name.toLowerCase(), loc)
430447
} else if (is_pseudo_class_selector(child)) {
431448
pseudoClasses.p(child.name.toLowerCase(), loc)
@@ -664,7 +681,10 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
664681
}
665682
})
666683
return SKIP
667-
} else if (normalizedProperty === 'animation-duration' || normalizedProperty === 'transition-duration') {
684+
} else if (
685+
normalizedProperty === 'animation-duration' ||
686+
normalizedProperty === 'transition-duration'
687+
) {
668688
for (let child of value.children) {
669689
if (!is_operator(child)) {
670690
let text = child.text
@@ -675,7 +695,10 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
675695
}
676696
}
677697
}
678-
} else if (normalizedProperty === 'transition-timing-function' || normalizedProperty === 'animation-timing-function') {
698+
} else if (
699+
normalizedProperty === 'transition-timing-function' ||
700+
normalizedProperty === 'animation-timing-function'
701+
) {
679702
for (let child of value.children) {
680703
if (!is_operator(child)) {
681704
timingFunctions.p(child.text, valueLoc)
@@ -715,7 +738,11 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
715738
}
716739
}
717740
} else if (normalizedProperty === 'position-anchor') {
718-
if (value.first_child && is_identifier(value.first_child) && is_custom(value.first_child.text)) {
741+
if (
742+
value.first_child &&
743+
is_identifier(value.first_child) &&
744+
is_custom(value.first_child.text)
745+
) {
719746
anchorNamesTracking.use(value.first_child.text)
720747
}
721748
} else if (border_radius_properties.has(normalizedProperty)) {
@@ -900,10 +927,16 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
900927

901928
return {
902929
stylesheet: {
903-
sourceLinesOfCode: atruleCount.total + totalSelectors + totalDeclarations + keyframeSelectors.size(),
930+
sourceLinesOfCode:
931+
atruleCount.total + totalSelectors + totalDeclarations + keyframeSelectors.size(),
904932
linesOfCode,
905933
size: cssLen,
906-
complexity: atRuleComplexity.sum + selectorComplexity.sum + declarationComplexity.sum + propertyComplexity.sum + valueComplexity.sum,
934+
complexity:
935+
atRuleComplexity.sum +
936+
selectorComplexity.sum +
937+
declarationComplexity.sum +
938+
propertyComplexity.sum +
939+
valueComplexity.sum,
907940
comments: {
908941
total: totalComments,
909942
size: commentsSize,

0 commit comments

Comments
 (0)