sublime 消除鋸齒_如何在Sublime中消除麻煩

sublime 消除鋸齒

by Abdul Kadir

通過阿卜杜勒·卡迪爾(Abdul Kadir)

如何在Sublime中消除麻煩 (How to lint away your troubles in Sublime)

Sublime is a lightweight text editor and is quite popular among many web developers. Now I know there are many sophisticated IDEs in the market with intellisense, code completion, and whatnot. But this post is for those who have remained loyal to their favorite text editors! So if you use Sublime for your projects, then you might enjoy some of the nifty features it offers. Linting is one of them.

Sublime是一個輕量級的文本編輯器,在許多Web開發人員中都非常流行。 現在,我知道市場上有許多具有智能感知,代碼完成等功能的高級IDE。 但是這篇文章是為那些仍然忠于自己喜歡的文本編輯器的人而設計的! 因此,如果將Sublime用于您的項目,那么您可能會喜歡它提供的一些精美功能。 棉絨就是其中之一。

Let’s start off by defining the term “Linting”.

讓我們從定義術語“棉絨”開始。

Linting is the process of checking your code for potential errors. This could be either the syntax or the code style.
整理是檢查代碼中是否存在潛在錯誤的過程。 這可以是語法,也可以是代碼樣式。

The linting process can be done during three stages of development:

整理過程可以在開發的三個階段完成:

  1. Via your editor (live linting)

    通過您的編輯器(實時整理)
  2. Through the build process

    通過構建過程
  3. Using a pre-commit hook in version control

    在版本控制中使用預提交掛鉤

In this post, we will explore live linting in the editor. There are many popular linters out there for JavaScript like JSHint, JSCS, and ESLint. I’ll be using ESLint, because ESLint supports ES6 code, is highly extensible, and is very easy to use. If you’re interested, you can look at the comparisons between the different linters over here!

在本文中,我們將探討編輯器中的實時棉絮。 有許多流行的針對Java的linter,例如JSHint,JSCS和ESLint。 我將使用ESLint,因為ESLint支持ES6代碼,具有高度可擴展性,并且非常易于使用。 如果您有興趣,可以在這里查看不同棉短絨之間的比較!

第1步 (Step 1)

You need to first install the ESLint npm package. The command is as follows:

您需要先安裝ESLint npm軟件包。 命令如下:

npm install -g eslint

The ‘-g’ option is to install the package on the global. Install ‘npm’ if you do not already have it installed. A file will open up in Sublime asking you to download two other plugins. You need to install these plugins using Sublime’s Package Control.

'-g'選項是在全局上安裝軟件包。 如果尚未安裝,請安裝“ npm”。 Sublime中將打開一個文件,要求您下載另外兩個插件。 您需要使用Sublime的Package Control安裝這些插件。

Open up the package control using command/ctrl + shift + P and select the ‘Package Control: Install Package’ option. Then download the two plugins.

使用command / ctrl + shift + P打開程序包控件,然后選擇“程序包控件:安裝程序包”選項。 然后下載兩個插件。

  1. SublimeLinter-eslint

    崇高的品味
  2. SublimeLinter-contrib-eslint

    崇高的品德

SublimeLinter is the framework that provides linting. It does not come with support for different languages. The language-specific Linter must be installed separately.

SublimeLinter是提供棉絨的框架。 它不支持不同的語言。 特定于語言的Linter必須單獨安裝。

The Sublime-contrib-eslint plugin acts as an interface between ESLint and the SublimeLinter. You can check the installation procedure on their main website if you get stuck anywhere.

Sublime-contrib-eslint插件充當ESLint與SublimeLinter之間的接口。 如果您卡在任何地方,可以在其主要網站上查看安裝過程。

After successfully installing the plugins, you need to reset your editor for the changes to take effect. Now we will see ESLint in action!

成功安裝插件后,您需要重置編輯器以使更改生效。 現在,我們將看到ESLint發揮作用!

第2步 (Step 2)

Phew! Those were a lot of installations. Now, finally, you can check out the awesomeness of Linting! Open up your file in Sublime and behold the power…but wait nothing’s happened. Why is that? Don’t fret. You have installed everything correctly, but ESLint by itself does not do anything. You need to provide the basic configuration, and it is a very straightforward process. Here’s how:

