创建React-TS项目流程

React+TS+eslint项目流程

1.使用create-react-app创建TS项目文件夹
$ create-react-app h5web-ts --template typescript //h5web-ts 包名
2.项目采用eslint代码检查工具
  • eslint采用eslint+standard

  • 下载eslint

    $ npm install eslint --save-dev
    
  • 设置一个配置文件 .eslintrc.js

    $ ./node_modules/.bin/eslint --init
    
  • 配置文件设置流程

    1. How would you like to use ESLint? //你想要怎么使用eslint?
       To check syntax, find problems, and enforce code style √
    2. What type of modules does your project use? //你想要模块怎么导入方式?
       JavaScript modules (import/export)3. Which framework does your project use? //你项目使用的框架?
       React √
    4. Does your project use TypeScript? // 是否需要Typescript?
       Yes √
    5. Where does your code run? // 项目是跑在哪里的
       Browser √
    6. How would you like to define a style for your project? //你想要你的项目是什么风格?
       Use a popular style guide √ //大厂风格
    7. Which style guide do you want to follow? //你想要额外加什么规则?
       standard √
    8. What format do you want your config file to be in? //你想要你的项目遵循什么语言?
       JavaScript √
    9. Would you like to install them now with npm? //是否现在下载依赖?
       Yes √
    
  • 配置.eslintrc.js 文件(TS通用)

    module.exports = {
         
      env: {
         
        browser: true,
        es2021
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值