|
1 |
| -"use babel"; |
| 1 | +'use babel'; |
2 | 2 |
|
3 | 3 | export default {
|
4 | 4 | config: {
|
5 | 5 | rubyExecutablePath: {
|
6 |
| - type: "string", |
7 |
| - default: "ruby" |
| 6 | + type: 'string', |
| 7 | + default: 'ruby', |
8 | 8 | },
|
9 | 9 | ignoredExtensions: {
|
10 | 10 | type: 'array',
|
11 | 11 | default: ['erb', 'md'],
|
12 | 12 | items: {
|
13 |
| - type: 'string' |
14 |
| - } |
15 |
| - } |
| 13 | + type: 'string', |
| 14 | + }, |
| 15 | + }, |
16 | 16 | },
|
17 | 17 |
|
18 | 18 | activate: () => {
|
19 | 19 | // We are now using steelbrain's package dependency package to install our
|
20 | 20 | // dependencies.
|
21 |
| - require("atom-package-deps").install(); |
| 21 | + require('atom-package-deps').install(); |
22 | 22 | },
|
23 | 23 |
|
24 | 24 | provideLinter: () => {
|
25 |
| - const helpers = require("atom-linter"); |
26 |
| - const Path = require("path"); |
| 25 | + const helpers = require('atom-linter'); |
| 26 | + const Path = require('path'); |
27 | 27 | const regex = /.+:(\d+):\s*(.+?)[,:]\s(.+)/;
|
28 | 28 | 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', |
32 | 32 | lintOnFly: true,
|
33 | 33 | 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'); |
36 | 36 | const filePath = activeEditor.getPath();
|
37 | 37 | const fileExtension = Path.extname(filePath).substr(1);
|
38 | 38 |
|
39 |
| - for (let extension of ignored) { |
40 |
| - if (fileExtension === extension) return []; |
| 39 | + if (ignored.includes(fileExtension)) { |
| 40 | + return []; |
41 | 41 | }
|
42 | 42 |
|
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) => { |
46 | 46 | const matches = regex.exec(line);
|
47 | 47 | if (matches === null) {
|
48 | 48 | return;
|
49 | 49 | }
|
| 50 | + const msgLine = Number.parseInt(matches[1] - 1, 10); |
50 | 51 | toReturn.push({
|
51 |
| - range: helpers.rangeFromLineNumber(activeEditor, Number.parseInt((matches[1] - 1))), |
| 52 | + range: helpers.rangeFromLineNumber(activeEditor, msgLine), |
52 | 53 | type: matches[2],
|
53 | 54 | text: matches[3],
|
54 |
| - filePath: filePath |
| 55 | + filePath, |
55 | 56 | });
|
56 | 57 | });
|
57 | 58 | return toReturn;
|
58 | 59 | });
|
59 |
| - } |
| 60 | + }, |
60 | 61 | };
|
61 |
| - } |
| 62 | + }, |
62 | 63 | };
|
0 commit comments