简体   繁体   English

JavaScript/React 样式指南缩进

[英]JavaScript/React Style Guide Indentation

Is there an agreed-upon convention for indentation in React JSX?在 React JSX 中是否有一致同意的缩进约定? 2 spaces, 4 spaces, tabs, etc. 2个空格、4个空格、制表符等

You should just use the same indentation as the rest of your javascript code.您应该使用与其余 javascript 代码相同的缩进。

That said react ecosystem seems to use mostly double spaces so I'd use that for consistency.也就是说,react 生态系统似乎主要使用双空格,所以我会使用它来保持一致性。

Most popular libraries tend to use 2 spaces, but you can change this if you and your team agree on a standard.大多数流行的库倾向于使用 2 个空格,但如果您和您的团队就标准达成一致,您可以更改此设置。

You can setup up eslint so that your code base is standardised.您可以设置eslint以便您的代码库标准化。 I would definitely recommend you to take a look at one of the most popular javascript style guide by Airbnb .我绝对会推荐你看一看Airbnb最流行的 JavaScript 风格指南之一。

You should use the identation style that fit your style.您应该使用适合您风格的标识样式。 You can use something like ESlint to define a convention.您可以使用诸如ESlint 之类的东西来定义约定。 4 or 2 spaces or tabs, is just a style. 4 或 2 个空格或制表符,只是一种样式。

The react source code and sample code in the React tutorial use 2 spaces . React教程中的 react源码和示例代码使用了2 个空格 Also it seems like many of the Github projects related to React use 2.此外,似乎许多与 React 相关的 Github 项目都使用 2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript样式指南变量声明 - Javascript style guide variable declarations 如何使Airbnb的JavaScript样式eslint指南与React,ES6一起在vim中工作? - How to get Airbnb's JavaScript style eslint guide working in vim with react, es6? 在Atom编辑器中更改缩进样式(JavaScript代码) - Changing indentation style in atom editor (javascript code) 什么是“ Google JavaScript样式指南”中所述的JavaScript源文件 - What are JavaScript source files as described in 'Google JavaScript Style Guide' 是否有基于 React 的项目的官方样式指南或命名约定? - Is there an official style guide or naming convention for React based projects? 通过解构或forEach进行缩减-迭代和Airbnb JavaScript样式指南 - Reduce with deconstruction or forEach - Iteration and Airbnb JavaScript Style Guide 根据Google JavaScript样式指南在Blocks中的函数声明 - Function Declarations Within Blocks according to the Google JavaScript style guide 如何使用 Airbnb JavaScript 风格指南设置 Prettier - How do I set up Prettier with Airbnb JavaScript Style Guide 如何运行Airbnb javascript样式指南中的代码? - How do I run the code in the Airbnb javascript style guide? ESLint 问题:标准指南,还是流行的风格指南 - ESLint Question: Standard guide, or a popular style guide
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM