Editor Setup
Overview¶
A properly configured editor can make code clearer to read and faster to write. It can even help you catch bugs as you write them! If this is your first time setting up an editor or you're looking to tune up your current editor, we have a few recommendations.
You will learn
- What the most popular editors are
- How to format your code automatically
Your editor¶
VS Code is one of the most popular editors in use today. It has a large marketplace of extensions and integrates well with popular services like GitHub. Most of the features listed below can be added to VS Code as extensions as well, making it highly configurable!
Other popular text editors used in the React community include:
- Sublime Text has support for syntax highlighting and autocomplete built in.
- Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems and with Apple OS X.
Recommended text editor features¶
Some editors come with these features built in, but others might require adding an extension. Check to see what support your editor of choice provides to be sure!
Linting¶
Linting is the process of running a program that will analyse code for potential errors. Ruff is Reactive Python's linter of choice due to its speed and configurability. Additionally, we recommend using Pyright as a performant type checker for Python.
Be sure you have Python installed before you proceed!
- Install Ruff using the VSCode extension or the standalone package.
- Install Pyright using the VSCode extension or the standalone package.
Formatting¶
The last thing you want to do when sharing your code with another contributor is get into an discussion about tabs vs spaces! Fortunately, Ruff will clean up your code by reformatting it to conform to preset, configurable rules. Run Ruff, and all your tabs will be converted to spacesβand your indentation, quotes, etc will also all be changed to conform to the configuration. In the ideal setup, Ruff will run when you save your file, quickly making these edits for you.
You can install the Ruff extension in VSCode by following these steps:
- Launch VS Code
- Use Quick Open, press Ctrl+P
- Paste in
ext install charliermarsh.ruff
- Press Enter
Formatting on save
Ideally, you should format your code on every save. VS Code has settings for this!
- In VS Code, press Ctrl+Shift+P
- Type "workspace settings"
- Hit Enter
- In the search bar, type "Format on save"
- Be sure the "Format on save" option is ticked!