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 4 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,10 @@ export default {
rubyExecutablePath: {
type: "string",
default: "ruby"
},
ignoredExtensions: {
type: "string",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignoredExtensions: {
  type: 'array',
  default: ['erb', 'md'],
  items: {
    type: 'string'
  }
}

default: "erb,md"
}
},

Expand Down Expand Up @@ -38,7 +42,18 @@ export default {
lintOnFly: true,
lint: (activeEditor) => {
const command = atom.config.get("linter-ruby.rubyExecutablePath");
const ignored = atom.config.get("linter-ruby.ignoredExtensions");
const filePath = activeEditor.getPath();
var ignore = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const fileExtension = Path.extname(filePath).substr(1)
documentation for Path.extname
Also, you should do const Path = require('path') where the helpers are defined.


ignored.split(",").forEach(function (extension) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You won't have to split if you make it an array. Also you should do for...of instead of foreach, You won't have to use the ignore variable then, you can just return from the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks again 👍

if (filePath.split(".").pop() === extension.trim()) {
ignore = true;
};
});

if (ignore) return [];

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