Add GitHub CI workflow for slim lint
This commit is contained in:

committed by
Dominic Sauer

parent
9a9efd5caa
commit
681e8ec444
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@ -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
32
.slim-lint.yml
Normal 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
|
1
Gemfile
1
Gemfile
@ -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
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user