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

Commit b226bfd

Browse files
authored
Merge pull request #98 from AtomLinter/arcanemagus/fix-eslint
Configure ESLint and cleanup code
2 parents f47efa8 + 2808ce9 commit b226bfd

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed

lib/main.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
1-
"use babel";
1+
'use babel';
22

33
export default {
44
config: {
55
rubyExecutablePath: {
6-
type: "string",
7-
default: "ruby"
6+
type: 'string',
7+
default: 'ruby',
88
},
99
ignoredExtensions: {
1010
type: 'array',
1111
default: ['erb', 'md'],
1212
items: {
13-
type: 'string'
14-
}
15-
}
13+
type: 'string',
14+
},
15+
},
1616
},
1717

1818
activate: () => {
1919
// We are now using steelbrain's package dependency package to install our
2020
// dependencies.
21-
require("atom-package-deps").install();
21+
require('atom-package-deps').install();
2222
},
2323

2424
provideLinter: () => {
25-
const helpers = require("atom-linter");
26-
const Path = require("path");
25+
const helpers = require('atom-linter');
26+
const Path = require('path');
2727
const regex = /.+:(\d+):\s*(.+?)[,:]\s(.+)/;
2828
return {
29-
name: "Ruby",
30-
grammarScopes: ["source.ruby", "source.ruby.rails", "source.ruby.rspec"],
31-
scope: "file",
29+
name: 'Ruby',
30+
grammarScopes: ['source.ruby', 'source.ruby.rails', 'source.ruby.rspec'],
31+
scope: 'file',
3232
lintOnFly: true,
3333
lint: (activeEditor) => {
34-
const command = atom.config.get("linter-ruby.rubyExecutablePath");
35-
const ignored = atom.config.get("linter-ruby.ignoredExtensions");
34+
const command = atom.config.get('linter-ruby.rubyExecutablePath');
35+
const ignored = atom.config.get('linter-ruby.ignoredExtensions');
3636
const filePath = activeEditor.getPath();
3737
const fileExtension = Path.extname(filePath).substr(1);
3838

39-
for (let extension of ignored) {
40-
if (fileExtension === extension) return [];
39+
if (ignored.includes(fileExtension)) {
40+
return [];
4141
}
4242

43-
return helpers.exec(command, ['-wc', '-E utf-8'], {stdin: activeEditor.getText(), stream: 'stderr'}).then(output => {
44-
var toReturn = [];
45-
output.split(/\r?\n/).forEach(function (line) {
43+
return helpers.exec(command, ['-wc', '-E utf-8'], { stdin: activeEditor.getText(), stream: 'stderr' }).then((output) => {
44+
const toReturn = [];
45+
output.split(/\r?\n/).forEach((line) => {
4646
const matches = regex.exec(line);
4747
if (matches === null) {
4848
return;
4949
}
50+
const msgLine = Number.parseInt(matches[1] - 1, 10);
5051
toReturn.push({
51-
range: helpers.rangeFromLineNumber(activeEditor, Number.parseInt((matches[1] - 1))),
52+
range: helpers.rangeFromLineNumber(activeEditor, msgLine),
5253
type: matches[2],
5354
text: matches[3],
54-
filePath: filePath
55+
filePath,
5556
});
5657
});
5758
return toReturn;
5859
});
59-
}
60+
},
6061
};
61-
}
62+
},
6263
};

package.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,34 @@
2424
"atom-package-deps": "^4.0.1"
2525
},
2626
"devDependencies": {
27-
"eslint": "latest"
27+
"eslint": "^3.9.1",
28+
"eslint-config-airbnb-base": "^10.0.1",
29+
"eslint-plugin-import": "^2.1.0"
2830
},
2931
"package-deps": [
3032
"linter"
3133
],
34+
"scripts": {
35+
"lint": "eslint .",
36+
"test": "apm test"
37+
},
3238
"eslintConfig": {
39+
"extends": "airbnb-base",
40+
"rules": {
41+
"global-require": "off",
42+
"import/no-unresolved": [
43+
"error",
44+
{
45+
"ignore": [
46+
"atom"
47+
]
48+
}
49+
]
50+
},
3351
"env": {
34-
"es6": true,
3552
"browser": true,
3653
"node": true
3754
},
38-
"ecmaFeatures": {
39-
"modules": true
40-
},
4155
"globals": {
4256
"atom": true
4357
}

0 commit comments

Comments
 (0)