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
6 changes: 3 additions & 3 deletions .claude/commands/implement.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Plan and implement GitHub issue **#$ARGUMENTS** in this repo, end-to-end, on a f
3. **Plan before coding.** Produce a short plan covering:
- Which files you'll touch or create
- For new rules: the WCAG principle directory under `lib/a11y/lint/rules/`, the rule class name (see CLAUDE.md "Rule Scoping Convention"), and whether it has an HTML/helper pair
- Tests to add (Slim + ERB + Phlex parity per `.claude/rules/testing.md`)
- Dummy app fixtures to add in `test/fixtures/dummy_app/app/views/home/home.html.{slim,erb}` and any Phlex view
- Tests to add (ERB + Phlex parity per `.claude/rules/testing.md`)
- Dummy app fixtures to add in `test/fixtures/dummy_app/app/views/home/home.html.erb` and any Phlex view
- Open questions, if any — ask once, then proceed

4. **Implement the plan.**
- Follow `CLAUDE.md` (rule scoping, node interface, configuration loading) and `.claude/rules/testing.md` (no `setup`, all three calling styles for `ruby_code` rules, Slim/ERB/Phlex parity, inline HEREDOC fixtures).
- Follow `CLAUDE.md` (rule scoping, node interface, configuration loading) and `.claude/rules/testing.md` (no `setup`, all three calling styles for `ruby_code` rules, ERB/Phlex parity, inline HEREDOC fixtures).
- For new rules: register the rule, add good/bad examples to dummy app fixtures, and add a docs page under `docs/src/rules/` if the issue is adding a user-visible rule.
- Add an entry under `[Unreleased]` in `CHANGELOG.md` for any user-visible change (bug fixes, new rules, behavior changes). Skip for internal refactors and test-only changes.

Expand Down
2 changes: 1 addition & 1 deletion .claude/commands/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Idea: $ARGUMENTS
- **Proposed approach** — only include if the approach is obvious from the idea
- **Files likely involved** — only include if you can quickly identify them from the repo (e.g. a new rule idea should point at the right WCAG principle directory under `lib/a11y/lint/rules/`)

2. **Clarify only if necessary** — one round, max. Voice input drops context, but too many questions defeat frictionless capture. Skip clarification when the idea is unambiguous. Typical clarifications: bug vs. feature, which rule/file, which template pipeline (Slim/ERB/Phlex).
2. **Clarify only if necessary** — one round, max. Voice input drops context, but too many questions defeat frictionless capture. Skip clarification when the idea is unambiguous. Typical clarifications: bug vs. feature, which rule/file, which template pipeline (ERB/Phlex).

3. **Create the issue** with `gh issue create --title "..." --body "$(cat <<'EOF' ... EOF)"` against the current repo. Do **not** pass `--repo`. Do **not** add labels.

Expand Down
22 changes: 11 additions & 11 deletions .claude/rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ globs: test/**/*.rb
def setup
@offense = Offense.new(
rule: "ImgMissingAlt",
filename: "test.slim",
filename: "test.html.erb",
line: 1,
message: "missing alt"
)
Expand All @@ -26,7 +26,7 @@ globs: test/**/*.rb
def test_rule
offense = Offense.new(
rule: "ImgMissingAlt",
filename: "test.slim",
filename: "test.html.erb",
line: 1,
message: "missing alt"
)
Expand All @@ -36,17 +36,17 @@ globs: test/**/*.rb
```

- Rules that inspect `ruby_code` (e.g. `link_to`, `image_tag` helpers) must include test cases for all three calling styles:
1. Single-line with parentheses: `= link_to("", "/path", class: "icon")`
2. Single-line without parentheses: `= link_to "", "/path", class: "icon"`
1. Single-line with parentheses: `<%= link_to("", "/path", class: "icon") %>`
2. Single-line without parentheses: `<%= link_to "", "/path", class: "icon" %>`
3. Multiline with trailing comma:
```slim
= link_to(\
"",
"/path",
class: "icon",
)
```erb
<%= link_to(
"",
"/path",
class: "icon",
) %>
```

Each style must be tested for both the offense case and the "passes with fix" case.

- Every rule must be tested against the Slim, ERB, and Phlex pipelines.
- Every rule must be tested against the ERB and Phlex pipelines.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- **Breaking:** Slim support has been dropped. `.slim` files are no longer discovered or linted, and `SlimRunner`, `SlimNode`, and `SlimLoadError` have been removed along with the `slim` development dependency. a11y-lint now targets ERB and Phlex only