! 這些是很多裝置。 現在,最后,您可以檢查一下Linting的超贊之處! 在Sublime中打開文件并查看其功能……但請耐心等待。 這是為什么? 別擔心 您已正確安裝了所有程序,但ESLint本身不執行任何操作。 您需要提供基本配置,這是一個非常簡單的過程。 這是如何做:

  1. Fire up the terminal program in the home directory of your project

    在項目的主目錄中啟動終端程序
  2. Type this command

    輸入此命令
eslint --init

A prompt shows up asking you a few questions about your coding preferences and an ‘.eslintrc’ file is generated for you. This file contains the rules that you have just selected. You can add extra configurations should you choose to do so.

出現提示,詢問您有關編碼首選項的幾個問題,并為您生成一個“ .eslintrc”文件。 該文件包含您剛剛選擇的規則。 您可以選擇添加其他配置。

As you can see, ESLint is complaining about the indentation and the fact that the foo variable is not used anywhere. You can check any error or warning by hovering over the highlighted portion of the code or checking the message in Sublime’s status bar at the bottom.

如您所見,ESLint抱怨縮進以及foo變量未在任何地方使用的事實。 您可以將鼠標懸停在代碼的突出顯示部分上,或者檢查底部Sublime狀態欄中的消息,以檢查任何錯誤或警告。

So that was it! I hope you were able to follow along. Linting is a pretty cool tool to detect errors in your code. It ensures that you follow code guidelines and write clean code at all times. I hope you all found this post helpful, and as always, happy coding!

就這樣! 希望您能夠跟進。 Linting是一個非常不錯的工具,可以檢測代碼中的錯誤。 它確保您始終遵循代碼準則并始終編寫干凈的代碼。 希望大家都覺得這篇文章對您有所幫助,并且一如既往地高興編寫代碼!

翻譯自: https://www.freecodecamp.org/news/how-to-lint-away-your-troubles-in-sublime-c448a8896cf7/

sublime 消除鋸齒

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/393406.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/393406.shtml
英文地址,請注明出處:http://en.pswp.cn/news/393406.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

node.js mysql防注入_避免Node.js中的命令行注入安全漏洞

在這篇文章中,我們將學習正確使用Node.js調用系統命令的方法,以避免常見的命令行注入漏洞。我們經常使用的調用命令的方法是最簡單的child_process.exec。它有很一個簡單的使用模式;通過傳入一段字符串命令,并把一個錯誤或命令處理結果回傳至…

Netbackup detected IBM drives as unusable

今天在遠程給客戶安裝NBU的時候,遇到了下面這個問題,下面的內容來至于SYMANTEC。 1,更新mapping文件 在原來也遇到過類型的故障,通過更新mapping文件后,故障解決,這次沒有那么幸運了。 2,lsscsi…

opencv python運動人體檢測

采用非極大值抑制,將重疊的框合并成一個。 # import the necessary packages from imutils.object_detection import non_max_suppression import numpy as np import imutils import cv2# initialize the HOG descriptor/person detector hog cv2.HOGDescriptor()…

php mysql 注入一句話木馬_滲透技術--SQL注入寫一句話木馬原理

講一下SQL注入中寫一句話拿webshell的原理,主要使用的是 SELECT ... INTO OUTFILE 這個語句,下面是一個語句的例子:SELECT * INTO OUTFILE C:\log1.txt這樣就可以把查詢到的數據寫入到C盤的log1.txt這個文件里面。利用這個原理我們可以把PHP的一句話木馬…

開源貢獻 計算_使用此網站為開源做貢獻

開源貢獻 計算When I began the transition into being a software developer, I knew that contributing to open source projects would greatly assist my job search.當我開始過渡為軟件開發人員時,我知道為開源項目做貢獻將極大地幫助我的求職。 So, I jumped…

leetcode275. H指數 II(二分法)

給定一位研究者論文被引用次數的數組(被引用次數是非負整數),數組已經按照升序排列。編寫一個方法,計算出研究者的 h 指數。 h 指數的定義: “h 代表“高引用次數”(high citations),一名科研人…

java 多線程阻塞隊列 與 阻塞方法與和非阻塞方法

