How to use the prettierx.resolveConfig function in prettierx

To help you get started, we’ve selected a few prettierx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sheerun / prettier-standard / src / cli.js View on Github external
const options = {}

  if (flags.parser) {
    options.parser = flags.parser
  }

  if (hasStdin) {
    const stdin = await getStdin()

    options.filepath = '(stdin)'

    if (flags['stdin-filepath']) {
      Object.assign(
        options,
        prettierx.resolveConfig.sync(flags['stdin-filepath'], {
          editorconfig: true
        })
      )
    }

    try {
      if (flags.check) {
        const valid = check(stdin, options)
        if (!valid) {
          console.log('(stdin)')
          return 1
        }
      } else {
        const output = format(stdin, options)
        process.stdout.write(output)
      }
github sheerun / prettier-standard / src / index.js View on Github external
for (const file of files) {
    const start = Date.now()
    const { filepath, changes } = file

    const fullpath = path.join(root, filepath)
    const input = fs.readFileSync(fullpath, 'utf8')

    let ranges
    if (config.lines && changes) {
      ranges = getRanges(input, changes)
    }

    const fileOptions = Object.assign(
      {},
      prettierx.resolveConfig.sync(fullpath, {
        editorconfig: true
      }),
      config.options,
      { filepath: fullpath }
    )

    const fileInfo = prettierx.getFileInfo.sync(fullpath, {})

    if (!fileOptions.parser) {
      fileOptions.parser = fileInfo.inferredParser
    }

    if (config.check) {
      const formatted = checkWithRanges(input, ranges, fileOptions)

      let report
github sheerun / prettier-standard / src / index.js View on Github external
file: filepath,
      runtime: Date.now() - start,
      formatted,
      report,
      check: config.check
    })
  }
}

module.exports = {
  format,
  check,
  run,
  getFileInfo,
  formatWithCursor,
  resolveConfig: prettierx.resolveConfig,
  clearConfigCache: prettierx.clearConfigCache,
  getSupportInfo: prettierx.getSupportInfo
}

prettierx

prettierX - a less opinionated fork of the Prettier code formatter

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis