In TextMate... menu
Bundles / Edit Bundles.... I didn't see a way to add a new Command, so I right-clicked an existing one (one with a
C icon for Command), selected
Find in Finder and just duplicated it. This way it appears in the bundle editor and you can tweak.. To create a new command, go
File / New and choose "Command" in the prompt.
PATH is in order
You need to have the path to
node and to
stylelint (likely the same) in your TextMate path preferences (menu TextMate / Preferences / Variables / PATH). To tell where node is, type `which node`.
Stylelint needs a config. See last post on how to setup a global one.
Setting up the new command
Here's a screenshot of my setup:
Basically run Stylelint when pressing CMD+L. Show the results in a tooltip.
And some magic to find the first error to move the cursor there:
#!/usr/bin/env ruby18 require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' error = `stylelint "$TM_FILEPATH"` if error.empty? puts 'No lint errors' else puts error TextMate.go_to :line => $1, :column => $2 if error =~ / (\d+):(\d+)/ end
And here is the whole integration in action. The lint finds an error and helpfully moves the cursor there.