0
votes

I installed SublimeLinter for linting JavaScript in Sublime. It works, but i want to change it's settings so it'll always detect unused variables. I managed to do it by adding // jshint unused:true to top of the .js file itself, but i want to make it default so it'll always work.

I tried adding the setting to the SublimeLinter user settings in SublimeText, but it didn't work:

"user": {
    "debug": false,
    "delay": 0.25,
    "error_color": "D02000",
    "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
    "gutter_theme_excludes": [],
    "lint_mode": "background",
    "linters": {
        "jshint": {
            "@disable": false,
            "args": [],
            "excludes": [],
            "unused": true,  <-------- THIS
            "ignore_match": ["Missing semicolon"]
        }
    },
1
Per the documentation you can either create a config file called .jshintrc in the root directory of your projects, or you can include the settings in your package.json. If you want this to be global to all projects, you can create a .jshintrc at the root directory. - Alexander Nied
I can't make a file named .jshintrc (under windows), the file must have a file name before the extension. - moonlander

1 Answers

0
votes

I managed to create the .jshintsrc file under windows thanks to the tip from Alexander Nied. That is: Name the file ".jshintsrc.", windows explorer will drop the last dot when you hit enter. I created the file in C:\ but probably can be put in other paths.

The settings i used for my .jshintsrc file, for NodeJS development:

{
    "undef": true,
    "unused": true,
    "node": true,
    "globals": {
        "MY_GLOBAL": true
    }
}