Add GitHub CI workflow for slim lint

This commit is contained in:
Sebastian Serth
2024-04-13 23:42:31 +02:00
committed by Dominic Sauer
parent 9a9efd5caa
commit 681e8ec444
4 changed files with 67 additions and 0 deletions

View File

@ -108,3 +108,33 @@ jobs:
skip_install: true skip_install: true
use_bundler: true use_bundler: true
fail_on_error: true fail_on_error: true
slim-lint:
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Allow write access to checks to allow the action to annotate code in the PR.
checks: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
- name: Run slim-lint
run: bundle exec slim-lint app/views --reporter checkstyle > checkstyle-result.xml
- name: Upload slim-lint results as GitHub annotations
uses: lcollins/checkstyle-github-action@v2.0.0
if: ${{ success() || failure() }}
with:
name: Slim-Lint Report
title: Analyze Slim templates for linting issues
path: checkstyle-result.xml

32
.slim-lint.yml Normal file
View File

@ -0,0 +1,32 @@
linters:
# Disabled a few linters that are not relevant to our use case
EmptyLines:
enabled: false
ConsecutiveControlStatements:
enabled: false
LineLength:
enabled: false
# Enable additional linters
EmbeddedEngines:
enabled: true
forbidden_engines:
# JavaScript is not allowed due to our Content Security Policy (CSP)
- javascript
InstanceVariables:
enabled: false # TODO: Enable
include:
# Include only Rails partial templates by default
- app/views/**/_*.html.slim
StrictLocalsMissing:
enabled: false # TODO: Enable
include:
# Include only Rails partial templates by default
- app/views/**/_*.html.slim
Zwsp:
enabled: true

View File

@ -80,6 +80,7 @@ group :development, :staging do
gem 'rubocop-performance' gem 'rubocop-performance'
gem 'rubocop-rails', require: false gem 'rubocop-rails', require: false
gem 'rubocop-rspec' gem 'rubocop-rspec'
gem 'slim_lint', require: false
end end
group :test do group :test do

View File

@ -499,6 +499,9 @@ GEM
actionpack (>= 3.1) actionpack (>= 3.1)
railties (>= 3.1) railties (>= 3.1)
slim (>= 3.0, < 6.0, != 5.0.0) slim (>= 3.0, < 6.0, != 5.0.0)
slim_lint (0.27.0)
rubocop (>= 1.0, < 2.0)
slim (>= 3.0, < 6.0)
snaky_hash (2.0.1) snaky_hash (2.0.1)
hashie hashie
version_gem (~> 1.1, >= 1.1.1) version_gem (~> 1.1, >= 1.1.1)
@ -641,6 +644,7 @@ DEPENDENCIES
shoulda-matchers shoulda-matchers
simplecov simplecov
slim-rails slim-rails
slim_lint
sorcery sorcery
sprockets-rails sprockets-rails
stackprof stackprof