This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (51 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use babel'
import { CompositeDisposable } from 'atom'
import * as helpers from 'atom-linter'
import { dirname } from 'path'
import { install as installDeps } from 'atom-package-deps'
import { execSync } from 'child_process'
const regex = /^.*:(\d+):(\d+): ([WE]): (.+)$/gm
export const provideLinter = () => ({
name: 'Dogma',
grammarScopes: ['source.elixir'],
scope: 'file',
lintsOnChange: false,
lint: async (textEditor) => {
filePath = textEditor.getPath()
const output = await helpers.exec(
atom.config.get('linter-elixir-dogma.executablePath'),
['dogma', filePath, '--format=flycheck'],
{
ignoreExitCode: true,
cwd: atom.project.rootDirectories[0].path,
}
)
let results
const messages = []
while((results = regex.exec(output)) !== null) {
const lineNumber = parseInt(results[1], 10) - 1
const lineColumn = parseInt(results[2], 10) - 1
const severity = results[3] === 'E' ? 'error' : 'warning'
const message = results[4]
messages.push({
location: {
file: filePath,
position: [[lineNumber, lineColumn], [lineNumber, lineColumn]],
},
excerpt: message,
severity,
})
}
return messages
},
})
export const activate = () =>
installDeps('linter')
export const config = {
executablePath: {
type: 'string',
default: 'mix',
description: 'Absolute path to the mix executable on your system.' +
'Example: /usr/local/bin/mix , by default it checks for mix in your path'
}
}