5

I collaborate on several javascript projects. Some of them use eslint, some others use standard. This is projects are maintained by different and unrelated teams, so forcing them to use the same linter is not an option.

I use Sublime Text 3, and it seems that when I install SublimeLinter plugin, plus SublimeLinter-contrib-standard and SublimeLinter-eslint, they end up both being active, so it's not clear when an error is highlighted in an editor, which linter generated it.

To add to the confusion, SublimeLinter-contrib-standard offers a "format on save" option that applies standard formatting when a file is saved, for example removing all semicolons. But this shouldn't be done for the project thay relies on eslint and has a different set of linter rules to apply, for example maybe they DO use semicolons.

So, how can I configure my development environment to be able to use whatever linter the project relies on?

I've tried:

  • creating a .sublime-project file on the root directory of the project specifying @disable: true for the linters I don't want to be active, but it didn't had any effect (See http://www.sublimelinter.com/en/latest/settings.html#project-settings)
  • creating a .sublimelinterrc with the same options, but still no effect.
  • disabling "format on save" for standard linter only avoid the problem of the file being modified, but the linter is still active and highlighting errors
  • I've read this GitHub issue for SublimeLinter project, where they closed it but then several people report it's not working for them
  • Adding a file to the repo is not a problem, I can commit a .eslintrc, a .sublime.project or whatever files helps achieving this. As mentioned before, I've tried this particular files to no avail.

How can I have different linters enabled per-project for the same language (javascript)? I imagine this has to be a very common use case, specially for people collaborating in different open source project which may adhere to different coding standards.

I'm thinking about switching to another editor that handles this better. Maybe https://code.visualstudio.com/? If anyone has comments about this or other editors handling this better, I'd appreciate it as well.

Thanks!

jotadepicas
  • 2,389
  • 2
  • 26
  • 48

2 Answers2

4

Following the documentation, you should add linter settings at .sublime-project file of your project. If you just created the file, try to open as project (or just save the current project and change the file again).

For example, to change "disable" option, your file should look like that:

{
    "folders":
    [
        ...
    ],
    "settings":
    {
        "SublimeLinter.linters.eslint.disable": true
    }
}

Remember:

Only the "linters" settings in can be changed in a project.

Oh. A extra point:

(...) they end up both being active, so it's not clear when an error is highlighted in an editor, which linter generated it.

Well. I use phpcs and phpmd and I can check the lint's name when hovering the error dot:

PHPCS error message with identification

Check show_hover_line_report and show_hover_region_report settings for that.

Mário Valney
  • 123
  • 1
  • 11
1

Your first bullit is on the right track. The setting is “disable” though, without the @. The documentation you link to has the right information, so try again, it should work,

Koen Lageveen
  • 174
  • 1
  • 3