How to setup a coffeescript linter for developing an Atom package

I want to use an external linter for developing atom packages (e.g this one).

But in my CoffeeScript code:

 atom.notifications.addSuccess("Started")

I get warnings that

`atom` is an unresolved variable or type
`notifications` is an unresolved variable:

The code works without issue, but:

How should I make the linter aware of atom and its API (or apm if needed)?

I don’t have any require or import related to atom, and everything in my code is inside a

module.exports =

Depends on what linter you’re using. I don’t know if eslint works for .coffee files, but it has a configuration for atom: https://eslint.org/docs/user-guide/configuring#specifying-environments

You can also specify a list of globals: https://eslint.org/docs/user-guide/configuring#specifying-globals

I don’t see anything similar for http://www.coffeelint.org/, but I also have never used it, so I can’t say for sure it doesn’t have those.

Either way, you’ll get a better answer asking the community around whichever linter you use than asking the atom community, since a lot of atom packages are being decaffeinated.

2 Likes

Thank you for the answer. I am gonna try that.

Since I don’t get autocomplete for the atom API, I think my problem isn’t Coffee vs JS. JS gives the same error. I seems that it is more related to importing the atom library.

I think you’re talking about two unrelated things here. Autocompletions are not the same thing as linting.

If you have decided on a particular linter, posting a few things here will help us help you:

  • Which linter is it?
  • What version are you on?
  • What command are you running to execute the linter?
  • If you’re using a GUI atom package for the linter, do you get the same results on the command line?
  • What do you expect to see?
  • What do you actually see?

If you’re looking for autocompletions (specifically auto-completing the atom API bits from coffeescript), those come from https://github.com/atom/autocomplete-plus/wiki/Autocomplete-Providers . If you’re not seeing completions you expect to see, then you can file an issue on the relevant provider package or (even better) create a PR to add the completions you expect to see.

1 Like

Thank you for your answer.

I rewrote my package in TypeScript. Coffee script was causing issues.

My problem is solved by putting

  "devDependencies": {
    "@types/atom": "^1.40.1"
  },

in package.json, and installing it as a node_module.

I was using Jetbrains Webstorm. It was a library issue, which is solved now.

For anyone who finds this post looking for a CoffeeScript linter config for Atom packages:

1 Like