MCPcopy
hub / github.com/nuxt-modules/tailwindcss / checkUnsafeInlineConfig

Function checkUnsafeInlineConfig

src/internal-context/validate.ts:3–29  ·  view source on GitHub ↗
(inlineConfig: T | undefined)

Source from the content-addressed store, hash-verified

1import type { TWConfig } from '../types'
2
3export const checkUnsafeInlineConfig = <T extends Partial<TWConfig>>(inlineConfig: T | undefined) => {
4 if (!inlineConfig) return
5
6 if (
7 'plugins' in inlineConfig && Array.isArray(inlineConfig.plugins)
8 && inlineConfig.plugins.find(p => typeof p === 'function' || typeof p?.handler === 'function')
9 ) {
10 return 'plugins'
11 }
12
13 if (inlineConfig.content) {
14 // @ts-expect-error indexing content with different possibilities
15 const invalidProperty = ['extract', 'transform'].find(i => i in inlineConfig.content! && typeof inlineConfig.content![i] === 'function')
16
17 if (invalidProperty) {
18 return `content.${invalidProperty}`
19 }
20 }
21
22 if (inlineConfig.safelist) {
23 const invalidIdx = inlineConfig.safelist.findIndex(s => typeof s === 'object' && s.pattern instanceof RegExp)
24
25 if (invalidIdx > -1) {
26 return `safelist[${invalidIdx}]`
27 }
28 }
29}

Callers 1

resolveConfigsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected