当前位置: 首页 > news >正文

解决Vue项目中ESLint和Prettier冲突问题[Vue.js项目实践: 新冠自检系统]

Logo

新冠疫情自我检测系统网页设计开发文档

Sylvan Ding 的第一个基于 Vue.js 的项目. 本项目所提供的信息,只供参考之用,不保证信息的准确性、有效性、及时性和完整性,更多内容请查看国家卫健委网站!
Explore the docs »

View Demo · Report Bug · Request Feature

homepage

解决Vue项目中ESLint和Prettier冲突问题

You will need to install the appropriate extension/plugin for your code editor. For VS Code, install ESLint and Prettier. These plugins have millions of downloads each, so it’ll be difficult to miss them in the VS Code extension marketplace. Once you’ve installed these, we are ready to move on to configuring each of them for proper usage.

Linters usually contain not only code quality rules, but also stylistic rules. Most stylistic rules are unnecessary when using Prettier, but worse – they might conflict with Prettier!

Luckily it’s easy to turn off rules that conflict or are unnecessary with Prettier. Package eslint-config-prettier can exclude all ESLint rules that could conflict with Prettier.

开发环境

node14.16.1
npm8.18.0
vue-cli2.9.6
vue2.5.2

解决方案

Install eslint-config-prettier:

npm install eslint-config-prettier --save-dev --legacy-peer-deps

You may meet upstream dependency conflict when installing NPM packages with the latest npm version (v8). The effective solution to this error is to pass a command --legacy-peer-deps to the npm install that can help ignore the peer dependencies and continue the installation.

Once the setup is successful, you should see a file eslintrc.js based on the format you chose your configuration file to be in.

Then, add "prettier" to the “extends” array in your .eslintrc.js file. Make sure to put it last, so it gets the chance to override other configs.

{
  "extends": [
    "some-other-config-you-use",
    "prettier"
  ]
}

Create .prettierrc file written in JSON as configuration file for Prettier:

{
  "arrowParens": "always",
  "bracketSameLine": false,
  "bracketSpacing": true,
  "embeddedLanguageFormatting": "auto",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": false,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false,
  "vueIndentScriptAndStyle": false
}

转载请注明出处:©️ Sylvan Ding 2022

相关文章:

  • 【misc】buu-面具下的flag——zip伪加密+用NTFS流隐藏文件
  • java毕业设计企业安全与设备管理系统源码+lw文档+mybatis+系统+mysql数据库+调试
  • Message Bus Solace Deeper Dive
  • Android-AGP之手写你的第一款自定义plugin插件
  • 入门力扣自学笔记159 C++ (题目编号788)
  • java毕业设计奇妙店铺电子商务网站源码+lw文档+mybatis+系统+mysql数据库+调试
  • 类与对象(十四)----包package
  • Codeforces Round #820 (Div. 3)A. Two Elevators
  • 实现淘宝购物车RecyclerView或LIstView的嵌套选择的逻辑
  • (pt可视化)利用torch的make_grid进行张量可视化
  • MQTT协议规范总结
  • SAP EWM-拣货队列操作演示实例
  • 公众号查题功能接口系统使用教程
  • MySql5.7主从同步配置(gtid模式)
  • Linux文件系统管理
  • 网络传输文件的问题
  • C++11: atomic 头文件
  • FineReport中如何实现自动滚屏效果
  • Flex布局到底解决了什么问题
  • Git学习与使用心得(1)—— 初始化
  • input实现文字超出省略号功能
  • javascript数组去重/查找/插入/删除
  • Java方法详解
  • mongodb--安装和初步使用教程
  • Mybatis初体验
  • MySQL QA
  • Quartz初级教程
  • webpack项目中使用grunt监听文件变动自动打包编译
  • 对话:中国为什么有前途/ 写给中国的经济学
  • 分布式熔断降级平台aegis
  • 模型微调
  • 微信如何实现自动跳转到用其他浏览器打开指定页面下载APP
  • 用quicker-worker.js轻松跑一个大数据遍历
  • 哈罗单车融资几十亿元,蚂蚁金服与春华资本加持 ...
  • #数学建模# 线性规划问题的Matlab求解
  • (1)(1.8) MSP(MultiWii 串行协议)(4.1 版)
  • (1)(1.9) MSP (version 4.2)
  • (1)虚拟机的安装与使用,linux系统安装
  • (27)4.8 习题课
  • (4)事件处理——(6)给.ready()回调函数传递一个参数(Passing an argument to the .ready() callback)...
  • (a /b)*c的值
  • (function(){})()的分步解析
  • (Java数据结构)ArrayList
  • (Matlab)基于蝙蝠算法实现电力系统经济调度
  • (大众金融)SQL server面试题(1)-总销售量最少的3个型号的车及其总销售量
  • (二十三)Flask之高频面试点
  • (附源码)springboot“微印象”在线打印预约系统 毕业设计 061642
  • (机器学习-深度学习快速入门)第三章机器学习-第二节:机器学习模型之线性回归
  • (七)Knockout 创建自定义绑定
  • (十五)使用Nexus创建Maven私服
  • (终章)[图像识别]13.OpenCV案例 自定义训练集分类器物体检测
  • (转)原始图像数据和PDF中的图像数据
  • ****Linux下Mysql的安装和配置
  • .net core 连接数据库,通过数据库生成Modell
  • .NET WebClient 类下载部分文件会错误?可能是解压缩的锅