Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

## Unreleased

- `ruby-templates check` is faster on apps with many locale files or a large `app/javascript` (one template: about 700 ms to 45 ms on an app with 500 locale files, 700 scripts and `config.i18n.fallbacks = true`): `Rails/I18nMissingKey` reads the default locale's files, once, and the other locales only when a key is missing there; the Stimulus check runs its patterns only over scripts that can register controllers.
- **Breaking:** a department's `enabled = true` in a `.ruby-templates.toml` (`[Layout]`, `[Style]`, `[Turbo]`, ...) only turns back on the rules that are on by default, cancelling an `enabled = false` from a file above. A rule that is off by default (`Layout/EmptyLines`, `Turbo/PreferTurboAttributes`, `Layout/LineLength`, ...) needs its own `[Layout.EmptyLines] enabled = true`, so rules added later can't start rewriting files.
- **Breaking:** `disabled_diagnostics` and the `[jbuilder]` table are removed from `.ruby-templates.toml`; the file reports them as a problem that names the replacement, `[Html.ImgAlt] enabled = false` (or `exclude = [...]` for some files). The VS Code `rubyTemplates.<language>.disabledDiagnostics` settings stay.
- A rule that a `.ruby-templates.toml` enables with `enabled = true` stays on when `rubyTemplates.<language>.disabledDiagnostics` lists it, as the documented precedence says (the file beats the editor).
- **Breaking:** `ruby-templates check` prints the rule at the end of each text line, `file:line:col: severity: message [Html/ImgAlt]`, and `[Config/Invalid]` for a problem in a `.ruby-templates.toml`. `format --verbose` and the config problems `format` prints on stderr read the same way.
- **Breaking:** the columns of `ruby-templates check` text output count characters from 1 (a byte order mark takes none), as `github`, `json` and `sarif` do, instead of UTF-16 units.
- **Breaking:** the `info` severity is `info` in the text and JSON output (JSON said `note`); GitHub annotations keep `notice` and SARIF `note`, the words they require.
- **Breaking:** the `source` of every diagnostic is `ruby-templates`, for templates and for problems in a `.ruby-templates.toml` (it was `erb`, `haml`, `slim`, `ruby`, `liquid` and `ruby-templates-ls`).
- **Breaking:** `Rails/I18nMissingKey` is renamed `Rails/MissingTranslation`, in diagnostics, `.ruby-templates.toml` and `disabledDiagnostics`; the old name is an unknown rule.
- **Breaking:** the `rubyTemplates.reindentHaml` command is removed; Format Document and Format Selection do the same.
- Liquid is documented as experimental: the `liquid` language id, its extensions and its grammar are outside the 1.0 stability guarantees.
- The rules reference and the guides no longer describe shipped rules as a draft, a roadmap or planned, and no longer mention `ruby-templates-ls --check`.
- `ruby-templates --version` and `ruby-templates-ls --version` (or `-V`) print the version and exit 0 (the language server no longer starts for them); `ruby-templates --help`, `check --help` and `format --help` exit 0 instead of 2.
- `ruby-templates check` is faster on apps with many locale files or a large `app/javascript` (one template: about 700 ms to 45 ms on an app with 500 locale files, 700 scripts and `config.i18n.fallbacks = true`): `Rails/MissingTranslation` reads the default locale's files, once, and the other locales only when a key is missing there; the Stimulus check runs its patterns only over scripts that can register controllers.
- `Rails/MissingPartial` finds a partial in the format of the template that renders it, whichever gem or initializer registered that format: `index.mobile.haml` renders `_card.mobile.haml` (`mobile-fu`'s `:mobile`, a custom `.amp`) without a report.
- `Rails/UnsafeOutput` no longer reports a safe call with a trailing `if` or `unless` (`== render "a" if x`, `<%== render "a" unless x %>`, `!= render "a" if x`).
- `ruby-templates check` and `format` skip `lib/templates` (Rails generator templates), `vendor`, `tmp`, `public` and `log` when walking a folder, as well as hidden folders and `node_modules`; `app/views` may hold folders with those names, and files named on the command line are always processed. `.gitignore` is not read.
Expand Down
38 changes: 19 additions & 19 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

## Що тут лежить

| Папка | Для чого |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `rails_app/` | Мінімальний Rails-застосунок без Rails: `Gemfile.lock` з `actionview 8.0`, контролери, хелпери, компоненти, Stimulus, локалі, `config/application.rb` (без нього Rails/I18nMissingKey мовчить), `db/schema.rb`, маршрути |
| `rails_app/app/views/users`, `shared`, `admin`, `layouts`, `user_mailer` | В'ю для навігації, автодоповнення й hover (ERB, Haml, Slim, Jbuilder) |
| `rails_app/engines/blog`, `rails_app/app/views/blog` | Engine в репозиторії (`path:`-гем у `Gemfile`) з `blog/_post` і `blog/_sidebar`; застосунок перекриває `_sidebar` (`users/engines.html.erb`) |
| `rails_app/lib/reports` | ERB з рядками `%` для мови `erb-percent` (її вмикає `files.associations` у `.vscode/settings.json`) |
| `shop_app/`, `demo.code-workspace` | Другий Rails-застосунок для вікна з двома застосунками: свої партіали, переклади, маршрути, `render "x"` без папки |
| `rails_app/app/views/playground/broken` | По одній проблемі на файл для перевірки діагностики |
| `rails_app/app/views/playground/format` | Погано відформатовані файли та файли, які форматер має лишити без змін |
| `rails_app/app/views/playground/editing` | Команди редагування: toggle, wrap, extract partial, коментарі в `.js.erb`, `.css.erb`… і в багаторядкових тегах |
| `rails_app/app/views/playground/editorconfig` | Однаковий файл під чотирма секціями `.editorconfig` (глоби) |
| `rails_app/app/views/playground/liquid` | Liquid: тема магазину й Jekyll-include (`_includes/header.html`) |
| `rails_app/app/views/playground/highlight` | Зразки підсвітки (копії `test/sample.*`) |
| `rails_app/app/views/playground/preview` | Шаблони без Rails-хелперів для Preview / Show Compiled Ruby Source |
| `rails_app/app/views/playground/stimulus` | Атрибути Stimulus-контролерів елемента (`search_controller.js`) в ERB, Haml і Slim |
| `rails_app/app/views/playground/rules` | Правила 0.11–0.14 (Rails, Turbo, Stimulus, Html, A11y): у ERB, Haml і Slim, у кожному файлі спершу рядки, що попереджають, потім ті, що ні (розділ 9) |
| `rails_app/app/views/playground/rules/format` | Правила форматування, вимкнені за замовчуванням, і lint-и `Style/ErbTrimMode`, `Layout/LineLength`; власний `.ruby-templates.toml` вмикає їх усі (розділ 9) |
| `rails_app/bin/rails` | Заглушка: відповідає лише на запит маршрутів, щоб `*_path` працювали без встановленого Rails |
| `no_rails/` | Шаблони без `Gemfile.lock`: Rails-перевірки тут вимкнені |
| Папка | Для чого |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rails_app/` | Мінімальний Rails-застосунок без Rails: `Gemfile.lock` з `actionview 8.0`, контролери, хелпери, компоненти, Stimulus, локалі, `config/application.rb` (без нього Rails/MissingTranslation мовчить), `db/schema.rb`, маршрути |
| `rails_app/app/views/users`, `shared`, `admin`, `layouts`, `user_mailer` | В'ю для навігації, автодоповнення й hover (ERB, Haml, Slim, Jbuilder) |
| `rails_app/engines/blog`, `rails_app/app/views/blog` | Engine в репозиторії (`path:`-гем у `Gemfile`) з `blog/_post` і `blog/_sidebar`; застосунок перекриває `_sidebar` (`users/engines.html.erb`) |
| `rails_app/lib/reports` | ERB з рядками `%` для мови `erb-percent` (її вмикає `files.associations` у `.vscode/settings.json`) |
| `shop_app/`, `demo.code-workspace` | Другий Rails-застосунок для вікна з двома застосунками: свої партіали, переклади, маршрути, `render "x"` без папки |
| `rails_app/app/views/playground/broken` | По одній проблемі на файл для перевірки діагностики |
| `rails_app/app/views/playground/format` | Погано відформатовані файли та файли, які форматер має лишити без змін |
| `rails_app/app/views/playground/editing` | Команди редагування: toggle, wrap, extract partial, коментарі в `.js.erb`, `.css.erb`… і в багаторядкових тегах |
| `rails_app/app/views/playground/editorconfig` | Однаковий файл під чотирма секціями `.editorconfig` (глоби) |
| `rails_app/app/views/playground/liquid` | Liquid: тема магазину й Jekyll-include (`_includes/header.html`) |
| `rails_app/app/views/playground/highlight` | Зразки підсвітки (копії `test/sample.*`) |
| `rails_app/app/views/playground/preview` | Шаблони без Rails-хелперів для Preview / Show Compiled Ruby Source |
| `rails_app/app/views/playground/stimulus` | Атрибути Stimulus-контролерів елемента (`search_controller.js`) в ERB, Haml і Slim |
| `rails_app/app/views/playground/rules` | Правила 0.11–0.14 (Rails, Turbo, Stimulus, Html, A11y): у ERB, Haml і Slim, у кожному файлі спершу рядки, що попереджають, потім ті, що ні (розділ 9) |
| `rails_app/app/views/playground/rules/format` | Правила форматування, вимкнені за замовчуванням, і lint-и `Style/ErbTrimMode`, `Layout/LineLength`; власний `.ruby-templates.toml` вмикає їх усі (розділ 9) |
| `rails_app/bin/rails` | Заглушка: відповідає лише на запит маршрутів, щоб `*_path` працювали без встановленого Rails |
| `no_rails/` | Шаблони без `Gemfile.lock`: Rails-перевірки тут вимкнені |

## 0. Підготовка

Expand Down
2 changes: 1 addition & 1 deletion demo/rails_app/app/views/playground/rules/i18n.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# Rails/I18nMissingKey: the key is playground.rules.i18n.<name>; line 3 warns %>
<%# Rails/MissingTranslation: the key is playground.rules.i18n.<name>; line 3 warns %>
<h1><%= t(".title") %></h1>
<h2><%= t(".titel") %></h2>

Expand Down
2 changes: 1 addition & 1 deletion demo/rails_app/app/views/playground/rules/i18n.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-# Rails/I18nMissingKey: the key is playground.rules.i18n.<name>; line 3 warns
-# Rails/MissingTranslation: the key is playground.rules.i18n.<name>; line 3 warns
%h1= t(".title")
%h2= t(".titel")

Expand Down
2 changes: 1 addition & 1 deletion demo/rails_app/app/views/playground/rules/i18n.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/ Rails/I18nMissingKey: the key is playground.rules.i18n.<name>; line 3 warns
/ Rails/MissingTranslation: the key is playground.rules.i18n.<name>; line 3 warns
h1 = t(".title")
h2 = t(".titel")

Expand Down
2 changes: 1 addition & 1 deletion demo/rails_app/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Marks the folder as a Rails app, so the extension reads config/locales for Rails/I18nMissingKey.
# Marks the folder as a Rails app, so the extension reads config/locales for Rails/MissingTranslation.
module Demo
class Application < Rails::Application
config.i18n.default_locale = :en
Expand Down
Loading
Loading