How to use the eslint-module-utils/unambiguous.test 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
if (!hasValidExtension(path, context)) {
    exportCache.set(cacheKey, null)
    return null
  }

  // check for and cache ignore
  if (isIgnored(path, context)) {
    log('ignored path due to ignore settings:', path)
    exportCache.set(cacheKey, null)
    return null
  }

  const content = fs.readFileSync(path, { encoding: 'utf8' })

  // check for and cache unambigious modules
  if (!unambiguous.test(content)) {
    log('ignored path due to unambiguous regex:', path)
    exportCache.set(cacheKey, null)
    return null
  }

  log('cache miss', cacheKey, 'for path', path)
  exportMap = ExportMap.parse(path, content, context)

  // ambiguous modules return null
  if (exportMap == null) return null

  exportMap.mtime = stats.mtime

  exportCache.set(cacheKey, exportMap)
  return exportMap
}
github benmosher / eslint-plugin-import / tests / src / core / getExports.js View on Github external
it(`works for ${testFile} (${expectedRegexResult})`, function () {
        const content = fs.readFileSync('./tests/files/' + testFile, 'utf8')
        expect(unambiguous.test(content)).to.equal(expectedRegexResult)
      })
    }