Every check the language server runs reports its problems under a stable code, which is the name of its rule: Html/ImgAlt, Syntax/Ruby. In VS Code the code appears next to the message in the Problems panel and in the hover over the underlined text, with alder as the source. The alder check command prints the same messages as file:line:column: severity: message [Code], and exits with 1 when it finds an error or a warning (not for information, such as Rails/InstanceVariableInPartial), or a problem in a .alder.toml.
The messages are those of Erubi, Rails, Haml 7, Slim 5, Pug 3 and Prism, or quote the section of the HTML standard that is broken. Each entry below shows a template that triggers the code and the message alder check prints for it, at the same line and column.
Turning diagnostics off
Section titled “Turning diagnostics off”Turn a check off in the .alder.toml of the project, by the rule’s name (the code):
[Html.ImgAlt]
enabled = false
[Html.DuplicateId]
exclude = ["app/views/legacy/**"]
[Rails.MissingPartial]
exclude = ["**/*.haml"]
The file is read by the editor and by alder check, and it beats the settings below: a rule the file switches with enabled stays as the file says. The rules reference describes the file.
Or list the codes to turn off for a language in your settings.json:
"alder.erb.disabledDiagnostics": ["Html/ImgAlt", "Html/DuplicateId"],
"alder.haml.disabledDiagnostics": ["Rails/MissingPartial"]
alder.slim.disabledDiagnostics also applies to Skim templates, and alder.jbuilder.disabledDiagnostics to Jbuilder and Builder views; alder.liquid.disabledDiagnostics and alder.pug.disabledDiagnostics turn off the Liquid and Pug ones. To silence a whole language, set alder.erb.diagnostics.enabled, alder.haml.diagnostics.enabled, alder.slim.diagnostics.enabled or alder.pug.diagnostics.enabled to false (in a .alder.toml: diagnostics.enabled = false under [erb], [haml], [slim] or [pug]). Thor templates (*.tt) get no diagnostics.
The rules reference lists the formatter rules next to the ones that report these codes.
ERB
Syntax/UnclosedErbTag
A <% with no %> after it.
Languages ERB
When it fires Erubi only compiles a tag it can close, so a <% without %> stays in the output as text, and the Ruby is printed instead of run. In HTML, < followed by % starts no tag (HTML 13.2.5.6). Reported only where the HTML tokenizer is between tags, not inside attribute values, comments or <script> and <style> bodies, and only in ERB with an HTML host (.html.erb and the like).
<p><%= @user.name %></p>
<p><%= @user.email</p>
[Syntax.UnclosedErbTag]
enabled = false"alder.erb.disabledDiagnostics": ["Syntax/UnclosedErbTag"]Html/UnexpectedCloseTag
An end tag with no open element of that name.
Languages ERB
When it fires The end tag closes nothing, so the browser drops it. Also reported for the end tag of a void element ("End tag </br> for a void element") and for a </p> after a block element such as <div> already closed the paragraph. A stray end tag in a partial is not reported, since a partial may close what another one opened. ERB with an HTML host only; checking stops after 20 tag problems in one file.
<div class="profile">
<p><%= @user.name %></p>
</div>
</div>
[Html.UnexpectedCloseTag]
enabled = false"alder.erb.disabledDiagnostics": ["Html/UnexpectedCloseTag"]Html/MismatchedCloseTag
An end tag that doesn't close the innermost open element.
Languages ERB
When it fires The message names the element that is still open and its line. When the end tag crosses an open element (<div><span></div>), the browser could recover in more than one way, so checking stops there instead of guessing. Reported in partials too. ERB with an HTML host only.
<div class="profile">
<span><%= @user.name %></div>
[Html.MismatchedCloseTag]
enabled = false"alder.erb.disabledDiagnostics": ["Html/MismatchedCloseTag"]Html/UnclosedElement
An element whose end tag never comes.
Languages ERB
When it fires Reported at the start tag when the file ends with the element still open. Elements whose end tag HTML lets you omit (li, p, td, option, …) and void elements are never reported. Partials are exempt, because a _header partial may open a <div> that _footer closes, and so is a file that ends inside an ERB block. ERB with an HTML host only.
<section class="users">
<h2>Users</h2>
[Html.UnclosedElement]
enabled = false"alder.erb.disabledDiagnostics": ["Html/UnclosedElement"]Rails/OutputControlFlow
Control flow in an output tag.
Languages ERB
When it fires <%= if @user %> is a syntax error, or prints a loop's value (<%= for x in y do %>): an output tag holds an expression, so a tag that opens if, unless, while, until, case, for or begin without closing it, or that starts with else, elsif, when, end, rescue or ensure, needs <% instead. Reported on the =, with a quick fix that removes it; the Ruby syntax errors it would cause are not shown, the template's other errors are. A complete expression such as <%= if a then b else c end %> is not reported.
<%= if @user %>
<p>hi</p>
<% end %>
[Rails.OutputControlFlow]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/OutputControlFlow"]Style/ErbTrimMode
Both %> and -%> in one template.
Languages ERB
When it fires Every closer of the kind the template uses less is reported, -%> when there are as many of each. Comments (<%#) and literal <%% tags are not counted, nor are closers with more on their line. Off by default: turn it on with enabled = true under [Style.ErbTrimMode] in .alder.toml.
<% @users.each do |user| -%>
<li><%= user.name %></li>
<% end %>
[Style.ErbTrimMode]
enabled = false"alder.erb.disabledDiagnostics": ["Style/ErbTrimMode"]ERB, Haml, Slim, and Pug
Html/ImgAlt
An image without alt text.
Languages ERB, Haml, Slim, and Pug
When it fires Fires for an <img> (%img in Haml, img in Slim and Pug) with no alt attribute and for an image_tag call whose options have no alt:; that one reads "image_tag without alt:". In ERB the call must be in an output tag. Not reported for an <img> with ERB where attributes go (<img <%= attrs %>>), a Haml **attrs, a Slim *attrs or a Pug &attributes(…), an image_tag given a **splat, or generator-unable-to-provide-required-alt, since each may supply the text. An empty alt="" counts as alt text. Templates that output HTML only: not .js.erb, .text.erb or .xml.haml.
<img src="<%= @user.avatar_url %>">
[Html.ImgAlt]
enabled = false"alder.erb.disabledDiagnostics": ["Html/ImgAlt"],
"alder.haml.disabledDiagnostics": ["Html/ImgAlt"],
"alder.slim.disabledDiagnostics": ["Html/ImgAlt"],
"alder.pug.disabledDiagnostics": ["Html/ImgAlt"]Html/DuplicateId
The same static id twice in one template.
Languages ERB, Haml, Slim, and Pug
When it fires Reported at the second occurrence, naming the line of the first. Only literal values count: an id holding ERB or interpolation is left alone, and so is an element with both #id and id: in Haml (it gets one joined id). Two ids in different branches of a conditional don't clash, and content inside <template> isn't in the document yet. In Haml and Slim, ids are also left alone when one of them sits in a conditional, a loop or a block that the other is not in. Templates that output HTML only.
<div id="profile">
<%= @user.name %>
</div>
<div id="profile"></div>
[Html.DuplicateId]
enabled = false"alder.erb.disabledDiagnostics": ["Html/DuplicateId"],
"alder.haml.disabledDiagnostics": ["Html/DuplicateId"],
"alder.slim.disabledDiagnostics": ["Html/DuplicateId"],
"alder.pug.disabledDiagnostics": ["Html/DuplicateId"]Html/AnchorHref
An <a> without an href, which is not a link and cannot be reached with the keyboard.
Languages ERB, Haml, Slim, and Pug
When it fires Reported on the tag name. link_to always has an href and is not checked. An <a> with a name, a tabindex, an id and no text of its own, or an attribute ending in :href (:href, x-bind:href), and one inside an <svg>, is left alone, as is one whose attributes may come from code that can't be read (ERB inside the start tag, **attrs, *attrs), is left alone. Templates that output HTML only.
<a class="btn" data-action="click->menu#open">Menu</a>
[Html.AnchorHref]
enabled = false"alder.erb.disabledDiagnostics": ["Html/AnchorHref"],
"alder.haml.disabledDiagnostics": ["Html/AnchorHref"],
"alder.slim.disabledDiagnostics": ["Html/AnchorHref"],
"alder.pug.disabledDiagnostics": ["Html/AnchorHref"]Html/NestedInteractive
An interactive element inside another: a link in a link, a form in a form.
Languages ERB, Haml, Slim, and Pug
When it fires Reported on the inner element's tag name or helper name. A link or button (also link_to, tag.a, button_tag with a block) can't hold another link, a button, an <input> that isn't hidden, a <select>, <textarea>, <label>, <iframe>, <details>, controls of <audio> and <video>, or an <img usemap> (HTML 4.5.1); a form can't hold a form, and button_to renders one (HTML 4.10.3). Only nesting the template writes is reported: partials rendered inside the element, a yield, elements started and ended in different branches of an if, and anything in an <svg> or <template> are left alone, and so are a <label> around its <input> and a hidden input. Templates that output HTML only.
<%= link_to user_path(user) do %>
<%= link_to "Edit", edit_user_path(user) %>
<% end %>
[Html.NestedInteractive]
enabled = false"alder.erb.disabledDiagnostics": ["Html/NestedInteractive"],
"alder.haml.disabledDiagnostics": ["Html/NestedInteractive"],
"alder.slim.disabledDiagnostics": ["Html/NestedInteractive"],
"alder.pug.disabledDiagnostics": ["Html/NestedInteractive"]A11y/IframeTitle
An <iframe> without a title, which screen readers use to name it.
Languages ERB, Haml, Slim, and Pug
When it fires Reported on the tag name, also for tag.iframe and content_tag :iframe. An aria-label or aria-labelledby (also in an aria: { label: … } hash) names the frame as well. Not reported where attributes may come from code that can't be read. Templates that output HTML only.
<iframe src="https://www.youtube.com/embed/<%= @video.youtube_id %>"></iframe>
[A11y.IframeTitle]
enabled = false"alder.erb.disabledDiagnostics": ["A11y/IframeTitle"],
"alder.haml.disabledDiagnostics": ["A11y/IframeTitle"],
"alder.slim.disabledDiagnostics": ["A11y/IframeTitle"],
"alder.pug.disabledDiagnostics": ["A11y/IframeTitle"]A11y/GenericLinkText
Link text that says nothing out of context: "click here", "here", "read more".
Languages ERB, Haml, Slim, and Pug
When it fires Reported on the text, for an <a> that holds only text and for a link_to, tag.a or content_tag :a given a string literal. The texts are "click here", "here", "read more", "learn more", "more", "more info", "more information", "link", "this link" and "click", in any case and ignoring punctuation. A link with an aria-label, aria-labelledby or aria-describedby, or with ERB, interpolation or other elements inside, is left alone. Templates that output HTML only.
<p>Our new pricing is live. <%= link_to "Click here", pricing_path %></p>
[A11y.GenericLinkText]
enabled = false"alder.erb.disabledDiagnostics": ["A11y/GenericLinkText"],
"alder.haml.disabledDiagnostics": ["A11y/GenericLinkText"],
"alder.slim.disabledDiagnostics": ["A11y/GenericLinkText"],
"alder.pug.disabledDiagnostics": ["A11y/GenericLinkText"]Layout/LineLength
A line longer than the limit.
Languages ERB, Haml, Slim, and Pug
When it fires Every line over max characters (100 unless set) is reported from the first character past the limit. Characters are counted, a tab is one, trailing whitespace is not counted, and a line that cannot be made shorter is skipped: one with no space after its indentation, such as a long URL, and the # locals: comment of strict locals. Off by default: turn it on with enabled = true under [Layout.LineLength] in .alder.toml, where max sets the limit.
<p class="lead text-muted"><%= link_to "Read the full announcement", announcement_path(@announcement), class: "link" %></p>
[Layout.LineLength]
enabled = false"alder.erb.disabledDiagnostics": ["Layout/LineLength"],
"alder.haml.disabledDiagnostics": ["Layout/LineLength"],
"alder.slim.disabledDiagnostics": ["Layout/LineLength"],
"alder.pug.disabledDiagnostics": ["Layout/LineLength"]ERB, Haml, and Slim
Html/DuplicateAttribute
An attribute given twice on one tag.
Languages ERB, Haml, and Slim
When it fires Reported at the second one, for names written out in ERB start tags, Haml tags (the (…) list and the {…} hash) and Slim tags, and in the literal options of Rails tag helpers. In ERB markup the page gets both, so the second is reported; in Haml and the helpers a repeated key renders once, so the value that is dropped is reported. class and id are left alone in Haml, Slim and the helpers, which merge them. An ERB start tag with ERB inside is left alone. Slim rejects a repeated attribute itself, which is reported as Syntax/Template. Templates that output HTML only.
<div class="card" class="wide">
<%= @user.name %>
</div>
[Html.DuplicateAttribute]
enabled = false"alder.erb.disabledDiagnostics": ["Html/DuplicateAttribute"],
"alder.haml.disabledDiagnostics": ["Html/DuplicateAttribute"],
"alder.slim.disabledDiagnostics": ["Html/DuplicateAttribute"]Rails/SilentRender
A render in a tag that outputs nothing.
Languages ERB, Haml, and Slim
When it fires A <% %> tag in ERB, and a - line in Haml and Slim, run Ruby and print nothing, so the partial render returns is thrown away. Reported for a render that is a whole statement, also in its block form. Not reported when the result is assigned or passed on. Rails projects only, in templates under app/views. The quick fix changes the tag to <%= (= in Haml and Slim) when the call is alone in its tag or line.
<% render "users/card", user: @user %>
[Rails.SilentRender]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/SilentRender"],
"alder.haml.disabledDiagnostics": ["Rails/SilentRender"],
"alder.slim.disabledDiagnostics": ["Rails/SilentRender"]Rails/SilentHelper
A helper that returns markup, called in a tag that outputs nothing.
Languages ERB, Haml, and Slim
When it fires link_to, image_tag, content_tag, form_with and the other helpers on the list return markup and do nothing else, so calling one in a <% %> tag (a - line in Haml and Slim) has no effect. Helpers with side effects (content_for, provide), your own helpers and calls on a receiver are not reported. Rails projects only, in templates under app/views. The quick fix changes the tag to <%= (= in Haml and Slim) when the call is alone in its tag or line.
<% link_to "Home", root_path %>
[Rails.SilentHelper]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/SilentHelper"],
"alder.haml.disabledDiagnostics": ["Rails/SilentHelper"],
"alder.slim.disabledDiagnostics": ["Rails/SilentHelper"]Rails/DebugOutput
Debugging left in a view.
Languages ERB, Haml, and Slim
When it fires p, pp, puts and debug with arguments, byebug, debugger, binding.irb and binding.pry, as a statement or as the whole of an output tag. A local variable named p, a method on a receiver, a call used as an argument and a call under an if or unless that tests Rails.env are not reported. Rails projects only, in templates under app/views.
<%= debug @user %>
<p><%= @user.name %></p>
[Rails.DebugOutput]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/DebugOutput"],
"alder.haml.disabledDiagnostics": ["Rails/DebugOutput"],
"alder.slim.disabledDiagnostics": ["Rails/DebugOutput"]Rails/InstanceVariableInPartial
An instance variable read inside a partial.
Languages ERB, Haml, and Slim
When it fires A partial that reads @user works only for the controllers that set it. Pass it as a local instead (render "users/card", user: @user). Reported once per variable and file. Not reported when the partial assigns the variable itself, for defined?(@user), for ActionView's own variables, and in partials under app/views/layouts. Reported as information, so alder check prints it without failing. Rails projects only, in templates under app/views.
<p><%= @user.name %></p>
[Rails.InstanceVariableInPartial]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/InstanceVariableInPartial"],
"alder.haml.disabledDiagnostics": ["Rails/InstanceVariableInPartial"],
"alder.slim.disabledDiagnostics": ["Rails/InstanceVariableInPartial"]Rails/UnusedStrictLocal
A local in the locals: comment that the partial never uses.
Languages ERB, Haml, and Slim
When it fires Reads, assignments, local_assigns[:name], local_assigns.fetch(:name), binding.local_variable_get(:name), defined?(name) and the default of another local count as use. Nothing is reported when the template passes local_assigns on as a whole or calls binding, local_variables or eval. The quick fix removes the local from the comment. Rails 7.1 or newer, in Rails projects, in templates under app/views.
<%# locals: (user:, compact: false) %>
<p><%= user.name %></p>
[Rails.UnusedStrictLocal]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/UnusedStrictLocal"],
"alder.haml.disabledDiagnostics": ["Rails/UnusedStrictLocal"],
"alder.slim.disabledDiagnostics": ["Rails/UnusedStrictLocal"]Rails/UnusedBlockArgument
A block argument the block never uses.
Languages ERB, Haml, and Slim
When it fires Looks at plain and optional block parameters, and at the whole block, which spans every tag between do |…| and end. Names starting with _, it and numbered parameters, destructured, *rest, keyword and &block parameters, and blocks that call binding, local_variables or eval are not reported. The quick fix prefixes the name with _. Rails projects only, in templates under app/views.
<% @users.each do |user, index| %>
<li><%= user.name %></li>
<% end %>
[Rails.UnusedBlockArgument]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/UnusedBlockArgument"],
"alder.haml.disabledDiagnostics": ["Rails/UnusedBlockArgument"],
"alder.slim.disabledDiagnostics": ["Rails/UnusedBlockArgument"]Rails/RenderInLoop
A partial rendered once per item inside a loop.
Languages ERB, Haml, and Slim
When it fires Reported for collection.each do |item| and each_with_index whose whole body is render "partial", name: item, with a string literal for the partial. render partial: "partial", collection: collection, as: :name renders the same markup in one call. Loops that do anything else, other locals and other iterators are not reported. Rails projects only, in templates under app/views.
<% @users.each do |user| %>
<%= render "users/card", user: user %>
<% end %>
[Rails.RenderInLoop]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/RenderInLoop"],
"alder.haml.disabledDiagnostics": ["Rails/RenderInLoop"],
"alder.slim.disabledDiagnostics": ["Rails/RenderInLoop"]Rails/UnsafeOutput
Output that skips Rails' HTML escaping.
Languages ERB, Haml, and Slim
When it fires raw x, x.html_safe and safe_concat x are reported on the method name, and the unescaped output markers <%== (ERB), != and !~ (Haml) and == (Slim) on the marker. raw x.to_json in a <script> is the usual idiom and is not reported. Not reported when the value is certainly safe: a literal whose interpolations are all safe ("Hi #{h(name)}"), yield, content_for, a t call with a literal key ending in _html or .html, or a call to sanitize, safe_join, strip_tags, json_escape, j, escape_javascript, h, html_escape, link_to, content_tag, render, capture, truncate (unless escape: false) and the like, or an escaper on ERB::Util, CGI or Rack::Utils. Not checked in text templates. Rails projects only, in templates under app/views.
<%= raw @user.bio %>
[Rails.UnsafeOutput]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/UnsafeOutput"],
"alder.haml.disabledDiagnostics": ["Rails/UnsafeOutput"],
"alder.slim.disabledDiagnostics": ["Rails/UnsafeOutput"]Rails/MissingTranslation
A lazy translation key with no entry in config/locales.
Languages ERB, Haml, and Slim
When it fires A literal lazy key (t(".title"), translate, with or without parentheses) is turned into its full key as Rails does (users/_form gives users.form.title, a layout keeps its folder) and must be in the default locale of the YAML files under config/locales: config.i18n.default_locale, en without one. The closest key of the view within two edits is offered. Absolute keys are not checked, since gems supply keys such as date.formats and helpers.submit.create; nor is a key with default:, scope: or locale:, a key with interpolation, or one in a view named for a gem in the Gemfile.lock. Nothing is reported without a config/application.rb or a locale file for the default locale, or when translations may come from elsewhere: Ruby locale files, I18n.load_path, I18n.backend, a gem that keeps them in a store. With config.i18n.fallbacks a key in any locale counts. Rails projects only, in templates under app/views.
<h1><%= t(".titel") %></h1>
[Rails.MissingTranslation]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/MissingTranslation"],
"alder.haml.disabledDiagnostics": ["Rails/MissingTranslation"],
"alder.slim.disabledDiagnostics": ["Rails/MissingTranslation"]Rails/UnknownRoute
A *_path or *_url helper that the app's routes don't define.
Languages ERB, Haml, and Slim
When it fires A *_path or *_url call without a receiver that no route of the app defines but that is within two edits of one (usr_path for user_path) is reported, with that route offered; a name with no route near it may come from a gem, a concern or lib, which can't be seen, so it is left alone. The routes are read with bin/rails runner once the editor has loaded them (setting alder.routes.enabled), so this is reported in the editor and not by alder check. Not reported: a call on a receiver (main_app.users_path, an engine's admin.users_path), Rails' asset and polymorphic helpers, rails_*, turbo_*, action_mailbox_*, omniauth_*, vite_* and asset_pack_* helpers, Devise's own helpers (session_path, edit_password_url, …) when the Gemfile.lock has devise, a view in a folder named for a gem (spree/, rails_admin/), a helper the app defines in app/helpers or names with a symbol (helper_method, delegate, define_method), a call under defined?, a route declared with direct, and a local variable or block parameter. A bare name (item_path with resources :items) could be a local the caller passes, so it is reported only when called with arguments or when the template's strict locals don't list it. Rails projects only, in templates under app/views.
<%= link_to @user.name, usr_path(@user) %>
[Rails.UnknownRoute]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/UnknownRoute"],
"alder.haml.disabledDiagnostics": ["Rails/UnknownRoute"],
"alder.slim.disabledDiagnostics": ["Rails/UnknownRoute"]Turbo/PermanentRequiresId
An element with data-turbo-permanent and no id.
Languages ERB, Haml, and Slim
When it fires Turbo keeps a permanent element across visits by matching its id on the next page, so without one the attribute does nothing. Read from ERB start tags, Haml and Slim tags, and the options of tag.div, content_tag, link_to and the form and button helpers; any value counts. An id of any kind (#id in Haml and Slim, an object reference such as %div[@user]) satisfies it. Nothing is reported where attributes may come from code that can't be read: ERB inside the start tag, a Haml **attrs or data: attrs, a Slim *attrs or data= hash, a helper's **options, or a value that isn't a literal. Rails projects only, in templates under app/views.
<div data-turbo-permanent>
<%= render 'shared/player' %>
</div>
[Turbo.PermanentRequiresId]
enabled = false"alder.erb.disabledDiagnostics": ["Turbo/PermanentRequiresId"],
"alder.haml.disabledDiagnostics": ["Turbo/PermanentRequiresId"],
"alder.slim.disabledDiagnostics": ["Turbo/PermanentRequiresId"]Stimulus/UnknownController
A data-controller name that no Stimulus controller has.
Languages ERB, Haml, and Slim
When it fires Each name in a static data-controller (also data: { controller: "…" } in Haml and in the options of tag, content_tag, link_to, button_to and the form helpers) must be a controller file in app/javascript/controllers (search_controller.js, admin/users_controller.js for admin--users; -controller, .ts, .jsx, .tsx and .mjs too) or a name a script in app/javascript registers with application.register("name", …). The closest controller within two edits is offered. Nothing is reported when the app has no app/javascript/controllers folder, loads controllers from another folder (eagerLoadControllersFrom("components", …), a context or glob outside the controllers folder, an importmap pin), registers one under a name the code computes, and not for a name with ERB or interpolation. Rails projects only, in templates under app/views.
<div data-controller="serch">
<%= text_field_tag :q %>
</div>
[Stimulus.UnknownController]
enabled = false"alder.erb.disabledDiagnostics": ["Stimulus/UnknownController"],
"alder.haml.disabledDiagnostics": ["Stimulus/UnknownController"],
"alder.slim.disabledDiagnostics": ["Stimulus/UnknownController"]Stimulus/UnknownTargetOrAction
A data-*-target or data-action method that its Stimulus controller doesn't have.
Languages ERB, Haml, and Slim
When it fires Static data-<controller>-target names are checked against the controller's static targets = ["…"], and the method of each data-action descriptor against the members its class defines (also data: { search_target: "…", action: "…" } in Haml and in the options of the Rails helpers). The closest name within two edits is offered. Only a controller that is one file in app/javascript/controllers and can be read with confidence is checked: a class that extends something other than Controller (a base controller is followed when imported by a relative path), computed member names, decorators, mixins and a static targets that is not a plain list skip it. Rails projects only, in templates under app/views.
<div data-controller="search">
<input data-search-target="querry">
</div>
[Stimulus.UnknownTargetOrAction]
enabled = false"alder.erb.disabledDiagnostics": ["Stimulus/UnknownTargetOrAction"],
"alder.haml.disabledDiagnostics": ["Stimulus/UnknownTargetOrAction"],
"alder.slim.disabledDiagnostics": ["Stimulus/UnknownTargetOrAction"]Haml
Syntax/InconsistentIndent
Indentation Haml can't follow.
Languages Haml
When it fires Haml's own indentation errors: a width other than the one the rest of the document uses, tabs mixed with spaces ("Indentation can't use both tabs and spaces."), or a line more than one level deeper than the one before ("The line was indented 2 levels deeper than the previous line."). Haml stops at its first error, so only that one is shown, and the Ruby isn't checked until it is fixed.
%section
%h2 Users
%ul
%li= @user.name
[Syntax.InconsistentIndent]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/InconsistentIndent"]Syntax/TopLevelIndent
The first line is indented.
Languages Haml
When it fires Haml measures every level from the first line, which must start at column 1.
%p= @user.name
[Syntax.TopLevelIndent]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/TopLevelIndent"]Syntax/IllegalNesting
Lines nested under something that can't hold them.
Languages Haml
When it fires Haml rejects lines nested under a tag that already has content on its own line, under plain text, and under a self-closing tag such as %br/; each has its own "Illegal nesting" message. Nesting under !!! has its own code, Syntax/DoctypeChildren.
%p= @user.name
%span Admin
[Syntax.IllegalNesting]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/IllegalNesting"]Syntax/UnmatchedBranch
An else, elsif or when that doesn't line up with its block.
Languages Haml
When it fires In Haml a branch keyword must stand at the indentation of the - if or - case it continues. One at another level is reported with the expected and actual levels; one with no open block before it reads "Got "else" with no preceding "if"". The first when may sit one level deeper than its case.
- if @users.any?
= render @users
- else
%p No users
[Syntax.UnmatchedBranch]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/UnmatchedBranch"]Syntax/IllegalElement
A . or # with no class or id name after it.
Languages Haml
When it fires Haml needs a name after each . and # in a tag (%p.lead, #main).
%p. Hello
[Syntax.IllegalElement]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/IllegalElement"]Syntax/UnknownFilter
A filter Haml doesn't have.
Languages Haml
When it fires The name after : isn't one of Haml's filters (:javascript, :css, :markdown, :plain, :ruby, …), usually a typo. Haml raises this when it compiles the template. A name that isn't a word at all is a Syntax/Template ("Invalid filter name").
:mardown
# Users
[Syntax.UnknownFilter]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/UnknownFilter"]Syntax/SelfClosingContent
Content after a tag closed with /.
Languages Haml
When it fires A tag ending in / renders as <br /> and can hold nothing on its own line.
%br/ Hello
[Syntax.SelfClosingContent]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/SelfClosingContent"]Haml and Slim
Syntax/DoctypeChildren
Lines nested under the doctype.
Languages Haml and Slim
When it fires The doctype line (!!! in Haml, doctype in Slim) takes no children; the %html or html that follows belongs at the same level. Slim reports it as "Unexpected indentation".
!!! 5
%html
[Syntax.DoctypeChildren]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/DoctypeChildren"],
"alder.slim.disabledDiagnostics": ["Syntax/DoctypeChildren"]Syntax/ExplicitEnd
A - end line.
Languages Haml and Slim
When it fires Haml and Slim close a Ruby block by un-indenting, and both refuse an explicit - end. Slim's message is shown here; Haml's starts with "You don't need to use "- end" in Haml." and goes on with an example. Skim templates, whose code is CoffeeScript, are not checked for it.
- if @user.admin?
p Admin
- end
[Syntax.ExplicitEnd]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/ExplicitEnd"],
"alder.slim.disabledDiagnostics": ["Syntax/ExplicitEnd"]Syntax/UnclosedAttribute
An attribute list or value that is never closed.
Languages Haml and Slim
When it fires Slim reports the bracket it expected ("Expected closing delimiter )", or ] or }), or "Unexpected end of file" for a quote left open. Haml reports "Unbalanced brackets." for a { or ( attribute list that doesn't close, and "Invalid attribute list" for one it can't read.
a href=(user_path(@user) Profile
[Syntax.UnclosedAttribute]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/UnclosedAttribute"],
"alder.slim.disabledDiagnostics": ["Syntax/UnclosedAttribute"]Syntax/Template
Any other error the Haml or Slim parser raises.
Languages Haml and Slim
When it fires The parser errors that have no code of their own. In Haml: "Invalid tag", "Invalid filter name" and "There's no Ruby code for = to evaluate." In Slim: "Unknown line indicator", "Illegal shortcut", "Invalid empty attribute", "Expected attribute", "Expected tag" for a block expansion with nothing after it (ul:), "Unexpected text after closed tag", "Multiple id attributes specified" (for any repeated attribute) and "Invalid doctype".
%p=
[Syntax.Template]
enabled = false"alder.haml.disabledDiagnostics": ["Syntax/Template"],
"alder.slim.disabledDiagnostics": ["Syntax/Template"]Haml, Slim, and Pug
Html/VoidChildren
Content inside a void element such as img or input.
Languages Haml, Slim, and Pug
When it fires Void elements have no end tag, so the content would end up after them. Haml reports content on the tag's line or nested under it. Slim reports lines nested under a void element, and "Unexpected indentation" under a tag closed with /. In Slim it applies to HTML templates only, not to .xml.slim and other formats. Pug refuses to compile a void element, or a tag closed with /, that holds anything but blank text; that is reported as an error with Pug's own message, at the first such tag. A tag closed with / counts whatever its name, #{…} too; a void element doesn't after a doctype xml, until a doctype with another name.
img src="/logo.png"
| Logo
[Html.VoidChildren]
enabled = false"alder.haml.disabledDiagnostics": ["Html/VoidChildren"],
"alder.slim.disabledDiagnostics": ["Html/VoidChildren"],
"alder.pug.disabledDiagnostics": ["Html/VoidChildren"]Slim
Syntax/BadDedent
A line un-indented to a level no open line has.
Languages Slim
When it fires When a line moves left, Slim needs it to land on the indentation of a line still open above it. Here li Two stops between ul and li One.
section
ul
li One
li Two
[Syntax.BadDedent]
enabled = false"alder.slim.disabledDiagnostics": ["Syntax/BadDedent"]Syntax/UnknownEngine
An embedded engine Slim doesn't know.
Languages Slim
When it fires A lone name: line opens an embedded engine. Slim's own are ruby, javascript, css, sass, scss, coffee, markdown, textile, rdoc and asciidoc; for any other Slim raises "Expected tag". Engines your app registers (such as mjml) go in alder.slim.extraEngines.
markdwn:
# Users
[Syntax.UnknownEngine]
enabled = false"alder.slim.disabledDiagnostics": ["Syntax/UnknownEngine"]Liquid
Syntax/LiquidUnclosedTag
A {{ or {% with no }} or %} after it.
Languages Liquid
When it fires Liquid reads the rest of the template as part of the output or tag, so it fails to render ("Variable '{{' was not properly terminated", "Tag '{%' was not properly terminated"). Checking stops at the first one, since what follows is inside it. Not reported inside {% raw %} and {% comment %}, whose content is not parsed.
<h2>{{ page.title</h2>
<p>{{ page.excerpt</p>
[Syntax.LiquidUnclosedTag]
enabled = false"alder.liquid.disabledDiagnostics": ["Syntax/LiquidUnclosedTag"]Syntax/LiquidUnclosedBlock
A block tag such as if or for with no end tag.
Languages Liquid
When it fires Liquid raises "'if' tag was never closed" and renders nothing. Reported on the opening tag, for if, unless, for, case, capture, comment, raw, tablerow, form, paginate and highlight, also inside a multi-line {% liquid %} tag. A block left open by an end tag for an outer block is reported here too. Tags the app registers itself are not checked.
{% if page.author %}
<p>{{ page.author }}</p>
<p>{{ page.date }}</p>
[Syntax.LiquidUnclosedBlock]
enabled = false"alder.liquid.disabledDiagnostics": ["Syntax/LiquidUnclosedBlock"]Syntax/LiquidStrayEndTag
An end tag with no open block to close.
Languages Liquid
When it fires Liquid raises "Unknown tag 'endif'": the tag closes nothing. Often the opening tag was deleted or sits in another file; Liquid reads each template on its own.
<p>{{ page.author }}</p>
{% endif %}
[Syntax.LiquidStrayEndTag]
enabled = false"alder.liquid.disabledDiagnostics": ["Syntax/LiquidStrayEndTag"]Syntax/LiquidMismatchedEndTag
An end tag that doesn't match the innermost open block.
Languages Liquid
When it fires Liquid raises "'endfor' is not a valid delimiter for if tags. use endif". When the end tag belongs to an outer block, the blocks inside it are reported as Syntax/LiquidUnclosedBlock instead; otherwise the end tag is taken for a typo and closes the innermost block.
{% if page.tags %}
<p>{{ page.tags }}</p>
{% endfor %}
[Syntax.LiquidMismatchedEndTag]
enabled = false"alder.liquid.disabledDiagnostics": ["Syntax/LiquidMismatchedEndTag"]Pug
Syntax/PugInconsistentIndent
Indentation Pug can't follow, or tabs and spaces mixed.
Languages Pug
When it fires Pug raises PUG:INCONSISTENT_INDENTATION for a line un-indented to a level no open line has, and PUG:INVALID_INDENTATION ("Invalid indentation, you can use tabs or spaces but not both") for a line indented with the other character than the lines before it. The template doesn't compile. Like every Pug error, only the first one is reported, at the line and column Pug gives: Pug stops there.
ul.users
li= user.name
li= user.email
[Syntax.PugInconsistentIndent]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugInconsistentIndent"]Syntax/PugUnclosedBracket
An attribute list, interpolation or expression whose bracket is never closed, or closed by the wrong one.
Languages Pug
When it fires Pug raises PUG:NO_END_BRACKET when an attribute list (…), the arguments of a mixin call or of &attributes(…), or a #{…} or #[…] interpolation runs to the end of the line or the file, and PUG:BRACKET_MISMATCH when a bracket inside it is closed by another kind. The JavaScript inside is not otherwise checked.
li(class={active: user.active) Profile
[Syntax.PugUnclosedBracket]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugUnclosedBracket"]Syntax/PugInvalidName
A #id or .class that isn't a valid name.
Languages Pug
When it fires Pug raises PUG:INVALID_ID or PUG:INVALID_CLASS_NAME: an id may hold letters, digits, _ and -, and a class name the same with at least one letter or _. Use an attribute for any other value: div(class="6").
.grid
.col.6 Name
[Syntax.PugInvalidName]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugInvalidName"]Syntax/PugDuplicateAttribute
An attribute given twice on one tag, id included.
Languages Pug
When it fires Pug raises PUG:DUPLICATE_ATTRIBUTE, or PUG:DUPLICATE_ID for a #id shorthand after an id attribute; the template doesn't compile. class is the exception: Pug joins several classes.
input#email(type="email" id="user-email")
[Syntax.PugDuplicateAttribute]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugDuplicateAttribute"]Syntax/PugMalformedKeyword
A keyword such as each, case or include without the expression or path it needs, or with one it can't take.
Languages Pug
When it fires Pug raises PUG:MALFORMED_EACH (each user from users, or - each with a dash), PUG:MALFORMED_EACH_OF_LVAL (an each … of whose variable is neither a name nor a [key, value] pair; Pug tries each … of first, so each offer in offers is one, as of starts offers), PUG:NO_CASE_EXPRESSION, PUG:NO_WHEN_EXPRESSION, PUG:NO_WHILE_EXPRESSION, PUG:NO_INCLUDE_PATH, PUG:NO_EXTENDS_PATH, PUG:MALFORMED_INCLUDE, PUG:MALFORMED_EXTENDS, PUG:DEFAULT_WITH_EXPRESSION and PUG:ELSE_CONDITION (else x, where else if x was meant).
each user from users
li= user.name
[Syntax.PugMalformedKeyword]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugMalformedKeyword"]Syntax/PugIllegalNesting
Lines nested under buffered code or a raw include, which can't hold them.
Languages Pug
When it fires Pug raises PUG:BLOCK_IN_BUFFERED_CODE for lines indented under a = code or != code line, and PUG:RAW_INCLUDE_BLOCK for lines under an include of a file that isn't Pug. Unbuffered - code may hold a block.
ul
= user.name
li admin
[Syntax.PugIllegalNesting]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugIllegalNesting"]Syntax/PugTemplate
Any other error the Pug parser raises.
Languages Pug
When it fires Pug's lexer and parser errors that belong to no other code, such as PUG:UNEXPECTED_TEXT, PUG:INVALID_TOKEN, PUG:MIXIN_WITHOUT_BODY and PUG:BLOCK_OUTISDE_MIXIN (an anonymous block outside a mixin), with Pug's message. A few templates make Pug itself throw a JavaScript error (a # with nothing after it, a lone . under a tag); that error's message is reported. Nesting more than 256 levels deep (tags, #[…], block expansion, if, else if, loops, case) is reported here too, as "Nested more than 256 levels deep, which isn't checked", and the template is checked no further; Pug itself runs out of stack some hundreds of levels deeper. The JavaScript in - code, #{} and attribute values is not checked, so Pug's PUG:SYNTAX_ERROR is never reported.
mixin badge
p Hello
[Syntax.PugTemplate]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugTemplate"]Syntax/PugMissingFile
An include or extends of a file that doesn't exist.
Languages Pug
When it fires Pug reads the file when it compiles the template and fails when it isn't there. A path without an extension gets .pug, so include row never finds pug-rails' row.jst.pug: write include row.jst.pug. A relative path starts from the template's folder; an absolute one (/shared/nav) from app/assets/templates, else app/assets/javascripts, standing in for the basedir option, and isn't checked when neither exists. Here users/row.jst.pug and layout.pug exist.
extends ../layout
block content
include row
[Syntax.PugMissingFile]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugMissingFile"]Syntax/PugExtendsNotFirst
An extends that isn't the template's first statement, or a second one.
Languages Pug
When it fires pug-linker raises PUG:EXTENDS_NOT_FIRST with this message. Blank lines and //- comments may come before extends, since Pug drops them; a doctype, a // comment (it is output) or a mixin may not. The layout's doctype belongs in the layout.
doctype html
extends ../layout
[Syntax.PugExtendsNotFirst]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugExtendsNotFirst"]Syntax/PugUnexpectedBlock
A block of an extending template that its layouts don't have.
Languages Pug
When it fires pug-linker raises PUG:UNEXPECTED_BLOCK for a block at the top level of an extending template, append and prepend included, whose name isn't in its layout once linked: no layout up the extends chain has it (with the files they include), a layout that replaces a block drops the blocks that block held, and a block the template nests in another counts only inside one the layout has. Blocks of a file the template includes at its top level count as its own and are reported on the include line. Not reported when a file on the way is missing, has a syntax error or includes itself. Here layout.pug has block content only.
extends ../layout
block content
ul.users
block sidebar
p Filters
[Syntax.PugUnexpectedBlock]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugUnexpectedBlock"]Syntax/PugUnknownMixin
A +mixin call with no definition in the template, the files it includes or its layouts.
Languages Pug
When it fires Pug compiles the call and fails when the template renders (pug_mixins.usr is not a function). A template that another one includes or extends may call that one's mixins, so the call is only reported in a template inside an app/ folder that no Pug file in it pulls in, and when every file it includes and extends is there and parses. A +#{name} call is never reported. Here mixins.pug defines mixin user(user).
include ../mixins
ul
each user in users
+usr(user)
[Syntax.PugUnknownMixin]
enabled = false"alder.pug.disabledDiagnostics": ["Syntax/PugUnknownMixin"]ERB, Haml, Slim, and Jbuilder
Syntax/Ruby
Ruby in the template that doesn't parse.
Languages ERB, Haml, Slim, and Jbuilder
When it fires The template is compiled the way Erubi, Haml or Slim compile it, and the result is parsed with Prism for the project's Ruby version; the message is Prism's. Haml and Slim code is checked only once the template itself parses. Also covers the locals: comment of strict locals (Rails 7.1 and later), for instance a local without a colon: # locals: (user) gives "user set as non-keyword argument for … Locals can only be set as keyword arguments." In Jbuilder and Builder views only that comment is checked, and in Skim templates nothing, since their code is CoffeeScript.
<ul>
<% @users.each do |user| %>
<li><%= user.name %></li>
</ul>
[Syntax.Ruby]
enabled = false"alder.erb.disabledDiagnostics": ["Syntax/Ruby"],
"alder.haml.disabledDiagnostics": ["Syntax/Ruby"],
"alder.slim.disabledDiagnostics": ["Syntax/Ruby"],
"alder.jbuilder.disabledDiagnostics": ["Syntax/Ruby"]Rails/MissingPartial
A render of a partial or template that isn't in app/views.
Languages ERB, Haml, Slim, and Jbuilder
When it fires Checks literal names in render "users/card", render partial:, render template: and Jbuilder's json.partial!, in a Rails app (actionview in Gemfile.lock) and in templates under app/views. A name with a folder is checked when that folder exists in app/views; a bare name (render "form") only in an action template, not a partial, whose controller chain is in the app, and the message then lists each folder Rails searches. Folders of view-shipping gems such as devise/ are skipped. The message is Rails' "Missing partial" or "Missing template", without the formats and view paths Rails adds.
<%= render "users/profile", user: @user %>
[Rails.MissingPartial]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/MissingPartial"],
"alder.haml.disabledDiagnostics": ["Rails/MissingPartial"],
"alder.slim.disabledDiagnostics": ["Rails/MissingPartial"],
"alder.jbuilder.disabledDiagnostics": ["Rails/MissingPartial"]Rails/StrictLocals
A render whose locals don't match the partial's locals: comment.
Languages ERB, Haml, Slim, and Jbuilder
When it fires With Rails 7.1 or later in Gemfile.lock, a literal render that resolves to exactly one partial is compared with that partial's strict locals. Here _card.html.erb starts with <%# locals: (user:) -%>. The messages are Rails': "missing local", "missing keywords", "unknown local", "unknown keywords", and "no locals accepted" for a partial declaring locals: (). From Rails 7.2 they end with the partial's path. The layout: of a render isn't checked, since it gets the call's locals.
<%= render "users/card", person: @user %>
[Rails.StrictLocals]
enabled = false"alder.erb.disabledDiagnostics": ["Rails/StrictLocals"],
"alder.haml.disabledDiagnostics": ["Rails/StrictLocals"],
"alder.slim.disabledDiagnostics": ["Rails/StrictLocals"],
"alder.jbuilder.disabledDiagnostics": ["Rails/StrictLocals"]