在Sublime3中使用ESLint
来源:互联网 发布:江苏微盛网络孙 编辑:程序博客网 时间:2024/04/30 18:46
Sublime集成 ESLint 需要两个插件 SublimeLinter 和 SublimeLinter-contrib-eslint ;直接在Package Controll中安装就好
安装ESLint: npm i -g eslint
安装后修改SublimeLinter的配置文件,在Package Settings中打开其Setting-User,将下列代码复制进去:
setting-user
{ "user": { "debug": false, "delay": 0.25, "error_color": "D02000", "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme", "gutter_theme_excludes": [], "lint_mode": "save only", "linters": { // 新增的 "eslint": { "@disable": false, "args": [], "excludes": [] } }, "mark_style": "outline", "no_column_highlights_line": false, "passive_warnings": false, "paths": { "linux": [], "osx": [], "windows": [ // 这个是你全局安装eslint后eslint.cmd的所在目录 "C:/Users/Lin/AppData/Roaming/npm/eslint.cmd" ] }, "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" }, "warning_color": "DDB700", "wrap_find": true }}
关键的一步,配置eslint,最好把 http://eslint.org/docs/user-guide/configuring 看看,配置出适合自己编程习惯的配置文件再好不过了,我的配置文件内容如下:
.eslintrc.json
{ "env": { "browser": true, "es6": true, "node": true }, "parserOptions": { "sourceType": "module" }, "rules": { "no-cond-assign": [2, "always"], //if, while等条件中不允许使用“=” "no-constant-condition": 2, "no-debugger": 2, // 程序中不能出现debugger "no-dupe-args": 2, // 函数的参数名称不能重复 "no-dupe-keys": 2, // 对象的属性名称不能重复 "no-duplicate-case": 2, // switch的case不能重复 "no-func-assign": 2, "no-obj-calls": 2, "no-regex-spaces": 2, "no-sparse-arrays": 2, "no-unexpected-multiline": 2, "no-unreachable": 2, "use-isnan": 2, "valid-typeof": 2, "eqeqeq": [2, "always"], "no-caller": 2, "no-eval": 2, "no-redeclare": 2, "no-undef": 2, "no-unused-vars": 1, "no-use-before-define": 2, "comma-dangle": [1, "never"], "no-const-assign": 2, "no-dupe-class-members": 2 }}
最后,把配置好的文件放在你项目的根目录中就可以了,项目中所有的子文件也会自动使用该配置文件。
这只是入门级的介绍,ESLint还有很多其他的功能,对JSX也支持,想了解的同学不妨自己去官网学习一下。
0 0
- 在Sublime3中使用ESLint
- sublime3使用ESLint
- sublime3 eslint 安装
- Sublime3集成ESLint
- sublime3配置eslint
- 在React+Babel+Webpack环境中使用ESLint
- eslint在项目中的使用
- ESLint 在vscode编辑器中 搭建
- ESLint在Vue中的使用详解
- JavaScript中使用ESLint 说明规则
- 如何在sublime3中直接运行python
- 在 sublime3 中格式化 html js
- react+webpack 下使用eslint以及eslint插件在sublime下的安装使用
- sublime3使用
- sublime3中如何使用sublimegit插件
- WebStorm 2016.3中如何安装及使用eslint
- ESlint安装使用
- ESLint 使用入门
- Android中Mock以及Mockito的使用
- Unity3D中C#调用iOS的静态库(*.a)
- svn 清理失败 (cleanup 失败) 的解决方法
- Windows环境下Qwt安装和使用
- JSTSP2016 Fully Deep Blind Image Quality Predictor
- 在Sublime3中使用ESLint
- Git 撤销合并
- Linux常用命令记录
- python基本语法和编程风格
- Field 'id' doesn't have a default value
- SAP CRM 忠诚度相关表的关系图
- Android SharedPreferences本地储存
- 从一道面试题来认识java类加载时机与过程
- ListView嵌套出现子Listview显示不全问题解决