How to use the eslint-module-utils/parse function in eslint-module-utils

To help you get started, we’ve selected a few eslint-module-utils 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 benmosher / eslint-plugin-import / src / ExportMap.js View on Github external
ExportMap.parse = function (path, content, context) {
  var m = new ExportMap(path)

  try {
    var ast = parse(path, content, context)
  } catch (err) {
    log('parse error:', path, err)
    m.errors.push(err)
    return m // can't continue
  }

  if (!unambiguous.isModule(ast)) return null

  const docstyle = (context.settings && context.settings['import/docstyle']) || ['jsdoc']
  const docStyleParsers = {}
  docstyle.forEach(style => {
    docStyleParsers[style] = availableDocStyleParsers[style]
  })

  // attempt to collect module doc
  if (ast.comments) {
github benmosher / eslint-plugin-import / tests / src / core / parse.js View on Github external
    expect(() => parse(path, content, { settings: {}, parserPath: 'espree', parserOptions: { ecmaVersion: 2015, sourceType: 'module', ecmaFeatures: { jsx: true } } }))
      .not.to.throw(Error)