Commands

Here are some useful commands and tools for working in this project:

erb-lint

We use erblint gem to ensure homogeneous formatting of erb files.

bundle exec erblint --lint-all --autocorrect
# shortest
bundle exec erblint --lint-all -a
# even shortest
bundle exec erblint -la -a

I18n

We use i18n-tasks gem to keep translations ordered and without missing/unused keys.

To fix the order of the keys, run:

# from the root of the project
bundle exec i18n-tasks normalize --locales en

To list unused i18n keys, run:

bundle exec  i18n-tasks unused --locales en

JavaScript linter

eslint and tslint are used to ensure homogeneous formatting of JavaScript code.

To lint and try to fix linting errors, run:

npm run lint --fix

Stylelinter

stylelint is a CSS linter and fixer that helps to avoid errors and enforce consistent conventions in the stylesheets. Is an npm package, install it using:

npm install -g stylelint

Linting a .scss file:

stylelint [path-to-file]

With --fix option stylelint will fix as many errors as possible. The fixes are made to the actual source files. All unfixed errors will be reported.

stylelint [path-to-file] --fix

Rubocop

RuboCop is a code analyzer tool we use at Decidim to enforce our code formatting guidelines.

# Run Rubocop
bundle exec rubocop
# Run Rubocop and automatically correct offenses
bundle exec rubocop -a

Markdown linter

This project uses markdownlint-cli to check markdown files and flag style issues.

Linting an .md file:

npx markdownlint [path-to-file]

With --fix option markdownlint-cli will fix as many errors as possible. The fixes are made to the actual source files. All unfixed errors will be reported.

npx markdownlint [path-to-file] --fix