## [0.15.0] - 2026-05-06

### Changed
Expand Down
7 changes: 3 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ a11y-lint is a Ruby gem (v0.1.0) for accessibility linting. It uses the `A11y::L

## Architecture

- **CLI:** `lib/a11y/lint/cli.rb` — command-line interface; executable at `exe/a11y-lint`; routes `.slim` files to `SlimRunner`, `.erb` files to `ErbRunner`, and `.rb` files to `PhlexRunner`
- **CLI:** `lib/a11y/lint/cli.rb` — command-line interface; executable at `exe/a11y-lint`; routes `.erb` files to `ErbRunner` and `.rb` files to `PhlexRunner`
- **Entry point:** `lib/a11y/lint.rb` — defines the `A11y::Lint` module and `A11y::Lint::Error` exception
- **Slim pipeline:** `SlimRunner` parses Slim templates via `Slim::Parser`; `SlimNode` wraps Slim S-expressions
- **ERB pipeline:** `ErbRunner` parses ERB templates via Nokogiri; `ErbNode` wraps Nokogiri nodes and extracted `<%= %>` Ruby code
- **Phlex pipeline:** `PhlexRunner` parses Phlex view classes via Prism; `PhlexNode` wraps Prism AST call nodes; detects Phlex files by the presence of `def view_template`
- **Ruby code parsing:** `RubyCode` (`lib/a11y/lint/ruby_code.rb`) — parses a Ruby code string once with Prism and exposes the resulting `CallNode`; used by `SlimNode` and `ErbNode` so rules work against a parsed AST instead of re-parsing strings
- **Ruby code parsing:** `RubyCode` (`lib/a11y/lint/ruby_code.rb`) — parses a Ruby code string once with Prism and exposes the resulting `CallNode`; used by `ErbNode` so rules work against a parsed AST instead of re-parsing strings
- **Configuration:** `lib/a11y/lint/configuration.rb` — loads `.a11y-lint.yml` to enable/disable individual rules; searches upward from the target path
- **Rules:** `lib/a11y/lint/rules/` — organized by WCAG principle (`perceivable/`, `operable/`, `understandable/`, `robust/`); rules implement `check(node)` against the shared node interface (`tag_name`, `attribute?`, `attributes`, `call_node`, `line`)
- **Version:** `lib/a11y/lint/version.rb`
- **Type signatures (RBS):** `sig/a11y/lint.rbs`
- **Tests:** `test/` directory using Minitest; test helper at `test/test_helper.rb`
- **Dummy app:** `test/fixtures/dummy_app/` — a fixture app with Slim/ERB/Phlex templates for end-to-end smoke testing before releases (`bundle exec a11y-lint test/fixtures/dummy_app`)
- **Dummy app:** `test/fixtures/dummy_app/` — a fixture app with ERB/Phlex templates for end-to-end smoke testing before releases (`bundle exec a11y-lint test/fixtures/dummy_app`)
- **Documentation site:** `docs/` — Bridgetown site deployed to https://a11y-lint.guidedrails.com via `.github/workflows/docs.yml` on push to `main`. Has its own `Gemfile`, `package.json`, and Ruby version, and is excluded from the gem's RuboCop config. Rule reference pages live in `docs/src/rules/` (one page per WCAG concept; individual rule classes are anchor sections, e.g. `/rules/images-need-alt-text/#img-missing-alt`). Run locally with `cd docs && bin/bridgetown start`.

