Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to configure ESLint in Sublime Text

Shulou Source: shulou.com Published: 2022-06-02 18:52:55 10月04日 Update

This article mainly introduces how to configure ESLint in Sublime Text, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

ESLint

ESLint is an effective code quality control tool, which can avoid low-level code errors and ensure the unity of code style according to pre-defined code specifications. Below, sublime uses the tutorials column to introduce how to configure ESLint in Sublime Text.

Installation

You can use npm to install ESLint:

Npm install eslint-g

Usage

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

Eslint-init

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

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

Use a popular style guideStandardJavaScript

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

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

Integrated Sublime Text

You need to install two plug-ins in Sublime Text:

SublimeLinterSublimeLinter-contrib-eslint

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

{"user": {"debug": true, # enable debug options "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" # set node path], "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}}

At this point, the integration is complete, and if the JavaScript code style in your project does not conform to JavaScript Standard Style, Sublime Text will give you an exception.

Thank you for reading this article carefully. I hope it will be helpful for everyone to share how to configure ESLint content in Sublime Text. At the same time, I also hope you can support us, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!

Tags: Code configuration file article project prompt selection method style root directory style Lai an low-level effective two value content and at the same time tools manual Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux MariaDB Shulou Tech Info Docker