Project

a11y-lint

0.0
No release in over 3 years
A linter for checking accessibility issues in your code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 1.13
>= 4.0
 Project Readme

A11y::Lint

A Ruby gem for checking accessibility issues in your code.

Installation

Add the gem to your application's Gemfile:

gem "a11y-lint"

Then run:

bundle install

Or install it directly:

gem install a11y-lint

Usage

Command Line

Run the linter on specific files or directories:

a11y-lint app/views/
a11y-lint app/views/home.html.slim app/views/about.html.slim

With no arguments, it scans the current directory recursively for .slim and .erb files:

a11y-lint

Configuration

Create a .a11y-lint.yml file in your project root to enable or disable individual rules:

ImgMissingAlt:
  Enabled: false

ImageTagMissingAlt:
  Enabled: true

Rules not listed in the file are enabled by default. The linter searches for .a11y-lint.yml starting from the target directory and walking up to the filesystem root.

To specify a config file explicitly:

a11y-lint --config path/to/.a11y-lint.yml app/views/

Ruby API

require "a11y/lint"

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

offenses.each do |offense|
  puts "#{offense.filename}:#{offense.line} [#{offense.rule}] #{offense.message}"
end

Requirements

  • Ruby >= 3.1.0

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To run all checks (tests + linting):

bundle exec rake

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Guided-Rails/a11y-lint. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the A11y::Lint project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.