Home > Development Tools > sublime > Configuring ESLint in Sublime Text

Configuring ESLint in Sublime Text

藏色散人
Release: 2019-09-12 13:47:32
forward
2603 people have browsed it

Configuring ESLint in Sublime Text

ESLint

ESLint is an effective code quality control tool that can avoid low-level code errors based on pre-established code specifications. , and ensure the unity of code style. The sublime usage tutorial column below will introduce you to the method of configuring ESLint in Sublime Text.

Installation

You can use npm to install ESLint:

npm install eslint -g
Copy after login

Usage

If you are using ESLint for the first time, you need to set up a configuration file first. You can use the --init option in the project root directory to generate:

eslint --init
Copy after login

If there is no package.json file in the project root directory, it will prompt you to use npm init to initialize a package.json file.

eslint --init will prompt you to choose the code style to use. You can choose according to your needs. The following choices are recommended here:

Use a popular style guide
Standard
JavaScript
Copy after login

During this process, eslint will independently perform the npm install operation. to install related dependencies. After the installation is complete, please pay attention to whether there is a dependency on the UNMET PEER DEPENDENCY item. This means that NPM cannot automatically install this dependency. You need to install it manually:

# ├── UNMET PEER DEPENDENCY eslint-plugin-promise@^1.0.8
npm install eslint-plugin-promise --save-dev
Copy after login

Integrate Sublime Text

In Sublime Text you need to install two plug-ins:

SublimeLinter
SublimeLinter-contrib-eslint
Copy after login

Then integrate through Preferences->Package Settings->SublimeLinter->Settings - User:

{
    "user": {
        "debug": true, # 开启 debug 选项
        "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": [],
                "excludes": []
            },
            "jshint": {
                "@disable": false,
                "args": [],
                "excludes": []
            },
            "php": {
                "@disable": false,
                "args": [],
                "excludes": []
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [
                "/Users/wang/.nvm/versions/node/v5.0.0/bin" # 设置 node 路径
            ],
            "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
    }
}
Copy after login

At this point, the integration is complete. If the JavaScript code style in your project does not comply with the JavaScript Standard Style, Sublime Text will give an exception prompt.

The above is the detailed content of Configuring ESLint in Sublime Text. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jianshu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template