Skip to content

Commit 3fa3f04

Browse files
committed
Fix CS
1 parent 3aa6b6f commit 3fa3f04

File tree

1 file changed

+48
-53
lines changed

1 file changed

+48
-53
lines changed

packages/tailwindcss-language-server/src/projects.ts

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const colorNames = Object.keys(namedColors)
8484

8585
function getConfigId(configPath: string, configDependencies: string[]): string {
8686
return JSON.stringify(
87-
[configPath, ...configDependencies].map((file) => [file, fs.statSync(file).mtimeMs])
87+
[configPath, ...configDependencies].map((file) => [file, fs.statSync(file).mtimeMs]),
8888
)
8989
}
9090

@@ -180,7 +180,7 @@ export async function createProjectService(
180180
refreshDiagnostics: () => void,
181181
watchPatterns: (patterns: string[]) => void,
182182
initialTailwindVersion: string,
183-
getConfiguration: (uri?: string) => Promise<Settings>
183+
getConfiguration: (uri?: string) => Promise<Settings>,
184184
): Promise<ProjectService> {
185185
let enabled = false
186186
const folder = projectConfig.folder
@@ -228,11 +228,11 @@ export async function createProjectService(
228228
return (await isExcluded(
229229
state,
230230
document,
231-
path.join(directory, dirent.name, isDirectory ? '/' : '')
231+
path.join(directory, dirent.name, isDirectory ? '/' : ''),
232232
))
233233
? null
234234
: [dirent.name, { isDirectory }]
235-
})
235+
}),
236236
)
237237
return result.filter((item) => item !== null)
238238
} catch {
@@ -255,7 +255,7 @@ export async function createProjectService(
255255

256256
function log(...args: string[]): void {
257257
console.log(
258-
`[${path.relative(projectConfig.folder, projectConfig.configPath)}] ${args.join(' ')}`
258+
`[${path.relative(projectConfig.folder, projectConfig.configPath)}] ${args.join(' ')}`,
259259
)
260260
}
261261

@@ -280,12 +280,12 @@ export async function createProjectService(
280280
) {
281281
documentSelector = [
282282
...documentSelector.filter(
283-
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE
283+
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE,
284284
),
285285
...getContentDocumentSelectorFromConfigFile(
286286
projectConfig.configPath,
287287
initialTailwindVersion,
288-
projectConfig.folder
288+
projectConfig.folder,
289289
),
290290
]
291291

@@ -390,7 +390,7 @@ export async function createProjectService(
390390
return findUp.stop
391391
}
392392
},
393-
{ cwd: folder }
393+
{ cwd: folder },
394394
)
395395

396396
if (pnpPath) {
@@ -498,10 +498,9 @@ export async function createProjectService(
498498
resolveConfigFn = (config) => resolveConfig([config, defaultConfig])
499499
} catch (_) {
500500
try {
501-
const resolveConfig = require(resolveFrom(
502-
tailwindDir,
503-
'./lib/util/mergeConfigWithDefaults.js'
504-
))
501+
const resolveConfig = require(
502+
resolveFrom(tailwindDir, './lib/util/mergeConfigWithDefaults.js'),
503+
)
505504
const defaultConfig = require(resolveFrom(tailwindDir, './defaultConfig.js'))
506505
resolveConfigFn = (config) => resolveConfig.default(config, defaultConfig())
507506
} catch (_) {
@@ -522,7 +521,7 @@ export async function createProjectService(
522521

523522
if (semver.gte(tailwindcssVersion, '1.99.0')) {
524523
applyComplexClasses = firstOptional(() =>
525-
require(resolveFrom(tailwindDir, './lib/lib/substituteClassApplyAtRules'))
524+
require(resolveFrom(tailwindDir, './lib/lib/substituteClassApplyAtRules')),
526525
)
527526
} else if (semver.gte(tailwindcssVersion, '1.7.0')) {
528527
applyComplexClasses = require(resolveFrom(tailwindDir, './lib/flagged/applyComplexClasses'))
@@ -541,43 +540,39 @@ export async function createProjectService(
541540
try {
542541
let createContext = first(
543542
() => {
544-
let createContextFn = require(resolveFrom(
545-
configDir,
546-
'tailwindcss/lib/lib/setupContextUtils'
547-
)).createContext
543+
let createContextFn = require(
544+
resolveFrom(configDir, 'tailwindcss/lib/lib/setupContextUtils'),
545+
).createContext
548546
assert.strictEqual(typeof createContextFn, 'function')
549547
return (state) => createContextFn(state.config)
550548
},
551549
() => {
552-
let createContextFn = require(resolveFrom(
553-
configDir,
554-
'tailwindcss/lib/jit/lib/setupContextUtils'
555-
)).createContext
550+
let createContextFn = require(
551+
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContextUtils'),
552+
).createContext
556553
assert.strictEqual(typeof createContextFn, 'function')
557554
return (state) => createContextFn(state.config)
558555
},
559556
// TODO: the next two are canary releases only so can probably be removed
560557
() => {
561-
let setupTrackingContext = require(resolveFrom(
562-
configDir,
563-
'tailwindcss/lib/jit/lib/setupTrackingContext'
564-
)).default
558+
let setupTrackingContext = require(
559+
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupTrackingContext'),
560+
).default
565561
assert.strictEqual(typeof setupTrackingContext, 'function')
566562
return (state) =>
567563
setupTrackingContext(
568564
state.configPath,
569565
tailwindDirectives,
570-
registerDependency
566+
registerDependency,
571567
)(result, root)
572568
},
573569
() => {
574-
let setupContext = require(resolveFrom(
575-
configDir,
576-
'tailwindcss/lib/jit/lib/setupContext'
577-
)).default
570+
let setupContext = require(
571+
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContext'),
572+
).default
578573
assert.strictEqual(typeof setupContext, 'function')
579574
return (state) => setupContext(state.configPath, tailwindDirectives)(result, root)
580-
}
575+
},
581576
)
582577

583578
jitModules = {
@@ -587,7 +582,7 @@ export async function createProjectService(
587582
require(resolveFrom(configDir, 'tailwindcss/lib/lib/generateRules')).generateRules,
588583
() =>
589584
require(resolveFrom(configDir, 'tailwindcss/lib/jit/lib/generateRules'))
590-
.generateRules
585+
.generateRules,
591586
),
592587
},
593588
createContext: {
@@ -599,14 +594,14 @@ export async function createProjectService(
599594
require(resolveFrom(configDir, 'tailwindcss/lib/lib/expandApplyAtRules')).default,
600595
() =>
601596
require(resolveFrom(configDir, 'tailwindcss/lib/jit/lib/expandApplyAtRules'))
602-
.default
597+
.default,
603598
),
604599
},
605600
evaluateTailwindFunctions: {
606601
module: firstOptional(
607602
() =>
608603
require(resolveFrom(configDir, 'tailwindcss/lib/lib/evaluateTailwindFunctions'))
609-
.default
604+
.default,
610605
),
611606
},
612607
}
@@ -670,7 +665,7 @@ export async function createProjectService(
670665

671666
try {
672667
state.corePlugins = Object.keys(
673-
require(resolveFrom(path.dirname(state.configPath), 'tailwindcss/lib/plugins/index.js'))
668+
require(resolveFrom(path.dirname(state.configPath), 'tailwindcss/lib/plugins/index.js')),
674669
)
675670
} catch (_) {}
676671

@@ -693,7 +688,7 @@ export async function createProjectService(
693688
rule.before(
694689
postcss.comment({
695690
text: '__ORIGINAL_SELECTOR__:' + rule.selector,
696-
})
691+
}),
697692
)
698693
rule.selector = newSelector
699694
}
@@ -738,7 +733,7 @@ export async function createProjectService(
738733
let designSystem = await loadDesignSystem(
739734
state.modules.tailwindcss.module,
740735
state.configPath,
741-
css
736+
css,
742737
)
743738

744739
state.designSystem = designSystem
@@ -851,13 +846,13 @@ export async function createProjectService(
851846
if (!projectConfig.isUserConfigured) {
852847
documentSelector = [
853848
...documentSelector.filter(
854-
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE
849+
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE,
855850
),
856851
...getContentDocumentSelectorFromConfigFile(
857852
state.configPath,
858853
tailwindcss.version,
859854
projectConfig.folder,
860-
originalConfig
855+
originalConfig,
861856
),
862857
]
863858
}
@@ -931,7 +926,7 @@ export async function createProjectService(
931926
.join('\n'),
932927
{
933928
from: undefined,
934-
}
929+
},
935930
)
936931
} catch (error) {
937932
throw error
@@ -947,8 +942,8 @@ export async function createProjectService(
947942
// chokidarWatcher?.add(state.dependencies)
948943
watchPatterns(
949944
(state.dependencies ?? []).flatMap((dep) =>
950-
getWatchPatternsForFile(dep, projectConfig.folder)
951-
)
945+
getWatchPatternsForFile(dep, projectConfig.folder),
946+
),
952947
)
953948

954949
state.configId = getConfigId(state.configPath, state.dependencies)
@@ -1043,15 +1038,15 @@ export async function createProjectService(
10431038
let document = documentService.getDocument(params.textDocument.uri)
10441039
if (!document) return null
10451040
return getDocumentLinks(state, document, (linkPath) =>
1046-
URI.file(path.resolve(path.dirname(URI.parse(document.uri).fsPath), linkPath)).toString()
1041+
URI.file(path.resolve(path.dirname(URI.parse(document.uri).fsPath), linkPath)).toString(),
10471042
)
10481043
},
10491044
provideDiagnostics: debounce(
10501045
(document: TextDocument) => {
10511046
if (!state.enabled) return
10521047
provideDiagnostics(state, document)
10531048
},
1054-
params.initializationOptions?.testMode ? 0 : 500
1049+
params.initializationOptions?.testMode ? 0 : 500,
10551050
),
10561051
provideDiagnosticsForce: (document: TextDocument) => {
10571052
if (!state.enabled) return
@@ -1071,7 +1066,7 @@ export async function createProjectService(
10711066
if (!document) return []
10721067
let className = document.getText(params.range)
10731068
let match = className.match(
1074-
new RegExp(`-\\[(${colorNames.join('|')}|(?:(?:#|rgba?\\(|hsla?\\())[^\\]]+)\\]$`, 'i')
1069+
new RegExp(`-\\[(${colorNames.join('|')}|(?:(?:#|rgba?\\(|hsla?\\())[^\\]]+)\\]$`, 'i'),
10751070
)
10761071
// let match = className.match(/-\[((?:#|rgba?\(|hsla?\()[^\]]+)\]$/i)
10771072
if (match === null) return []
@@ -1193,7 +1188,7 @@ type Plugin = SimplePlugin | WrappedPlugin
11931188
function runPlugin(
11941189
plugin: Plugin,
11951190
state: State,
1196-
apiOverrides: Record<string, Function> = {}
1191+
apiOverrides: Record<string, Function> = {},
11971192
): void {
11981193
let config = state.config
11991194
let postcss = state.modules.postcss.module
@@ -1266,7 +1261,7 @@ function getVariants(state: State): Array<Variant> {
12661261
}
12671262

12681263
let fns = (Array.isArray(variantFnOrFns[0]) ? variantFnOrFns : [variantFnOrFns]).map(
1269-
([_sort, fn]) => fn
1264+
([_sort, fn]) => fn,
12701265
)
12711266

12721267
let placeholder = '__variant_placeholder__'
@@ -1324,7 +1319,7 @@ function getVariants(state: State): Array<Variant> {
13241319
definition = `@${rule.name} ${rule.params}`
13251320
}
13261321
},
1327-
})
1322+
}),
13281323
)
13291324

13301325
if (!definition) {
@@ -1355,7 +1350,7 @@ function getVariants(state: State): Array<Variant> {
13551350
return definitions
13561351
},
13571352
})
1358-
}
1353+
},
13591354
)
13601355

