Our coding standards are enforced in the internal CI by various tools like Rubocop and ESLint. To make sure you always keep them in mind, you can use git hooks based on overcommit for this.
$ overcommit --install
This will execute several checks on the changed files whenever you commit. Feel free to add suggestion for additional interesting commit hooks. 🚀
Linters can also be run manually:
# Robocop
$ bundle exec rubocop --parallel
# Type checks, ESLint & Stylelint
$ pnpm lint
# Type checks, ESLint & Stylelint with automatic fixing
$ pnpm lint:fix
# Just type checking
$ pnpm lint:ts
# Just ESLint checks
$ pnpm lint:js
# Just ESLint checks with automatic fixing
$ pnpm lint:js:fix
# Just Stylelint checks
$ pnpm lint:css
# Just Stylelint checks with automatic fixing
$ pnpm lint:css:fix
# Coffeelint
$ coffeelint --rules ./.dev/coffeelint/rules/* app/
Rubocop will tell you. Don't forget to run it. Here are some additional tips.
&.
to safely call method on possible nil
variable.Hash#fetch
for receiving values from hash and providing fall back value.Object#presence
to return variable value while treating non Object#present?
values as nil.The methods are doing model related functions and events. This area is mainly used to do changes to other related objects.
For example, a model
The code contains hooks to events (e.g. after_commit
), validations or another pre/post function checks.
For example:
The code contains new functions without any relations to any hook or event.
For example, a model will get some new util functions
UpperCamelCase: e.g. ApolloClient
lowerCamelCase_ e.g. fileSize
UpperCamelCase: e.g. CommonDateTime.vue
TBD
UpperCamelCase:
<div>
<CommonDateTime ... />
<CommonDateTime>...</CommonDateTime>
</div>