当前位置:   article > 正文

Sublime Text 3使用SublimeLinter配置JS,CSS,HTML语法检查

no_column_highlights_line": true

安装Package Control

  Sublime安装插件有两种方式,一种是直接下载安装包解压缩到Packages目录,另一种是通过Package Control组件来安装组件,后者更加的方便。

打开Sublime,按control + ` 打开控制台,粘贴如下代码到命令行并回车;

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp =   sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())  

重启Sublime,在Perferences->Package Settings 中看到 Package Control,则表示安装成功。

安装SublimeLinter

  SublimeLinter是Sublime的一个代码检测工具插件。
安装SublimeLinter前必须安装node.js

  • 打开Sublime,按下 Ctrl+Shift+p 进入 Command Palette;

  • 输入install进入 Package Control: Install Package;

  • 输入SublimeLinter,选择SublimeLinter进行安装。


安装sublimeLinter-contrib-htmlhint

  可以把sublimeLinter-contrib-htmlhint看成是SublimeLinter的一个插件,sublimeLinter-contrib-htmlhint调用xg-htmlhint来进行语法检查。sublimeLinter-contrib-htmlhint 1.0.1版本有问题,所以我们使用1.0.0版本。

  • 前往Releases下载1.0.0的压缩包,解压并重命名为“SublimeLinter-contrib-htmlhint”,并放入Sublime的Package目录(菜单->Preferences->Browse
    Packages)

安装xg-htmlhint

图片描述

找到node.js的CMD窗口,输入以下命令;等待出现一堆数字版本号即为成功安装。

npm install -g xg-htmlhint

  此时打开Sublime Text3,xg-htmlhint就可以检测代码了,保存(cmd + S)的时候如果有错误会有错误提示。


安装jshint和csslint

打开Sublime_Txt3,按住Ctrl+Shift+P安装

  1. Sublime​Linter-csslint
  2. Sublime​Linter-jshint

打开nodejs的CDM窗口,输入命令安装

  1. npm install jshint
  2. npm install csslint

SublimeLinter个性化配置

  1. {
  2. "user": {
  3. "csslint_options": {
  4. "adjoining-classes": false,
  5. "box-model": false,
  6. "box-sizing": false,
  7. "compatible-vendor-prefixes": false,
  8. "floats": false,
  9. "font-sizes": false,
  10. "gradients": false,
  11. "important": false,
  12. "known-properties": false,
  13. "outline-none": false,
  14. "qualified-headings": false,
  15. "regex-selectors": false,
  16. "shorthand": false,
  17. "text-indent": false,
  18. "unique-headings": false,
  19. "universal-selector": false,
  20. "unqualified-attributes": false
  21. },
  22. "debug": false,
  23. "delay": 0.25,
  24. "error_color": "D02000",
  25. "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
  26. "gutter_theme_excludes": [],
  27. "jshint_options": {
  28. "browser": true,
  29. "curly": true,
  30. "devel": true,
  31. "eqeqeq": true,
  32. "evil": true,
  33. "forin": true,
  34. "globals": {
  35. "$": true,
  36. "console": true,
  37. "document": true,
  38. "global": true,
  39. "grunt": true,
  40. "jQuery": true,
  41. "module": true,
  42. "setInterval": true,
  43. "setTimeout": true,
  44. "window": true
  45. },
  46. "jquery": true,
  47. "latedef": true,
  48. "noarg": true,
  49. "noempty": true,
  50. "quotmark": "single",
  51. "strict": false,
  52. "undef": true,
  53. "unused": "vars",
  54. "wsh": true
  55. },
  56. "lint_mode": "background",
  57. "linters": {
  58. "csslint": {
  59. "@disable": false,
  60. "args": [],
  61. "errors": "",
  62. "excludes": [],
  63. "ignore": "",
  64. "warnings": ""
  65. },
  66. "htmlhint": {
  67. "@disable": false,
  68. "args": [],
  69. "excludes": []
  70. },
  71. "jshint": {
  72. "@disable": false,
  73. "args": [],
  74. "excludes": []
  75. }
  76. },
  77. "mark_style": "outline",
  78. "no_column_highlights_line": false,
  79. "passive_warnings": false,
  80. "paths": {
  81. "linux": [],
  82. "osx": [],
  83. "windows": []
  84. },
  85. "python_paths": {
  86. "linux": [],
  87. "osx": [],
  88. "windows": []
  89. },
  90. "rc_search_limit": 3,
  91. "shell_timeout": 10,
  92. "show_errors_on_save": false,
  93. "show_marks_in_minimap": true,
  94. "sublimelinter": "save-only",
  95. "sublimelinter_executable_map": {
  96. "css": "C:/Program Files/nodejs/node.exe",
  97. "javascript": "C:/Program Files/nodejs/node.exe"
  98. },
  99. "sublimelinter_gutter_marks": true,
  100. "sublimelinter_popup_errors_on_save": true,
  101. "syntax_map": {
  102. "html (django)": "html",
  103. "html (rails)": "html",
  104. "html 5": "html",
  105. "javascript (babel)": "javascript",
  106. "magicpython": "python",
  107. "php": "html",
  108. "python django": "python"
  109. },
  110. "warning_color": "DDB700",
  111. "wrap_find": true
  112. }
  113. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/79645
推荐阅读
相关标签
  

闽ICP备14008679号