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

Ignore extensions #37

Merged
merged 10 commits into from
Sep 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You can configure linter-ruby by editing ~/.atom/config.cson (choose Open Your C
```
'linter-ruby':
'rubyExecutablePath': null #ruby path. run 'which ruby' to find the path.
'ignoredExtensions': 'erb, md' #ignored extensions, ERB and markdown files by default.
```

## Contributing
Expand Down
15 changes: 15 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ export default {
rubyExecutablePath: {
type: "string",
default: "ruby"
},
ignoredExtensions: {
type: 'array',
default: ['erb', 'md'],
items: {
type: 'string'
}
}
},

Expand All @@ -31,14 +38,22 @@ export default {

provideLinter: () => {
const helpers = require("atom-linter");
const Path = require("path");
const regex = /.+:(\d+):\s*(.+?):\s(.+)/;
return {
grammarScopes: ["source.ruby", "source.ruby.rails", "source.ruby.rspec"],
scope: "file",
lintOnFly: true,
lint: (activeEditor) => {
const command = atom.config.get("linter-ruby.rubyExecutablePath");
const ignored = atom.config.get("linter-ruby.ignoredExtensions");
const filePath = activeEditor.getPath();
const fileExtension = Path.extname(filePath).substr(1);

for (let extension of ignored) {
if (fileExtension === extension) return [];
}

return helpers.exec(command, ['-wc'], {stdin: activeEditor.getText(), stream: 'stderr'}).then(output => {
var toReturn = [];
output.split(/\r?\n/).forEach(function (line) {
Expand Down