Cookies Psst! Do you accept cookies?

We use cookies to enhance and personalise your experience.
Please accept our cookies. Checkout our Cookie Policy for more information.

Most basic code formatting

When working on Javascript/Typescript projects probably most of us know the following;

  • eslint is used to avoid code errors
  • prettier is used to format you text

These are tools that you need to add. But the most elemental code formatting is not here, it is in the widely supported .editorconfig file.

You can generate such a file with this command:

npx editorconfig-cli init -y

It is basically an ini file

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
quote_type = single

The best thing is that your code editor or IDE will recognise this file automatically and formats your code per this .editorconfig file by default, or there is a plugin.

And if you want to include these rules in linting locally or in the pipeline, even prettier supports it!

Happy coding!

Last Stories

What's your thoughts?

Please Register or Login to your account to be able to submit your comment.