📄 parseConfig¶
📊 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¶
Parse a .eslintrc string into an object. This function is pretty naive, as it only validates rules and extends.
TODO: the user should probably write flat configs, but that requires work on the visual editor.
Raw JSDoc
Calls:
parseJSONObject (from ./json)ensureObject (from ./json)Array.isArrayconsole.error
Code
export function parseESLintRC(code?: string): EslintRC {
if (code) {
try {
const parsed = parseJSONObject(code);
parsed.rules = ensureObject(parsed.rules);
if (
!Array.isArray(parsed.extends) &&
typeof parsed.extends !== 'string'
) {
parsed.extends = [];
} else if (typeof parsed.extends === 'string') {
parsed.extends = [parsed.extends];
}
return parsed as unknown as EslintRC;
} catch (e) {
console.error(e);
}
}
return { extends: [], rules: {} };
}
parseTSConfig(code: string): TSConfig¶
Parse a tsconfig.json string into an object. This is done by typescript compiler.
Raw JSDoc
Calls:
window.ts.parseConfigFileTextToJsonconsole.errorisRecord (from ../ast/utils)
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: {} };
}
tryParseEslintModule(value: string): string¶
Evaluate a string that contains a module.exports assignment.
Calls:
moduleRegexp.testtoJson (from ./json)constrainedScopeEvalconsole.error
Code
constrainedScopeEval(obj: string): unknown¶
Parameters:
objstring
Returns: unknown
Calls:
complex_call_1683
Internal Comments:
Code
Generated by Syntax Scribe