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

Update to support new linter APIs #16

Merged
merged 7 commits into from
Oct 15, 2015
Merged

Update to support new linter APIs #16

merged 7 commits into from
Oct 15, 2015

Conversation

artoale
Copy link
Contributor

@artoale artoale commented Oct 14, 2015

As reported in #10, #14 and #15, Linter APIs have changed.
This pull request is an attempt at fixing the issue.
It doesn't support ignored code - but it should at least work (since current implementation is not).
I suspect adding support for ignored codes would be good for another issue/pr.

Let me know if there's anything I should add/change.

@Arcanemagus
Copy link
Member

Can you update the README.md as well? It still references things like needing to install linter manually 😉.

lintOnFly: true
lint: (editor) =>
filePath = editor.getPath()
cwd = path.dirname(filePath)
Copy link
Member

Choose a reason for hiding this comment

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

path hasn't been imported, so it crashes on this line currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder why it's not on my local setup :) anyway - fixing now

@Arcanemagus
Copy link
Member

I think that's all the comments I have for now, if you want here is a .diff of the changes required to get this working, but it doesn't address all of the comments above:

diff --git a/lib/init.coffee b/lib/init.coffee
index 82065ea..8ca5a44 100644
--- a/lib/init.coffee
+++ b/lib/init.coffee
@@ -22,6 +22,7 @@ module.exports =
     @subscriptions.dispose()
   provideLinter: ->
     helpers = require('atom-linter')
+    path = require 'path'
     provider =
       name: 'gjslint'
       grammarScopes: ['source.js', 'source.js.jquery', 'text.html.basic']
@@ -37,7 +38,7 @@ module.exports =
             tmpFilePath
           ]
           return helpers.exec(@executablePath, params, {cwd}).then (stdout) ->
-            regex = /^Line\s(\d*)\, E\:(\d*):\s(.*)$/
+            regex = /Line\s(\d+), E:(\d+):\s(.+)/
             lines = stdout.split('\n').filter (line) ->
               line.indexOf('Line') == 0

@Arcanemagus
Copy link
Member

Btw, when this gets eventually gets merged make sure to file an issue to get this re-instated over here: https://github.com/AtomLinter/atomlinter.github.io

* Remove unnecessary escaping in RegEx
* Always match at least one digit/character
* Require path before using it :)
* Use `is` instead of `==`
* Include error code in the output message
* Return whole line instead of first char as range
@artoale
Copy link
Contributor Author

artoale commented Oct 15, 2015

@Arcanemagus I've updated the PR to (hopefully) cover all your comments

Please let me know if there's anything else I should be doing apart from reporting to atomlinter.github.io once this gets eventually merged.

A bit OT: is there a "standard" way to disable the plugin live? (As you might expect, not all the project I work on require gjslint validation, and what I usually have to do is disable the relevant linter and restart Atom. If there's a standard, more user friendly way, that requires code changed let me know, I'd be happy to create a new PR - otherwise would a plugin-specific setting work in your opinion? It should remove the unnecessary step of restarting Atom.

$ apm install linter-gjslint
```
## Installation
Run `amp install linter-gjslint` or search for `linter-gjslint` in atom package manager.
Copy link
Member

Choose a reason for hiding this comment

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

*Atom

@Arcanemagus
Copy link
Member

Some plugins have a setting that, when enabled, disable linting if a configuration file isn't found. That really only helps if the linter itself uses configuration files though.

You shouldn't need to restart Atom btw, just disabling the plugin should work (now that it's moved to the new linter API, the old API would always lint since it was somewhat running itself).

@Arcanemagus
Copy link
Member

@steelbrain this looks good to me (other than the slight README.md typo), any objections to merging this that you have? Also I would suggest that a team be created for this repo and @artoale be added as a maintainer, assuming you would want that @artoale 😉.

@artoale
Copy link
Contributor Author

artoale commented Oct 15, 2015

@Arcanemagus Thanks for the info - I haven't needed the "disable" feature since the new linter API, well, because of the purpose of this PR :)

I'll be very happy to help in maintaining this linter, if I can. I suspect it shouldn't require a massive effort in terms of time, so very happy to collaborate if needed!

lint: (editor) =>
filePath = editor.getPath()
cwd = path.dirname(filePath)
tempFile path.basename(filePath), editor.getText(), (tmpFilePath) =>

Choose a reason for hiding this comment

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

Is tempfile really necessary? I mean does it not support stdin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK no,
cat test.js | gjslint gives

0 files checked, no errors found.

So, I suspect no :(

Choose a reason for hiding this comment

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

google/closure-linter#96
We don't have to wait for it

@steelbrain
Copy link

Also you can completely drop the donation part in the readme

@steelbrain
Copy link

@artoale You should've recieved the github emails

@artoale
Copy link
Contributor Author

artoale commented Oct 15, 2015

@steelbrain Yeah, got the invitation :)

@steelbrain
Copy link

LGTM. Merge at will.

artoale added a commit that referenced this pull request Oct 15, 2015
Support new linter APIs
@artoale artoale merged commit 6e57034 into AtomLinter:master Oct 15, 2015
@artoale
Copy link
Contributor Author

artoale commented Oct 15, 2015

@steelbrain should I publish as well? if so, are we following a specific "definition" of how to use semver? (e.g. here we don't really change the API exposed - since well, we're just consuming some)

@steelbrain
Copy link

To publish a release clone the repo and do apm publish {major, minor, patch}. Major one would be cool as it's a complete rewrite.

@artoale artoale mentioned this pull request Oct 15, 2015
@Arcanemagus
Copy link
Member

Btw after doing an apm publish you can go here to GitHub and edit the tag that creates to mark it as the latest release here as well (since apm doesn't do that for some reason).

@artoale
Copy link
Contributor Author

artoale commented Oct 16, 2015

Oh, I see! Makes sense. Will do!

On Thu, Oct 15, 2015, 18:15 Landon Abney notifications@github.com wrote:

Btw after doing an apm publish you can go here to GitHub and edit the tag
that creates to mark it as the latest release here as well (since apm
doesn't do that for some reason).


Reply to this email directly or view it on GitHub
#16 (comment)
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants