【React】vite + react 项目,进行配置 eslint_vite react eslint(2)

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

module.exports = {
  'env': {
    'browser': true,
    'es2021': true
  },
  'extends': [
    'eslint:recommended',
    'plugin:react/recommended'
  ],
  'overrides': [
    {
      'env': {
        'node': true
      },
      'files': [
        '.eslintrc.{js,cjs}'
      ],
      'parserOptions': {
        'sourceType': 'script'
      }
    }
  ],
  'parserOptions': {
    'ecmaVersion': 'latest',
    'sourceType': 'module'
  },
  'plugins': [
    'react'
  ],
  'rules': {
  },
};

3 安装 vite-plugin-eslint
npm i -D vite-plugin-eslint

4 配置 vite.config.js 文件
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import eslintPlugin from 'vite-plugin-eslint'

export default defineConfig({
  plugins: [
    react(),
    // 添加 eslint 插件配置
    eslintPlugin({
      include: ['src/\*\*/\*.js', 'src/\*\*/\*.jsx', 'src/\*.js', 'src/\*.jsx']
    })
  ],
  resolve: {
    alias: {
    },
  },
})

5 修改 eslint 默认配置

可根据实际情况进行配置。

module.exports = {
  'env': {
    'browser': true,
    'es2021': true
  },
  'extends': [
    'eslint:recommended',
    'plugin:react/recommended'
  ],
  'overrides': [
    {
      'env': {
        'node': true
      },
      'files': [
        '.eslintrc.{js,cjs}'
      ],
      'parserOptions': {
        'sourceType': 'script'
      }
    }
  ],
  'parserOptions': {
    'ecmaVersion': 'latest',
    'sourceType': 'module'
  },
  'plugins': [
    'react'
  ],
  'rules': {
    'indent': [
      2,
      2,
      {
        'SwitchCase': 1,
        'ignoredNodes': ['TemplateLiteral']
      }
    ], //缩进
    'no-unused-vars': [0], //未使用变量
    'quotes': [2, 'single'], //单引号
    'jsx-quotes': ['error', 'prefer-single'],
    'no-console': [0, { 'allow': ['warn', 'error'] }], //console
    'linebreak-style': [0, 'unix'], //强制执行统一的行结尾
    'semi': [2, 'always'], //分号结尾
    'curly': 2,
    'no-eval': 1, //禁止使用eval
    'no-caller': 2,
    'no-else-return': 2, //如果if语句里面有return,后面不能跟else语句
    'no-extend-native': 2, //禁止扩展native对象
    'no-extra-bind': 2, //禁止不必要的函数绑定
    'no-floating-decimal': 2, //禁止省略浮点数中的0
    'no-implied-eval': 2, //禁止使用隐式eval
    'no-labels': 2, //禁止标签声明
    'no-with': 2, //禁用with


![img](https://img-blog.csdnimg.cn/img_convert/6269ee539f241fb7fb8bd542ce15d92f.png)
![img](https://img-blog.csdnimg.cn/img_convert/af6198b27ac1ad784b03570f93d424df.png)
![img](https://img-blog.csdnimg.cn/img_convert/29fe9c88de7002d820ffdcd06adbdbf9.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**

知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值