Skip to content

Commit 413c4c9

Browse files
committed
Move linting commands to rake tasks
Only check files tracked by git and not generated and temporary files.
1 parent e1361ee commit 413c4c9

File tree

7 files changed

+26
-27
lines changed

7 files changed

+26
-27
lines changed

.circleci/config.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,13 @@ jobs:
246246
- run: 'bundle install'
247247
- run:
248248
name: Check Ruby
249-
command: |
250-
bundle exec rubocop --parallel --format junit --out "$PWD/test-results/rubocop-results.xml" --format progress
249+
command: "bin/rake lint:rb"
251250
- run:
252251
name: Check ERB
253-
command: |
254-
# enable recursive globbing with "**"
255-
shopt -s globstar
256-
257-
# we're only interested in errors
258-
bundle exec erb-format **/*.html.erb > /dev/null
252+
command: "bin/rake lint:erb"
259253
- run:
260254
name: Check JavaScript
261-
command: |
262-
npx -y eslint "**/*.js"
255+
command: "bin/rake lint:js"
263256
- store_test_results:
264257
path: test-results
265258

.eslintrc.json

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"extends": "eslint:recommended",
3-
"ignorePatterns": [
4-
"*tailwind.config.js",
5-
"**/spec",
6-
"**/vendor",
7-
"**/node_modules",
8-
"sandbox",
9-
"coverage",
10-
"core/doc",
11-
"tmp"
12-
],
133
"parserOptions": {
144
"ecmaVersion": 2019
155
},

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ yarn.lock
3232
package-lock.json
3333
.env
3434
/admin/app/assets/builds
35+
/test-results

.rubocop.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ require:
88

99
AllCops:
1010
Exclude:
11-
- 'vendor/**/*'
12-
- '**/vendor/**/*'
13-
- '*/spec/dummy/**/*'
14-
- 'sandbox/**/*'
15-
- '**/templates/**/*'
16-
- 'tmp/**/*'
11+
- '**/{tmp,vendor,spec/dummy,sandbox,templates,pkg}/**/*'
1712
TargetRubyVersion: 3.0
1813
NewCops: disable
1914
SuggestExtensions: false

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ group :admin do
6161
end
6262

6363
group :lint do
64-
gem 'erb-formatter', require: false
64+
gem 'erb-formatter', '~> 0.7', require: false
6565
gem 'rubocop', '~> 1', require: false
6666
gem 'rubocop-performance', '~> 1.4', require: false
6767
gem 'rubocop-rails', '~> 2.9', require: false

Rakefile

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
import 'tasks/cleaning.rake'
44
import 'tasks/releasing.rake'
55
import 'tasks/testing.rake'
6+
import 'tasks/linting.rake'

tasks/linting.rake

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
namespace :lint do
4+
task :rb do
5+
ci_options = "-f junit -o '#{__dir__}/../test-results/rubocop-results.xml' " if ENV['CI']
6+
7+
sh %{bundle exec rubocop -P -f q #{ci_options}$(git ls-files -co --exclude-standard | grep -E "\\.rb$" | grep -v "/templates/")}
8+
end
9+
10+
task :erb do
11+
sh 'bundle exec erb-format $(git ls-files -co --exclude-standard | grep -E "\.html.erb$") > /dev/null'
12+
end
13+
14+
task :js do
15+
sh 'npx -y eslint $(git ls-files -co --exclude-standard | grep -E "\.js$" | grep -vE "/(vendor|config|spec)/")'
16+
end
17+
end
18+
19+
task lint: %w[lint:rb lint:erb lint:js]

0 commit comments

Comments
 (0)