Queue是什么隊列,是一種數據結構。除了優先級隊列和LIFO隊列外,隊列都是以FIFO(先進先出)的方式對各個元素進行排序的。無論使用哪種排序方式,隊列的頭都是調用remove()或poll()移除元素的。在FIFO隊列中,所…

批量移動AD用戶到指定OU

作為域管理員,在日常工作中使用ADUC(AD用戶和計算機)工具在圖形界面中進行賬號管理操作可謂是家常便飯了。然而一個個增加、移動、刪除用戶,這樣操作有時真的夠煩,當管理大批量的賬戶時,重復操作浪費的時間…

vs 編譯說明

靜態編譯/MT,/MTD 是指使用libc和msvc相關的靜態庫(lib)。動態編譯,/MD,/MDd是指用相應的DLL版本編譯。其中字母含義 d:debug m:multi-threading(多線程) t:text代碼 d:dynamic(動態)…

python numeric_Python pandas.to_numeric函數方法的使用

pandas.to_numeric(arg, errorsraise, downcastNone) [source]將參數轉換為數字類型。默認返回dtype為float64或int64, 具體取決于提供的數據。使用downcast參數獲取其他dtype。請注意,如果傳入非常大的數字,則可能會導致精度損失。由…

javascript 分號_讓我們談談JavaScript中的分號

javascript 分號要使用它們,還是不使用它們… (To use them, or not to use them…) Semicolons in JavaScript divide the community. Some prefer to use them always, no matter what. Others like to avoid them.JavaScript中的分號分隔社區。 有些人更喜歡始終…

leetcode436. 尋找右區間(二分法)

給定一組區間,對于每一個區間 i,檢查是否存在一個區間 j,它的起始點大于或等于區間 i 的終點,這可以稱為 j 在 i 的“右側”。 對于任何區間,你需要存儲的滿足條件的區間 j 的最小索引,這意味著區間 j 有最…

python篇第6天【數據類型】

Python有五個標準的數據類型:Numbers(數字)String(字符串)List(列表)Tuple(元組)Dictionary(字典)Python數字數字數據類型用于存儲數值。他們是不…

如何確定Ionic是否適合您的項目

by Simon Grimm西蒙格里姆(Simon Grimm) 如何確定Ionic是否適合您的項目 (How to find out if Ionic is the right choice for your project) Ionic has been around for quite some years. With the latest release of version 4, it has become an even better option for d…

二維數組的查找 java_查找二維數組java的總和

我正在一個項目中,我必須讀取文件并將內容輸入2D數組。然后,我必須對每一行,每一列和矩陣的周長求和。到目前為止,除外圍功能外,我一切正常。我正在嘗試為兩個外部列的頂行,底行和中間創建單獨的for循環。矩…

遞歸法解決兔子問題

記得以前過相似問題,今天有同事問道,竟然不知所答,故寫篇文章以記之。 一般而言,兔子在出生兩個月后,就有繁殖能力,一對兔子每個月能生出一對小兔子來。如果所有兔子都不死,那么若干月以后可以繁…

mysql本地連接錯誤解決辦法

今天公司同事在測試服務器上死活不能用一個賬號在本地登陸,但是遠程就可以,于是我幫忙看了下,測試服務器的IP是10.10.2.226,錯誤如下:linux-0fdr:/home1/mysql_data # mysql -h 10.10.2.226 -u jxq2 -pjxq2ERROR 1045 (28000): Access denied for user jxq2linux-0fdr (using p…

leetcode546. 移除盒子(dp)

給出一些不同顏色的盒子,盒子的顏色由數字表示,即不同的數字表示不同的顏色。 你將經過若干輪操作去去掉盒子,直到所有的盒子都去掉為止。每一輪你可以移除具有相同顏色的連續 k 個盒子(k > 1),這樣一輪…

408. Valid Word Abbreviation

題目: Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word", "1ord", &qu…

oracle常用操作指令

登錄oracle用戶: sqlplus 用戶名/密碼 創建用戶:create user 要創建的用戶名 identified by 當前用戶名; 授權:grant resource,connect to 要授權的用戶名; 刪除用戶:drop user 用戶名 創建表: create table student( id n…