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

Transition package to new linter provider API #58

Merged
merged 7 commits into from
Jul 26, 2015

Conversation

proman21
Copy link
Contributor

Hi

I've done some work converting this package to the new Linter API, just using the examples as reference and trying to import as much functionality from the old version.

One problem I'm having is that the process always exits with status code 127 for me, which is the sh default for 'executable not found', even though the executable exists in the path I provide in config.

Any ideas would be appreciated.


This change is Reviewable

@rjfranco
Copy link

Nice! Thanks @proman21

@proman21
Copy link
Contributor Author

OK just found the reason I was getting exit code 127 for my env. I'm using rvm, and since Atom launched from icon doesn't inherit env, it would fail. I've tried with a system install and it seems to be good.

However, I've now run into the problem that scss-lint return with exit code 66 and outputs

"No such file or directory - ↵"

For any file I throw at it. I'm not skilled enough to introspect the spawned process to make sure the argument is being passed properly, but I cannot get passed the error.

filePath = editor.getPath()
resultJson = []
config = findFile path.dirname(filePath), '.scss-lint.yml'
process = new BufferedProcess
Copy link
Contributor

Choose a reason for hiding this comment

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

How about you use the helper modules that we've packaged as atom-linter in npm.
It has a very nice execution API that also supports executing node bins using atom as a node binary.

@steelbrain
Copy link
Contributor

Also, make sure to remove the old outdated files

@proman21
Copy link
Contributor Author

Thanks steelbrain. I'm not really familiar with the linter and Atom API. Could you post some links to some stuff to help? Thanks if you can.

@steelbrain
Copy link
Contributor

This is the Migration Guide and this is the full API guide. and here's a list of linters transitioned to the new API, their source code will trigger new ideas for you. Or if you want a simple one see linter-php and linter-jshint for a node version.

@caseywebdev
Copy link
Contributor

Having just written AtomLinter/linter-rubocop#54, it appears that lintOnFly will not work here as Linter is no longer creating a temp file.

@steelbrain
Copy link
Contributor

@caseywebdev we have worked around the writing to file by writing to stdin of the linters, You can see that linter-jshint. It's more efficient and faster.

@caseywebdev
Copy link
Contributor

That makes sense when the linter accepts stdin as input, but AFAIK scss-lint does not. I believe it only will lint a file that's written to disk.

@proman21
Copy link
Contributor Author

Just applied some of the refactoring suggested by @steelbrain, also got config and additional params to work, even if empty.

filePath: filePath,
range: [[line, col], [line, col + (msg.length || 0)]]
else return []
.catch (error) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't really need to catch it, linter does it itself IIRC

@steelbrain
Copy link
Contributor

Nice work so far 👏

@steelbrain
Copy link
Contributor

Also, congratulations on your first PR 🎉

@proman21
Copy link
Contributor Author

Thanks for the help @steelbrain. should be all done now

@steelbrain
Copy link
Contributor

Looks good to me, will merge after confirming that it works.

@proman21
Copy link
Contributor Author

Might be a good idea to include some of this help in the linter API wiki. Wiki doesn't explain things like the promise rejection notifications or the existence of the helper methods.

text: (msg.reason || 'Unknown Error') +
(if msg.linter then " (#{msg.linter})" else ''),
filePath: filePath,
range: [[line, col], [line, col + (msg.length || 0)]]
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just do +1 instead of doing msg.length.
As the length of the error message has nothing to do with the buffer itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The length field isn't the length of the lint message, its the length of the warning/error in the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Acknowledged. Thanks.

@steelbrain
Copy link
Contributor

I agree with you, that's why we've put the documentation in a wiki instead of a repo, anyone can edit/correct/expand it :)

@steelbrain
Copy link
Contributor

I just tested it and it works, now here's some last recommendations

  • Throw a nice error if the executable path is empty/null
  • Remove the old linter-scss-lint.coffee file from codebase

@caseywebdev
Copy link
Contributor

If I'm reading this correctly lintOnFly will not work anymore? That's a huge hit on my workflow. I think we need to do the same thing rubocop is doing and use a temp file.

@steelbrain
Copy link
Contributor

@caseywebdev Disabling lintOnFly for linters who doesn't support write via stdin is a fair trade, You will find me and others from the team in #linter of Atom Slack, wanna discuss this there?

@caseywebdev
Copy link
Contributor

Alright

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

Successfully merging this pull request may close these issues.

4 participants