Linting with SublimeLinter

Linting is a term for flagging suspicious and non-portable constructs, likely to be bugs in any written language. SublimeLinter is a plugin that supports linting and has the following linters built in:

  • C/C++: This lints via cppcheck
  • CoffeeScript: This lints via coffee –s –l
  • CSS: This lints via built-in csslint
  • Haml: This checks syntax via haml –c
  • HTML: This lints via tidy
  • Java: This lints via javac –Xlint
  • JavaScript: This lints via built in jshint, jslint, or gjslint (if installed)
  • Lua: This checks syntax via luac
  • Objective-J: This lints via built in capp_lint
  • Perl: This lints via Perl::Critic or syntax and deprecation check via perl-c
  • PHP: This checks syntax via php –l
  • Puppet: This checks syntax via puppet parser validate
  • Python: This is a native, moderately-complete lint
  • Ruby: This checks syntax via ruby –wc
  • XML: This lints via xmllint

Installing SublimeLinter

We can install this plugin by using the Package Control that we installed earlier. Let's open it by pressing Ctrl + Shift + P in Windows or Linux and command + Shift + P in OS X; choose Install Package and install the SublimeLinter plugin.

Using SublimeLinter

SublimeLinter can run in four different modes; the current mode is set by the sublimelinter key in the user settings:

  • Background mode (default): When the sublimelinter key is set to true, linting is performed constantly in the background while we modify the file.
  • Load-save mode: When the sublimelinter key is set to load-save, linting will be performed when a file is loaded and after the file is saved.
  • Save-only mode: When the sublimelinter key is set to save-only, linting is performed only after a file is saved.
  • On demand Mode: When the sublimelinter key is set to false, linting will only be initiated by us. We can initiate a lint by pressing Ctrl + Alt + L on Windows or Linux and Control + command + L on OS X.

We can also control all SublimeLinter settings and initiate an instant lint fromthe command palette. Press Ctrl + Shift + P or command + Shift + P and type SublimeLinter:; you will see all the options for quick linting and quick mode changing.

Configuring SublimeLinter

There are a number of customizations that SublimeLinter supports:

  • Custom Linters
  • Per project settings
  • Customizing colors

We won't cover these customizations in this book, but we can always go to https://github.com/SublimeLinter/SublimeLinter, and learn more about them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset