Script Standard
Code Style
General Guidelines
- Be consistent!
- Avoid using deprecated features.
- Avoid modifying
yarn.lockandpackage.json, unless you are adding a new dependency. - Conbine repetitive code into functions.
- Prefer higher ECMAScript Standard features over lower ones.
- Sort the entries alphabetically (uppercase first) to make it easier to find an entry.
- Use HTTPS instead of HTTP whenever possible.
- Use WebP format instead of JPG whenever possible since it offers better compression.
Formatting
Indentation
- Use 4 spaces for indentation for consistent and easy-to-read code.
Semicolons
- Add a semicolon at the end of each statement for improved readability and consistency.
String
- Use single quotes instead of double quotes whenever possible for consistency and readability.
- Use template literals over complex string concatenation.
- Use template literals for GraphQL queries as they make the code more concise and easy to read.
Whitespace
- Add an empty line at the end of each file.
- Avoid trailing whitespace for a clean and readable codebase.
Language Features
Casting
- Avoid re-casting the same type.
Functions
- Prefer arrow functions over the
functionkeyword.
Loops
- Use
for-ofinstead offorfor arrays (javascript:S4138).
Variables
- Use
constandletinstead ofvar. - Declare one variable per declaration.