## Rule Scoping Convention
Expand Down
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ GEM
parser (>= 3.3.7.2)
prism (~> 1.7)
ruby-progressbar (1.13.0)
slim (5.2.1)
temple (~> 0.10.0)
tilt (>= 2.1.0)
stringio (3.2.0)
temple (0.10.4)
tilt (2.7.0)
tsort (0.2.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
Expand All @@ -81,7 +76,6 @@ DEPENDENCIES
minitest (~> 5.16)
rake (~> 13.0)
rubocop (~> 1.21)
slim (>= 4.0)

BUNDLED WITH
2.6.9
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Run the linter on specific files or directories:

```bash
a11y-lint app/views/
a11y-lint app/views/home.html.slim app/views/about.html.slim
a11y-lint app/views/home.html.erb app/views/about.html.erb
```

With no arguments, it scans the current directory recursively for `.slim`, `.erb`, and `.rb` (Phlex) files:
With no arguments, it scans the current directory recursively for `.erb` and `.rb` (Phlex) files:

```bash
a11y-lint
Expand Down Expand Up @@ -64,11 +64,6 @@ a11y-lint --config path/to/.a11y-lint.yml app/views/
```ruby
require "a11y/lint"

# Slim
source = File.read("app/views/home.html.slim")
runner = A11y::Lint::SlimRunner.new([A11y::Lint::Rules::ImgMissingAlt])
offenses = runner.run(source, filename: "app/views/home.html.slim")

# ERB
source = File.read("app/views/home.html.erb")
runner = A11y::Lint::ErbRunner.new([A11y::Lint::Rules::ImgMissingAlt])
Expand Down
2 changes: 0 additions & 2 deletions a11y-lint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ Gem::Specification.new do |spec|

spec.add_dependency "nokogiri", ">= 1.13"

spec.add_development_dependency "slim", ">= 4.0"

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
end
9 changes: 3 additions & 6 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ Rule pages live in `src/rules/`, one Markdown file per WCAG concept. Each rule c

### Showing example code in multiple template languages

a11y-lint supports ERB, Slim, and Phlex. When a rule page shows example code, render it through the `Shared::CodeTabs` component so all three pipelines collapse into one tabbed block instead of three stacked code blocks.
a11y-lint supports ERB and Phlex. When a rule page shows example code, render it through the `Shared::CodeTabs` component so both pipelines collapse into one tabbed block instead of two stacked code blocks.

ERB is required and is the default tab. Slim and Phlex are optional — omit either kwarg and the tab won't render.
ERB is required and is the default tab. Phlex is optional — omit the kwarg and the tab won't render.

```erb
<%= render Shared::CodeTabs.new(
erb: <<~ERB,
<img src="hero.jpg" alt="Team celebrating after a product launch">
ERB
slim: <<~SLIM,
img src="hero.jpg" alt="Team celebrating after a product launch"
SLIM
phlex: <<~PHLEX,
img(src: "hero.jpg", alt: "Team celebrating after a product launch")
PHLEX
Expand All @@ -26,7 +23,7 @@ ERB is required and is the default tab. Slim and Phlex are optional — omit eit

The component takes care of:

- Rouge syntax highlighting per tab (using the `erb`, `slim`, and `ruby` lexers).
- Rouge syntax highlighting per tab (using the `erb` and `ruby` lexers).
- WAI-ARIA tab pattern: `role="tablist"` / `role="tab"` / `role="tabpanel"` with full `aria-*` wiring.
- Keyboard navigation: Left/Right arrows move between tabs, Home/End jump to the first/last tab, Enter/Space activate, Tab moves into the panel.
- A no-JavaScript fallback that shows the ERB panel only.
Expand Down
5 changes: 2 additions & 3 deletions docs/src/_components/shared/code_tabs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
class Shared::CodeTabs < Bridgetown::Component
TABS = [
{ key: :erb, label: "ERB", lexer: "erb" },
{ key: :slim, label: "Slim", lexer: "slim" },
{ key: :phlex, label: "Phlex", lexer: "ruby" }
].freeze

attr_reader :id

def initialize(erb:, slim: nil, phlex: nil)
@samples = { erb: erb, slim: slim, phlex: phlex }
def initialize(erb:, phlex: nil)
@samples = { erb: erb, phlex: phlex }
@id = "code-tabs-#{SecureRandom.hex(4)}"
end

Expand Down
6 changes: 0 additions & 6 deletions docs/src/rules/form-controls-need-accessible-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ Or `aria-labelledby` pointing to existing visible text:
<%%= form.input :secret, as: :hidden, label: false %>
```

### Slim equivalent

```slim
= form.input :name, label: false, input_html: { aria: { label: "Name" } }
```

## What this rule doesn't catch

This rule has a deliberately narrow scope. Things it doesn't flag:
Expand Down
58 changes: 5 additions & 53 deletions docs/src/rules/images-need-alt-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ Applies to: HTML `<img>` elements.
erb: <<~ERB,
<img src="hero.jpg">
ERB
slim: <<~SLIM,
img src="hero.jpg"
SLIM
phlex: <<~PHLEX,
img(src: "hero.jpg")
PHLEX
Expand All @@ -85,9 +82,6 @@ Applies to: HTML `<img>` elements.
erb: <<~ERB,
<img src="hero.jpg" alt="Team celebrating after a product launch">
ERB
slim: <<~SLIM,
img src="hero.jpg" alt="Team celebrating after a product launch"
SLIM
phlex: <<~PHLEX,
img(src: "hero.jpg", alt: "Team celebrating after a product launch")
PHLEX
Expand All @@ -99,15 +93,7 @@ For a decorative image, use an empty `alt` so assistive tech skips it:
<img src="divider.svg" alt="">
```

### Slim and Phlex equivalents

Slim:

```slim
img src="hero.jpg" alt="Team celebrating after a product launch"
```

Phlex:
### Phlex equivalent

```ruby
img(src: "hero.jpg", alt: "Team celebrating after a product launch")
Expand Down Expand Up @@ -136,15 +122,7 @@ For a decorative image:
<%%= image_tag("divider.svg", alt: "") %>
```

### Slim and Phlex equivalents

Slim:

```slim
= image_tag("hero.jpg", alt: "Team celebrating after a product launch")
```

Phlex:
### Phlex equivalent

```ruby
image_tag("hero.jpg", alt: "Team celebrating after a product launch")
Expand All @@ -169,15 +147,7 @@ Applies to: HTML `<input type="image">` elements.
<input type="image" src="search.svg" alt="Search">
```

### Slim and Phlex equivalents

Slim:

```slim
input type="image" src="search.svg" alt="Search"
```

Phlex:
### Phlex equivalent

```ruby
input(type: "image", src: "search.svg", alt: "Search")
Expand All @@ -202,15 +172,7 @@ Applies to: Rails `image_submit_tag` helper (renders `<input type="image">`).
<%%= image_submit_tag("search.svg", alt: "Search") %>
```

### Slim and Phlex equivalents

Slim:

```slim
= image_submit_tag("search.svg", alt: "Search")
```

Phlex:
### Phlex equivalent

```ruby
image_submit_tag("search.svg", alt: "Search")
Expand Down Expand Up @@ -243,17 +205,7 @@ Each `<area>` is a clickable hotspot in an image map — effectively a link. Its
</map>
```

### Slim and Phlex equivalents

Slim:

```slim
img src="team-photo.jpg" alt="Our team" usemap="#team"
map name="team"
area shape="rect" coords="0,0,100,100" href="/team/alex" alt="Alex's profile"
```

Phlex:
### Phlex equivalent

```ruby
img(src: "team-photo.jpg", alt: "Our team", usemap: "#team")
Expand Down
2 changes: 0 additions & 2 deletions lib/a11y/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
require_relative "lint/call_node"
require_relative "lint/ruby_code"
require_relative "lint/block_inspection"
require_relative "lint/slim_node"
require_relative "lint/erb_element_node"
require_relative "lint/erb_output_node"
require_relative "lint/phlex_tags"
require_relative "lint/phlex_node"
require_relative "lint/configuration"
require_relative "lint/node_rule"
Dir[File.join(__dir__, "lint", "rules", "**", "*.rb")].each { |f| require f }
require_relative "lint/slim_runner"
require_relative "lint/erb_runner"
require_relative "lint/phlex_runner"
12 changes: 5 additions & 7 deletions lib/a11y/lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run
files = resolve_files(@argv)

if files.empty?
@stderr.puts("No .slim, .erb, or .rb files found")
@stderr.puts("No .erb or .rb files found")
return 0
end

Expand Down Expand Up @@ -61,7 +61,7 @@ def resolve_files(paths)

def expand_path(path)
if File.directory?(path)
Dir.glob(File.join(path, "**", "*.{slim,erb,rb}"))
Dir.glob(File.join(path, "**", "*.{erb,rb}"))
elsif File.file?(path)
[path]
else
Expand All @@ -72,22 +72,20 @@ def expand_path(path)

def lint_files(files)
configuration = load_configuration
slim_runner = SlimRunner.new(configuration:)
erb_runner = ErbRunner.new(configuration:)
phlex_runner = PhlexRunner.new(configuration:)

files.flat_map do |file|
source = File.read(file)
runner = runner_for(file, slim_runner, erb_runner, phlex_runner)
runner = runner_for(file, erb_runner, phlex_runner)
runner.run(source, filename: file)
end
end

def runner_for(file, slim_runner, erb_runner, phlex_runner)
def runner_for(file, erb_runner, phlex_runner)
case File.extname(file)
when ".erb" then erb_runner
when ".rb" then phlex_runner
else slim_runner
else erb_runner
end
end

Expand Down
10 changes: 0 additions & 10 deletions lib/a11y/lint/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,5 @@
module A11y
module Lint
class Error < StandardError; end

# Raised when slim is not installed.
class SlimLoadError < Error
def initialize
super(
"a11y-lint needs the `slim` gem to lint .slim files. " \
"Add `gem \"slim\"` to your Gemfile."
)
end
end
end
end
Loading
Loading