How to use the eslint-module-utils/hash.hashObject 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.for = function (context) {
  const { path } = context

  const cacheKey = hashObject(context).digest('hex')
  let exportMap = exportCache.get(cacheKey)

  // return cached ignore
  if (exportMap === null) return null

  const stats = fs.statSync(path)
  if (exportMap != null) {
    // date equality check
    if (exportMap.mtime - stats.mtime === 0) {
      return exportMap
    }
    // future: check content equality?
  }

  // check valid extensions first
  if (!hasValidExtension(path, context)) {
github benmosher / eslint-plugin-import / memo-parser / index.js View on Github external
exports.parse = function parse(content, options) {
  options = Object.assign({}, options, parserOptions)

  if (!options.filePath) {
    throw new Error('no file path provided!')
  }

  const keyHash = crypto.createHash('sha256')
  keyHash.update(content)
  hashObject(options, keyHash)

  const key = keyHash.digest('hex')

  let ast = cache.get(key)
  if (ast != null) return ast

  const realParser = moduleRequire(options.parser)

  ast = realParser.parse(content, options)
  cache.set(key, ast)

  return ast
}