Styling code
In this section, you will learn how to implement EditorConfig and ESLint to improve your code quality by validating your code style. It is important to have a standard code style in your team and avoid using different code styles.
EditorConfig
EditorConfig helps developers to maintain consistent coding styles between different IDEs.
EditorConfig is supported by a lot of editors. You can check whether your editor is supported or not on the official website, https://www.editorconfig.org.
You need to create a file called .editorconfig
in your root
directory – the configuration I use is this one:
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.html]
indent_size = 4
[*.css]
indent_size = 4
[*.md]
trim_trailing_whitespace = false
You can affect all the files with [*]
, and specific files with [.extension]
.
Prettier
Prettier is an opinionated...