'use babel'

import minimatch from 'minimatch'

export function showError(e) {
  atom.notifications.addError(`[Linter] ${e.message}`, {
    detail: e.stack,
    dismissable: true
  })
}

export function shouldTriggerLinter(linter, wasTriggeredOnChange, scopes) {
  if (wasTriggeredOnChange && !linter.lintOnFly) {
    return false
  }
  return scopes.some(function (scope) {
    return linter.grammarScopes.indexOf(scope) !== -1
  })
}

export function requestUpdateFrame(callback) {
  setTimeout(callback, 100)
}

export function debounce(callback, delay) {
  let timeout = null
  return function(arg) {
    clearTimeout(timeout)
    timeout = setTimeout(() => {
      callback.call(this, arg)
    }, delay)
  }
}

export function isPathIgnored(filePath, ignoredGlob) {
  const projectPaths = atom.project.getPaths()
  const projectPathsLength = projectPaths.length
  let   repository = null
  for (let i = 0; i < projectPathsLength; ++i) {
    const projectPath = projectPaths[i]
    if (filePath.indexOf(projectPath) === 0) {
      repository = atom.project.getRepositories()[i]
      break
    }
  }
  if (repository !== null && repository.isProjectAtRoot() && repository.isPathIgnored(filePath)) {
    return true
  }
  return minimatch(filePath, ignoredGlob)
}

@@ -434,287 +434,8 @@
 %0A%7D%0A%0A
-export function requestUpdateFrame(callback) %7B%0A  setTimeout(callback, 100)%0A%7D%0A%0Aexport function debounce(callback, delay) %7B%0A  let timeout = null%0A  return function(arg) %7B%0A    clearTimeout(timeout)%0A    timeout = setTimeout(() =%3E %7B%0A      callback.call(this, arg)%0A    %7D, delay)%0A  %7D%0A%7D%0A%0A
 expo
@@ -977,12 +977,293 @@
 oredGlob)%0A%7D%0A
+%0Aexport function messageKey(message) %7B%0A  return (message.text %7C%7C message.html) + '$' + message.class + '$' + message.name + '$' + (%0A    message.range ? (message.range.start.column + ':' + message.range.start.row + message.range.end.column + ':' + message.range.end.row) : ''%0A  )%0A%7D%0A

Add a message key helper; also cleanup unused