Skip to content

ReactParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/apps/frontend-parser/src/parsers/react.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
namestring
versionstring
supportedPatternsstring[]

Where it refuses work

  • ReactParser stops the work with an early return when !name, in 3 places.
  • ReactParser stops the work with an early return when !/^[A-Z]/.test(name), in 2 places.
  • ReactParser stops the work with an early return when !this.canParse(filePath).
  • ReactParser stops the work with an early return when !fileContent.trim().
  • ReactParser stops the work with an early return when !t.isArrowFunctionExpression(init) && !t.isFunctionExpression(init).
  • ReactParser stops the work with an early return when !hasJSXInPath(path).

When something fails

  • ReactParser handles failure in 2 places: it turns it into a return value in all 2.

Was this page helpful?

Download as PDF