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

vscode+react+ESLint解决不引入组件,vscode不会报错的问题

解决不引入组件,vscode不会报错的问题

routes.jsx       全部代码如下
export const routes = [{path:"/",element:<Home/>}
]

在项目根目录下新建个
eslint.config.js
加入下面的代码,要保证node_modules里安装了
eslint-plugin-react(主要是这个)
eslint-plugin-react-hooks
eslint-plugin-react-refresh

import js from "@eslint/js";
import globals from "globals";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";export default [{ ignores: ["dist", "build", "node_modules"] },{files: ["**/*.{js,jsx}"],languageOptions: {ecmaVersion: 2020,globals: globals.browser,parserOptions: {ecmaVersion: "latest",sourceType: "module",ecmaFeatures: { jsx: true },},},settings: { react: { version: "detect" } },plugins: {react: reactPlugin,"react-hooks": reactHooks,"react-refresh": reactRefresh,},rules: {...js.configs.recommended.rules,...reactPlugin.configs.recommended.rules, // ← 插件推荐里包含 jsx-no-undef 等...reactHooks.configs.recommended.rules,"no-unused-vars": "off", // 关掉 ESLint 对未使用变量的默认规则(如果已开启的话)// 如果想手动写,也可以:// 'react/jsx-no-undef': 'error',// 'react/jsx-uses-vars': 'error',// 'react/jsx-uses-react': 'error',// 'no-undef': 'error',},},
];

然后安装插件ESLint在这里插入图片描述

http://www.xdnf.cn/news/14570.html

相关文章:

  • 小孙学变频学习笔记(四)变频器的逆变器件—IGBT管(下)
  • linux 远程终端执行qt应用显示到接入的物理显示器上
  • 如何仅用AI开发完整的小程序<5>—让AI制作开始页面
  • C++ Programming Language —— 第2章:数据类型
  • C#.NET HttpClient 使用教程
  • 【Dicom标准】dicom数据中pixelData显示处理流程详细介绍
  • Linux 服务器运维:磁盘管理与网络配置
  • 一个免费的视频、音频、文本、图片多媒体处理工具
  • ICM-20948 Wake on Motion功能开发全过程(8)
  • Python 的内置函数 hash
  • python模块常用语法sys、traceback、QApplication
  • 操作系统内核态和用户态--2-系统调用是什么?
  • 决策树:化繁为简的智能决策利器
  • GO语言---数组
  • 【Docker基础】Docker镜像管理:docker rmi、prune详解
  • 经典:在浏览器地址栏输入信息到最终看到网页的全过程,涉及网络协议以及前后端技术
  • Vue状态管理实践:使用Vuex进行前端状态管理
  • FVISION 未来视界工作室:AI驱动的创新与智能外包平台
  • TodoList 案例(Vue3): 使用Composition API
  • Snapchat矩阵运营新策略:亚矩阵云手机打造高效社交网络
  • 基于SpringBoot+Uniapp的活动中心预约小程序(协同过滤算法、腾讯地图、二维码识别)
  • 【论文笔记】【强化微调】TinyLLaVA-Video-R1:小参数模型也能视频推理
  • SQLite 数据库操作完整指南
  • Spring Boot邮件发送终极指南:从基础到高级应用
  • AI大模型学习之基础数学:高斯分布-AI大模型概率统计的基石
  • RocketMQ--为什么性能不如Kafka?
  • Mac电脑-Markdown编辑器-Typora
  • springboot垃圾分类网站
  • 浅议 3D 展示技术为线上车展新体验带来的助力​
  • Qt的学习(七)