Skip to content

JsonConfigParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/apps/config-docs-parser/src/parsers/json-config.parser.ts

Implements: IParser

Methods

MethodSignatureReturns
initializeinitialize(config: ParserConfig)Promise<void>
canParsecanParse(filePath: string)boolean
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>
parseFilesparseFiles(files: ParseFileInput[])Promise<ParseResult[]>
destroydestroy()Promise<void>

Properties

PropertyType
nameany
versionany
supportedPatternsany

Where it refuses work

  • JsonConfigParser stops the work with Error when !content — “Content is required for parsing”.
  • JsonConfigParser stops the work with an early return when fileName === 'package.json'.
  • JsonConfigParser stops the work with an early return when fileName.startsWith('tsconfig') || parsed.compilerOptions.
  • JsonConfigParser stops the work with an early return when fileName.includes('eslint') || parsed.rules || parsed.extends.
  • JsonConfigParser stops the work with an early return when fileName.includes('prettier').
  • JsonConfigParser stops the work with an early return when fileName.includes('jest') || parsed.testEnvironment || parsed.testMatch.

When something fails

  • JsonConfigParser handles failure in 1 place: it turns it into a return value in all 1.

Was this page helpful?

Download as PDF