您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關在sublime中實現代碼檢測的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
在sublime中配置linter, eslint
sublime插件安裝
打開pci,安裝sublimeLinter
進入到,對path進行配置:
● 配置node的基本位置:/usr/local/bin/node, /usr/local/bin
● 配置node_modules的基本位置:/usr/local/lib/node_modules
● 配置其他各項插件的位置:如eslint: /usr/local/bin/eslint
示例代碼如下:
"paths": { "linux": [], "osx": [ "/usr/local/bin/node", "/usr/local/lib/node_modules", "/usr/local/bin/eslint", "/usr/local/bin/jslint" ], "windows": [] }
安裝插件(以eslint為例):
安裝eslint的npm插件,包括:
● sudo npm i eslint babel-eslint -g
● 將所安裝的工具的路徑放到的path中,即:/usr/local/bin/eslint
● 在項目中配置.eslintrc文件,類似:(每個項目都需要配置)
● 當中包括非常多的依賴,可以在項目中輸入eslint .,然后根據提示對缺少的依賴進行sudo npm i -g ***
然后就可以愉快的使用啦!
可以通過右鍵進入到sublimelinter來調用其功能。
.eslintrc文件示例
{ "env": { "browser": true, "node": true, "es6": true }, "parser": "babel-eslint", "extends" : [ "airbnb" ], "plugins": [ "babel", "promise" ], "ecmaFeatures": { "jsx": true }, "rules": { "semi": [2, "always"], "quotes": [2, "single"] } }
最后
展示一下配置完成后的sublimelinter-user.settings:
{ "user": { "debug": true, "delay": 0.25, "error_color": "D02000", "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme", "gutter_theme_excludes": [], "lint_mode": "background", "linters": { "eslint": { "@disable": false, "args": [], "ecmaFeatures": { "jsx": true }, "env": { "browser": true, "es6": true, "node": true }, "excludes": [], "extends": [ "standard" ], "parser": "babel-eslint", "plugins": [ "babel", "promise" ], "rules": { "quotes": [ 2, "single" ], "semi": [ 2, "always" ] } }, "jsxhint": { "@disable": false, "args": [], "excludes": [] } }, "mark_style": "stippled underline", "no_column_highlights_line": false, "passive_warnings": false, "paths": { "linux": [], "osx": [ "/usr/local/bin/node", "/usr/local/lib/node_modules", "/usr/local/bin/eslint" ], "windows": [] }, "python_paths": { "linux": [], "osx": [], "windows": [] }, "rc_search_limit": 3, "shell_timeout": 10, "show_errors_on_save": false, "show_marks_in_minimap": true, "syntax_map": { "html (django)": "html", "html (rails)": "html", "html 5": "html", "javascript (babel)": "javascript", "magicpython": "python", "php": "html", "python django": "python", "pythonimproved": "python" }, "warning_color": "DDB700", "wrap_find": true } }
關于“在sublime中實現代碼檢測的方法”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。