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 消除锯齿

sublime 消除锯齿_如何在Sublime中消除麻烦相关推荐

  1. figma设计_如何在Figma中构建设计入门套件(第1部分)

    figma设计 Figma教程 (Figma Tutorial) Do you like staring at a blank canvas every time you start a new pr ...

  2. 在excel日期比对大小_如何在Excel中防止分组日期

    在excel日期比对大小 As a teenager, group dates can be fun. If you have strict parents, that might be the on ...

  3. 表格在整个html居中显示,html 表格字符居中显示_如何在HTML中居中显示表格?

    html 表格字符居中显示_如何在HTML中居中显示表格? html 表格字符居中显示_如何在HTML中居中显示表格? html 表格字符居中显示 HTML table provides the ab ...

  4. java中转json字符串_如何在Java中转义JSON字符串-Eclipse IDE技巧

    java中转json字符串 在Java应用程序中工作或进行JSON解析时,通常很常见的做法是从某些资源(例如RESTful Web服务)中复制粘贴JSON字符串,然后使用Jackson库解析JSON. ...

  5. css在兼容模式下无法引用_如何在CSS中使用深色模式

    css在兼容模式下无法引用 by Frank Lämmer 由FrankLämmer 如何在CSS中使用深色模式 (How to get dark mode working with CSS) I h ...

  6. java 正则表达式 开头_如何在Java中修复表达式的非法开头

    java 正则表达式 开头 您是否遇到过这个令人难以置信的错误,想知道如何解决它? 让我们仔细阅读一下,研究如何解决表达式Java非法开头错误. 这是一个动态错误,这意味着编译器会发现某些不符合Jav ...

  7. python 线性回归模型_如何在Python中建立和训练线性和逻辑回归ML模型

    python 线性回归模型 Linear regression and logistic regression are two of the most popular machine learning ...

  8. anki卡片重复_如何在Anki中使用间隔重复来学习更快的编码

    anki卡片重复 by Steven Gilbert 史蒂文·吉尔伯特 如何在Anki中使用间隔重复来学习更快的编码 (How to use spaced repetition with Anki t ...

  9. 合并的表格怎么加横线_如何在excel中文字后面加横线

    如何在excel中文字后面加横线以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 如何在excel中文字后面加横线 好办啊 ...

最新文章

  1. SHELL 技能树(持续更新)
  2. new hashmap 初始大小_害怕面试被问HashMap?这一篇就搞定了
  3. 神经网络与机器学习 笔记—核方法和径向基函数网络(下)
  4. 远离极限编程 (Don’t do XP)
  5. arrayfunction[LeetCode]Convert Sorted Array to Binary Search Tree
  6. muduo网络库学习(三)定时器TimerQueue的设计
  7. 飘逸的python - 命令行漂亮的显示json数据
  8. 漫画:为什么计算机起始时间是 1970 年 1 月 1 日?
  9. ubuntu shortcuts
  10. 关闭win7 透明化效果 aero
  11. lock.lock()使用,与synchronized对比
  12. oid 值 内存使用_JVM:对Java内存模型的理解,你还停留在面试阶段吗?
  13. 通俗理解激活函数作用和常见激活函数总结:sigmoid、tanh、relu、Leaky-relu、P-relu、R-Relu、elu
  14. HIVE Sql 笛卡尔积关联导致查询过慢问题优化
  15. Python 数据挖掘(四) pandas模块 简单使用
  16. 用户访谈与问卷调查怎么做
  17. java计算机毕业设计足球队管理系统源码+数据库+系统+lw文档+mybatis+运行部署
  18. 两个音轨合并_如何将两个音频连接 多个音频/音乐合并
  19. 本体论:Gene Ontology (基因本体)
  20. win7休眠设置在哪里_win7系统如何关闭休眠模式--win7w.com

热门文章

  1. 太厉害了!2021年互联网大厂Java笔经
  2. 280. Wiggle Sort
  3. 16.U-boot的工作流程分析-2440
  4. android各个版本的名称和更新(转)
  5. flowable 任务节点多实例使用
  6. MySQL 亿级数据需求的优化思路(二),100亿数据,1万字段属性的秒级检索
  7. 汇编跳转比较用的列表
  8. 机器学习05神经网络--表示
  9. 3.1 读入一个参数
  10. Python - 排序( 插入, 冒泡, 快速, 二分 )