CÓMO configurar ESLINT y PRETTIER en REACT 🤒 sin romperte la cabeza! 😎 Curso de React desde cero #4

Desarrollo Útil
13 Feb 202225:24

Summary

TLDRIn this informative video, Pablo explains the setup of ESLint and Prettier, two essential tools for JavaScript development. He clarifies the roles of linting for code quality and formatting for consistent style. The tutorial guides viewers through installing, configuring, and integrating ESLint and Prettier to avoid 'ghost' changes and maintain a uniform coding standard. Pablo also addresses common issues like conflicting rules and provides solutions for a seamless development experience.

Takeaways

  • 😀 The video discusses the common challenges faced when configuring a project for irrigation with ESLint and Prettier.
  • 🔧 The difference between 'linting' and 'formatting' is explained, with linting focusing on code correctness and formatting on code organization and presentation.
  • 💡 ESLint is highlighted as a tool that not only checks for syntax errors but also enforces a consistent coding style.
  • 🛠️ Prettier is introduced as a popular code formatter that can be configured to adhere to specific style guidelines.
  • 📝 The importance of using a shared formatting and linting configuration across multiple machines or team members to avoid 'ghost' changes is emphasized.
  • 👨‍🏫 The video provides a step-by-step guide on installing ESLint and setting up a configuration file with rules using 'eslint --init'.
  • 🔄 It demonstrates how to integrate ESLint with an editor to provide real-time feedback on code errors and style issues.
  • 📁 The creation of a '.prettierrc' file is shown for configuring Prettier, with options available to customize the formatting style.
  • 🔧 The script explains how to resolve conflicts between ESLint and Prettier, such as different preferences for semicolons, by using 'eslint-config-prettier'.
  • 📝 The necessity of setting up npm scripts for linting and formatting to streamline the process for all team members is discussed.
  • 🚫 The video mentions the need to ignore auto-generated files from formatting in both ESLint and Prettier configurations to prevent unnecessary changes.

Q & A

  • What are the two main tools discussed in the video script for configuring a project for irrigation?

    -The two main tools discussed are ESLint (referred to as 'sling' in the script) and Prettier (referred to as 'pretty air').

  • What is the primary concern of ESLint in the context of coding?

    -ESLint is primarily concerned with what is being written and the meaning of the code, focusing on syntax and finding errors in the code.

  • What does Prettier focus on in terms of code development?

    -Prettier focuses on the organization and presentation of the code, ensuring that the code is well-formatted and presented correctly.

  • Why might ESLint and Prettier conflict with each other during code development?

    -ESLint and Prettier may conflict because ESLint is concerned with the meaning and correctness of the code, while Prettier is concerned with the formatting. These different focuses can lead to situations where one tool corrects what the other has formatted.

  • What is a 'ghost change' in the context of code formatting?

    -A 'ghost change' refers to changes in the code that are purely formatting changes and do not affect the actual functionality of the code. These changes can occur when different team members have different formatting settings in their editors.

  • How can ghost changes be avoided in a team project?

    -Ghost changes can be avoided by using a shared formatting tool with common rules for everyone, ensuring that all team members use the same formatting settings and thus preventing unnecessary formatting conflicts.

  • What is the purpose of installing ESLint as a development dependency?

    -Installing ESLint as a development dependency ensures that it only acts while writing code and does not affect the production environment, where it is not needed.

  • What is the recommended way to configure ESLint settings according to the script?

    -The script recommends using the 'eslint --init' command, which opens an assistant that asks questions to help configure ESLint settings according to the project's needs.

  • What is the role of the 'standard' style guide in configuring ESLint?

    -The 'standard' style guide is a popular choice for ESLint configuration, providing a set of rules that enforce a consistent coding style across the project.

  • How can ESLint help with code quality apart from syntax errors?

    -Apart from catching syntax errors, ESLint can ensure that the code follows a consistent style, avoiding issues like unused variables and enforcing the use of the same coding patterns throughout the project.

  • Why is it important to have a consistent coding style in a large project?

    -A consistent coding style is important in a large project to avoid confusion and potential errors that can arise from inconsistent coding practices, making the codebase easier to maintain and understand.

  • What is the recommended way to integrate ESLint and Prettier in a project?

    -The recommended way is to install and configure both tools with their respective settings and then use a package like 'eslint-config-prettier' to resolve conflicts between ESLint and Prettier rules, ensuring that they work together seamlessly.

  • How can the script's speaker ensure that ESLint and Prettier do not conflict with each other?

    -The speaker can ensure no conflict by using the 'eslint-config-prettier' package, which prioritizes Prettier's formatting rules over ESLint's when there is a conflict, thus maintaining a consistent code style.

Outlines

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Mindmap

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Keywords

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Highlights

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Transcripts

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф
Rate This

5.0 / 5 (0 votes)

Связанные теги
Code FormattingJavaScriptESLintPrettierDevelopment ToolsCoding StandardsProject SetupCode QualityVSCodeBest Practices
Вам нужно краткое изложение на английском?