Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 5b40fa9

Browse files
committed
Merge pull request #45 from AtomLinter/various-tweaks
Various tweaks
2 parents 28beeb6 + d9e8684 commit 5b40fa9

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

lib/index.js

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,37 @@
33
import { Range } from 'atom';
44
import * as jsonlint from 'jsonlint';
55

6-
export default class LinterJsonLint {
6+
const regex = '.+?line\\s(\\d+)';
77

8-
static regex = '.+?line\\s(\\d+)';
9-
10-
static activate() {
11-
require('atom-package-deps').install();
12-
}
13-
14-
static provideLinter() {
15-
return {
16-
grammarScopes: ['source.json'],
17-
scope: 'file',
18-
lintOnFly: true,
19-
lint: editor => {
20-
const path = editor.getPath();
21-
const text = editor.getText();
22-
23-
try {
24-
jsonlint.parse(text);
25-
} catch (error) {
26-
const message = error.message;
27-
const line = Number(message.match(this.regex)[1]);
28-
const column = 0;
29-
30-
return Promise.resolve([{
31-
type: 'Error',
32-
text: error.message,
33-
filePath: path,
34-
range: new Range([line, column], [line, column + 1])
35-
}]);
36-
}
8+
export function activate() {
9+
require('atom-package-deps').install();
10+
}
3711

38-
return Promise.resolve([]);
12+
export function provideLinter() {
13+
return {
14+
grammarScopes: ['source.json'],
15+
scope: 'file',
16+
lintOnFly: true,
17+
lint: editor => {
18+
const path = editor.getPath();
19+
const text = editor.getText();
20+
21+
try {
22+
jsonlint.parse(text);
23+
} catch (error) {
24+
const message = error.message;
25+
const line = Number(message.match(regex)[1]);
26+
const column = 0;
27+
28+
return Promise.resolve([{
29+
type: 'Error',
30+
text: error.message,
31+
filePath: path,
32+
range: new Range([line, column], [line, column + 1])
33+
}]);
3934
}
40-
};
41-
}
35+
36+
return Promise.resolve([]);
37+
}
38+
};
4239
}

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
},
2626
"homepage": "https://github.com/AtomLinter/linter-jsonlint#readme",
2727
"dependencies": {
28-
"atom-linter": "^4.5.0",
28+
"atom-linter": "^4.6.1",
2929
"atom-package-deps": "^4.0.1",
3030
"jsonlint": "~1.6.2"
3131
},
3232
"devDependencies": {
33-
"babel-eslint": "^5.0.0",
34-
"eslint": "^2.2.0",
35-
"eslint-config-airbnb": "^6.0.1"
33+
"eslint": "^2.4.0",
34+
"eslint-config-airbnb": "^6.1.0"
3635
},
3736
"eslintConfig": {
3837
"rules": {
@@ -43,7 +42,6 @@
4342
"no-console": 0
4443
},
4544
"extends": "airbnb/base",
46-
"parser": "babel-eslint",
4745
"globals": {
4846
"atom": true
4947
},

0 commit comments

Comments
 (0)