jshint and sublimelinter settings config on mac

不羁的心 提交于 2019-12-01 09:45:44

问题


I'm trying to configure sublimelinter, specifically jshint on my Mac. On my windows version of SublimeText there is the following section in SublimeLinter.sublime-settings

 "jshint_options":
    {
        // To fix column positions for JSHint errors you may want to add `"indent": 1` to your
        // **User** "jshint_options". This issue affects users with tabs for indentation.
        // This fix was reverted due to a conflict with using the `"white": true` option.
        // "indent": 1,
        "evil": true,
        "regexdash": true,
        "browser": true,
        "wsh": true,
        "trailing": true,
        "sub": true
    },

When I view the file on my Mac this section doesn't exist, is there a place to edit these option on the Mac version without a separate settings file? Or a global settings file for jshint?

I've been digging through similar questions but haven't found a clear solution.

Update:

Actually it doesn't seem to catch any errors at all when using it on the console. My javascript file doesn't end in .js how can I configure it to look at different extensions? I can't find it in the docs.


回答1:


In general I would recommend against configuring JSHint system-wide. It's usually safer to create a .jshintrc file for each project your work on because it's likely they will have different JSHint requirements.

The jshint_options SublimeLinter setting you mention in your question is from the old version of SublimeLinter, which has recently been reworked to have a simple plugin architecture. The JSHint plugin (which I assume you are using, since the settings you tried didn't work) makes the same recommendation:

You can configure jshint options in the way you would from the command line, with .jshintrc files.

The added benefit of this approach is that you can commit the .jshintrc file to your repository and ensure that anyone who works on the project is working with the same JSHint rules, rather than their own system-wide settings.




回答2:


There's another way to set options globally, without using ".jshintrc" files.
1) create a file with any name (e.g. "jshint.conf"). my file is:

{
  "globals": { "$": false },
  "globalstrict": true,
  "devel": true
}

2) put it anywhere. in my case it is: "c:\Users\Smith\AppData\Roaming\Sublime Text 3\Packages\User\"

3) make the next reference in section "jshint"->"args" of sublime-linter user setting (user/SublimeLinter.sublime-settings):

{
    "user": {
        "linters": {
            "jshint": {
                "args": [
                    "--config", "c:\\Users\\Smith\\AppData\\Roaming\\Sublime Text 3\\Packages\\User\\jshint.conf"
                ]
            }
        }
    }
}

4) Enjoy!



来源:https://stackoverflow.com/questions/24194603/jshint-and-sublimelinter-settings-config-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!