create-react-app项目中的eslint
"no-multi-spaces": 1, //禁止多个空格
"jsx-quotes": 1, //此规则强制在JSX属性中一致使用双引号或单引号
"react/jsx-closing-bracket-location": 1, //有多行属性的话, 新建一行关闭标签,为JSX语法使用下列的对齐方式
// bad
<Foo superLongParam="bar"
anotherSuperLongParam="baz" /> // good
<Foo
superLongParam="bar"
anotherSuperLongParam="baz"
/> // 如果组件的属性可以放在一行就保持在当前一行中,(个人觉得如果只有一个属性就放在一行)
<Foo bar="bar" />
react/jsx-boolean-value": 1,//当属性值等于true的时候,省略该属性的赋值
disabled=“true” 改成 disabled
"react/wrap-multilines": 1,使用括号包裹多行JSX标签
// bad
render() {
return <MyComponent className="long body" foo="bar">
<MyChild />
</MyComponent>
} // good
render() {
return (
<MyComponent className="long body" foo="bar">
<MyChild />
</MyComponent>
);
} // good, when single line
render() {
const body = <div>hello</div>;
return <MyComponent>{body}</MyComponent>;
}
<Form ref="form1"></Form>
this.refs.form.validate((valid) => {
});
正确方法:
<Form ref={ e => { this.form1 = e } }></Form>
this.form1.validate((valid) => {
});
// bad
<Foo className="stuff"></Foo> // good
<Foo className="stuff" />
//按照具体规范的React.createClass 的生命周期函数书写代码// bad
import reservationCard from './ReservationCard'; // good
import ReservationCard from './ReservationCard'; // bad
const ReservationItem = <ReservationCard />; // good
const reservationItem = <ReservationCard />;
"quotes": [
1,
"single",
{
"avoidEscape": true
}
],
"beforeStatementContinuationChars": "always"要求在声明的末尾加分号,如果下一行开头[,(,/,+,或-。// bad
const Listing = React.createClass({
// ...
render() {
return <div>{this.state.hello}</div>;
}
}); // good
class Listing extends React.Component {
// ...
render() {
return <div>{this.state.hello}</div>;
}
}
function MyComponent() {
return <div />;
}
// bad
组件名: MyComponent.js
// good
组件名: MyComponent.jsx
//防止在数组中遍历中使用数组key做索引this{'TEXT'}
create-react-app项目中的eslint的更多相关文章
- create react app 项目部署在Spring(Tomcat)项目中
网上看了许多,大多数都是nginx做成静态项目,但是这样局限性太多,与Web项目相比许多服务端想做的验证都很麻烦,于是开始了艰难的探索之路,终于在不经意间试出来了,一把辛酸... 正常的打包就不说了. ...
- 在 .NET Core 5 中集成 Create React app
翻译自 Camilo Reyes 2021年2月22日的文章 <Integrate Create React app with .NET Core 5> [1] Camilo Reyes ...
- 深入 Create React App 核心概念
本文差点难产而死.因为总结的过程中,多次怀疑本文是对官方文档的直接翻译和简单诺列:同时官方文档很全面,全范围的介绍无疑加深了写作的心智负担.但在最终的梳理中,发现走出了一条与众不同的路,于是坚持分享出 ...
- 如何扩展 Create React App 的 Webpack 配置
如何扩展 Create React App 的 Webpack 配置 原文地址https://zhaozhiming.github.io/blog/2018/01/08/create-react-a ...
- Vue2/3 项目中的 ESLint + Prettier 代码检测格式化风格指南
Vue2/3 项目中的 ESLint + Prettier 代码检测格式化风格指南 因为平时都是使用 VSCode ESLint + Prettier 检测格式化不规范代码,但是随着接手的项目越来越多 ...
- 如何在VUE项目中添加ESLint
如何在VUE项目中添加ESLint 1. 首先在项目的根目录下 新建 .eslintrc.js文件,其配置规则可以如下:(自己小整理了一份),所有的代码如下: // https://eslint.or ...
- 使用create react app教程
This project was bootstrapped with Create React App. Below you will find some information on how to ...
- 在React旧项目中安装并使用TypeScript的实践
前言 本篇文章默认您大概了解什么是TypeScript,主要讲解如何在React旧项目中安装并使用TypeScript. 写这个的目的主要是网上关于TypeScript这块的讲解虽然很多,但都是一些语 ...
- 我是如何在公司项目中使用ESLint来提升代码质量的
ESLint:你认识我吗 ESLint是一个语法规则和代码风格的检查工具. 和学习所有编程语言一样,想要入门ESLint,首先要去它的官网看看:https://eslint.org/. ESLint的 ...
- tap news:week5 0.0 create react app
参考https://blog.csdn.net/qtfying/article/details/78665664 先创建文件夹 安装create react app 这个脚手架(facebook官方提 ...
随机推荐
- utf8_unicode_ci与utf8_general_ci的区别
From: http://www.chinaz.com/program/2010/0225/107151.shtml 当前,utf8_unicode_ci校对规则仅部分支持Unicode校对规则算法. ...
- Java多线程——Lock&Condition
Lock比传统线程模型中的synchronized方式更加面向对象,与生活中的锁类似,锁本身也应该是一个对象.两个线程执行的代码片段要实现同步互斥的效果,它们必须用同一个Lock对象. package ...
- 【DL】物体识别与定位
https://cloud.tencent.com/community/article/414833
- Innodb表空间
Innodb有两种管理表空间的方法 独立表空间:每一张表都会生成独立的文件来进行存储,每一张表都有一个.frm表描述文件,和一个.ibd文件.其中ibd文件包括了单独一个表的数据内容和索引内容. 共享 ...
- workerman定时器使用 php定时任务
add int \Workerman\Lib\Timer::add(float $time_interval, callable $callback [,$args = array(), bool $ ...
- Innodb表压缩过程中遇到的坑(innodb_file_format)
https://www.cnblogs.com/billyxp/p/3342969.html
- [scala] scala 集合(⑧)
1.List 基础操作 2.Set 基础操作 3. TreeSet 排序Set 4. 拉链操作 5. 流 import scala.collection.immutable.TreeSet impor ...
- python--模块--10
原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ Python 模块 Python 模块(Module),是一个 Python 文件,以 .py ...
- SQLServer------远程调用失败
1.情况 出现 2.解决方法 打开“控制面板” -> “卸载程序” -> 找到 “Microsoft SQL Server 2016) ExpressLocalDB”将其卸载 -> ...
- mongodb 搭建主从服务器
mongodb 主从配置比较简单,只需要在启动的时候添加参数(-master.-slave -source IP:PORT). Ubuntu 16.04 系统环境 监听端口分别为:27010.2701 ...