get-alex / atom-linter-alex

Linter plugin using alex to catch insensitive, inconsiderate writing
MIT License
87 stars 6 forks source link

Ignore globs #8

Closed VikramTiwari closed 9 years ago

VikramTiwari commented 9 years ago

Though alex is great when I am writing documentations and comments in code, it causes random lint warnings on the configuration files (.conf). Haven't checked it on other such file types (JSON/YAML), but it would be a great addition if it were possible to ignore specific files, path and file types.

PS: Is there some already present option I am totally missing here?

wooorm commented 9 years ago

Hmm, ik not that familiar with atom here, but how this works in that a file in classified as some sort of syntax (E.g., 'plain-text'), which I think your '.conf' files are. In a alex-linter, I specify that plain text files should be liother

Do you know of other linters with similar settings?

VikramTiwari commented 9 years ago

@wooorm This might be helpful. https://github.com/yujinakayama/atom-lint/issues/25

wooorm commented 9 years ago

Thanks @VikramTiwari, but atom-linter-alex uses atom-linter instead of atom-lint (and I’m not planning to switch).

I just checked some linters based on atom-linter, and couldn’t find a single package which allowed this. I also couldn’t find an issue relating to this on atom-linter’s Issues. @steelbrain, have you ever seen this requested before?

steelbrain commented 9 years ago

@wooorm We definitely get requests for this, I've added https://github.com/atom-community/linter/pull/962 to the latest version, it should ignore the VCS ignored files. but we haven't agreed on a single way to ignore non-VCS ignored files. I mean, should it be a glob or a regex or what?

steelbrain commented 9 years ago

Be advised, this has been implemented in linter and will be a part of the next release. But you can still implement it in your package for provider-specific ignores by adding a glob config, matching the textEditor.getPath() with that glob and if it matches, returning an empty errors array.

wooorm commented 9 years ago

Thanks @steelbrain! Do you know of a package which implements such a settings for inspiration?

steelbrain commented 9 years ago

I don't think so but here's what it would look like

minimatch = require('minimatch') # You can use a normal regex instead of this if you want
module.exports = 
  config:
    ignoreFiles:
      type: 'string'
      default: '/**/*.min.css'
  ... other stuff ...
  provideLinter: ->
    linter =
      ... other stuff  ...
      lint: (textEditor) ->
        return [] if minimatch(textEditor.getPath(), atom.config.get('mylinter.ignoreFiles'))
        # Do normal linting
wooorm commented 9 years ago

Thanks so much!

Arcanemagus commented 9 years ago

Just an fyi, we are doing this already over in linter-phpcs, and allow an array of ignore patterns: https://github.com/AtomLinter/linter-phpcs/blob/master/lib/main.coffee#L91

If you wanted another example.