13611356
return result
@@ -1454,7 +1449,7 @@ async function getPlugins(config: any) {
14541449
return {
14551450
name: fnName,
14561451
}
1457-
})
1452+
}),
14581453
)
14591454
}
14601455

@@ -1470,7 +1465,7 @@ function getPackageRoot(cwd: string, rootDir: string) {
14701465
return findUp.stop
14711466
}
14721467
},
1473-
{ cwd }
1468+
{ cwd },
14741469
)
14751470
return pkgJsonPath ? path.dirname(pkgJsonPath) : rootDir
14761471
} catch {
@@ -1482,7 +1477,7 @@ function getContentDocumentSelectorFromConfigFile(
14821477
configPath: string,
14831478
tailwindVersion: string,
14841479
rootDir: string,
1485-
actualConfig?: any
1480+
actualConfig?: any,
14861481
): DocumentSelector[] {
14871482
let config = actualConfig ?? require(configPath)
14881483
let contentConfig: unknown = config.content?.files ?? config.content
@@ -1501,7 +1496,7 @@ function getContentDocumentSelectorFromConfigFile(
15011496
.map((item) =>
15021497
item.startsWith('!')
15031498
? `!${path.resolve(contentBase, item.slice(1))}`
1504-
: path.resolve(contentBase, item)
1499+
: path.resolve(contentBase, item),
15051500
)
15061501
.map((item) => ({
15071502
pattern: normalizePath(item),

0 commit comments

Comments
 (0)