📄 parseConfig.ts
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 4 |
📦 Imports | 6 |
📊 Variables & Constants | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/website/src/components/lib/parseConfig.ts
📦 Imports¶
Name | Source |
---|---|
EslintRC |
../types |
TSConfig |
../types |
isRecord |
../ast/utils |
ensureObject |
./json |
parseJSONObject |
./json |
toJson |
./json |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
moduleRegexp |
RegExp |
const | /(module\.exports\s*=)/g |
✗ |
Functions¶
parseESLintRC(code: string): EslintRC
¶
Code
export function parseESLintRC(code?: string): EslintRC {
if (code) {
try {
const parsed = parseJSONObject(code);
parsed.rules = ensureObject(parsed.rules);
if ('extends' in parsed) {
parsed.extends =
Array.isArray(parsed.extends) || typeof parsed.extends === 'string'
? parsed.extends
: [];
}
return parsed as EslintRC;
} catch (e) {
console.error(e);
}
}
return { rules: {} };
}
-
JSDoc:
-
Parameters:
code: string
- Return Type:
EslintRC
- Calls:
parseJSONObject (from ./json)
ensureObject (from ./json)
Array.isArray
console.error
parseTSConfig(code: string): TSConfig
¶
Code
export function parseTSConfig(code?: string): TSConfig {
if (code) {
try {
const parsed = window.ts.parseConfigFileTextToJson(
'/tsconfig.json',
code,
);
if (parsed.error) {
console.error(parsed.error);
}
if (isRecord(parsed.config)) {
return parsed.config as TSConfig;
}
} catch (e) {
console.error(e);
}
}
return { compilerOptions: {} };
}
-
JSDoc:
-
Parameters:
code: string
- Return Type:
TSConfig
- Calls:
window.ts.parseConfigFileTextToJson
console.error
isRecord (from ../ast/utils)
constrainedScopeEval(obj: string): unknown
¶
Code
- Parameters:
obj: string
- Return Type:
unknown
- Calls:
complex_call_1505
- Internal Comments:
tryParseEslintModule(value: string): string
¶
Code
-
JSDoc:
-
Parameters:
value: string
- Return Type:
string
- Calls:
moduleRegexp.test
toJson (from ./json)
constrainedScopeEval
console.error