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

TypeScript 项目 Airbnb 语法风格 ESLint 配置

TypeScript 项目 Airbnb 语法风格 ESLint 配置

1. 配置

安装:

npm i -D eslint-config-airbnb-typescript @typescript-eslint/eslint-plugin@^6.0.0 @typescript-eslint/parser@^6.0.0

配置:

  • .eslintrc.js:

    module.exports = {root: true,env: {node: true,browser: true,},extends: ['airbnb-base','airbnb-typescript/base',],parserOptions: {project: './tsconfig.json',},
    };
    
  • tsconfig.json:

    {// ..."include": ["src/**/*.ts","src/**/*.tsx","src/**/*.vue","tests/**/*.ts","tests/**/*.tsx","./*.js", // 匹配不到 `.eslintrc.js`,但可以匹配到 `webpack.config.js`"./.eslintrc.js", // 重点,缺少它会报如下错误]
    }
    

错误:

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/.eslintrc.js` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
Process finished with exit code -1

注意:

  • webstorm 上修改完 tsconfig.json 的 include 属性的值,需要重启才会生效

2. 参考

  • eslint-config-airbnb-typescript
  • Solve parserOptions.project bug with Typescript and ESLint

相关文章:

  • python之TCP的网络应用程序开发
  • 455.分发饼干
  • OpenCV快速入门:特征点检测与匹配
  • nginx 代理接口报404 问题排查
  • HarmonyOS开发:ArkTs常见数据类型
  • 流程图是什么,用什么软件做?
  • [开源]Web端的P2P文件传输工具,简单安全高效的P2P文件传输服务
  • centos7 docker开启认证的远程端口2376配置
  • 分享11款原型图软件,让你的创意无限发挥!
  • [Latex] Riemann 问题中的激波,接触间断,膨胀波的 Tikz 绘图
  • 三元表达式原理及例子js
  • OpenCV [c++](图像处理基础示例小程序汇总)
  • 使用new Vue()的时候发生了什么?
  • 案例015:Java+SSM+uniapp基于微信小程序的校园防疫系统
  • Hadoop学习笔记:运行wordcount对文件字符串进行统计案例
  • CSS盒模型深入
  • Java 实战开发之spring、logback配置及chrome开发神器(六)
  • JavaScript设计模式系列一:工厂模式
  • Java程序员幽默爆笑锦集
  • Java基本数据类型之Number
  • React+TypeScript入门
  • 基于Android乐音识别(2)
  • 聊聊springcloud的EurekaClientAutoConfiguration
  • 前端_面试
  • 使用common-codec进行md5加密
  • 探索 JS 中的模块化
  • Spring Batch JSON 支持
  • 仓管云——企业云erp功能有哪些?
  • 基于django的视频点播网站开发-step3-注册登录功能 ...
  • # Redis 入门到精通(九)-- 主从复制(1)
  • # 再次尝试 连接失败_无线WiFi无法连接到网络怎么办【解决方法】
  • #FPGA(基础知识)
  • #Java第九次作业--输入输出流和文件操作
  • #面试系列-腾讯后端一面
  • $(document).ready(function(){}), $().ready(function(){})和$(function(){})三者区别
  • $(selector).each()和$.each()的区别
  • (2024,LoRA,全量微调,低秩,强正则化,缓解遗忘,多样性)LoRA 学习更少,遗忘更少
  • (Arcgis)Python编程批量将HDF5文件转换为TIFF格式并应用地理转换和投影信息
  • (Bean工厂的后处理器入门)学习Spring的第七天
  • (C++17) optional的使用
  • (day18) leetcode 204.计数质数
  • (javaweb)Http协议
  • (第一天)包装对象、作用域、创建对象
  • (翻译)terry crowley: 写给程序员
  • (附源码)计算机毕业设计大学生兼职系统
  • (机器学习-深度学习快速入门)第一章第一节:Python环境和数据分析
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (十五)Flask覆写wsgi_app函数实现自定义中间件
  • (转) ns2/nam与nam实现相关的文件
  • ***测试-HTTP方法
  • ./indexer: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object fil
  • .bat批处理(七):PC端从手机内复制文件到本地
  • .net core webapi 大文件上传到wwwroot文件夹
  • .NET Core 控制台程序读 appsettings.json 、注依赖、配日志、设 IOptions