资讯专栏INFORMATION COLUMN

在sublime中实现代码检测

tain335 / 3045人阅读

在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
    }
}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/81139.html

相关文章

  • 工欲善其事,必先利其器 _SUBLIME TEXT 3_使用心得(上篇)

    摘要:的主要功能包括拼写检查,书签,完整的,功能,即时项目切换,多选择,多窗口等等。缺点是一款收费软件,不过可以无限期使用。举个栗子快速选中并更改所有相同的变量名函数名等。设置书签,切换书签左右字母互换。 Sublime text 简介 Sublime text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Tex...

    endless_road 评论0 收藏0
  • sublime的js代码检测的插件(by jshint)

    项目地址:Sublime-JSHint 安装 Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X 输入 install, 选择 Package Control: Install Package 输入 js gutter, 选择 JSHint Gutter 配置 Ctrl+Shift+P or Cmd+Shift+P 输入 jshint, 选择 ...

    Pandaaa 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<