A few days ago I noticed Brackets was no longer linting JSON files. I had recently updated so I assumed it was a bug with that particular extension. Like a good developer, I checked the console and when I didn't see anything, I filed a report and moved on. (For folks curious, the extension I was using is called "JSONLint Extension for Brackets" by Ingo Richter. Oh, and for what I used when it was't working - I used JSONLint.com.) Turns out the issue was a mistake I made in my preferences.
Brackets has a pretty complex preferences system. While there isn't a UI for it, you can open your global preferences file by going to the Debug menu and selecting Open Preferences File. Brackets ships with a linter for JavaScript files called JSLint. I have another extension that wraps JSHint that I prefer. By default, if Brackets sees multiple linters for a file, it will display issues from both:
That's not really ideal so I checked out the Preferences docs on how I could correct this.
I focused my attention on two settings: linting.prefer and lintingUsePrefferedOnly. The first lets you specify an order of preferred linters and the second specifies that you only want to use the preferred one. So I added this to my global preferences:
"linting.prefer": [
"JSHint"
],
"linting.usePreferredOnly": true,
Seems legit, right? I prefer JSHint and I only want to use that. However, this was the root of my issues. Because this preference was global, it applied to all file types. When reading the docs, I had focused in on the table of settings and missed this crucial detail:
Within either file, there are three levels of specificity at which you can set a preference:
- default - global (user-level file) or project-global (project-level file)
- "path" layer - overrides in effect for files that match the given path/filename wildcard
- "language" layer - overrides in effect for files that Brackets detects as the given programming language (this is also filename/extension based, but it's easier to work with since Brackets already understands many file extensions out of the box, and additional languages supported by Brackets extensions can automatically be used here too).
Basically, you can specify settings per language, which is what I needed to do for JavaScript. Here is the corrected version:
"language": {
"javascript": {
"linting.prefer": [
"JSHint"
],
"linting.usePreferredOnly": true
}
},
And that corrected it. In JavaScript I only see JSHint and my other linters work fine elsewhere. A big thank you to Randy Edmunds for pointing out my mistake.
Archived Comments
DUDE, THANKS A LOT!
You're a friggin life saver... I've been grinding on this college project for couple days now, and only JS and HTML and CSS are linting and that's because of the problem you described above. Lots of time was wasted while trying to figure this crap out but you saved my day! I'm runnin' full-stack on this shizzle and really needed this.
Again thank you for writing this blog man.
You are most welcome.
Wow 70< errors and suggestions in just one 150-line PHP file! Sporting PHP Quality Tools (uses CodeSniffer).
And oh it appears JSHint was set in global to be used for all files, similarly to what you suggested in this awesome blog post.
Thanks a lot. I was searching for exactly the same thing.