Skip to content

Commit

Permalink
Move linting commands to rake tasks
Browse files Browse the repository at this point in the history
Only check files tracked by git and not generated and temporary files.

(cherry picked from commit 413c4c9)

# Conflicts:
#	.circleci/config.yml
  • Loading branch information
elia committed Feb 19, 2025
1 parent 9bab0e4 commit 7815e54
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,26 @@ commands:
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
jobs:
lint_code:
docker:
- image: cimg/ruby:3.2-node
environment:
BUNDLE_ONLY: "lint"
steps:
- checkout
- run: 'bundle install'
- run:
name: Check Ruby
command: "bin/rake lint:rb"
- run:
name: Check ERB
command: "bin/rake lint:erb"
- run:
name: Check JavaScript
command: "bin/rake lint:js"
- store_test_results:
path: test-results

solidus_installer:
executor:
name: sqlite
Expand Down
10 changes: 0 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"extends": "eslint:recommended",
"ignorePatterns": [
"*tailwind.config.js",
"**/spec",
"**/vendor",
"**/node_modules",
"sandbox",
"coverage",
"core/doc",
"tmp"
],
"parserOptions": {
"ecmaVersion": 2019
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ yarn.lock
package-lock.json
.env
/admin/app/assets/builds
/test-results
7 changes: 1 addition & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ require:

AllCops:
Exclude:
- 'vendor/**/*'
- '**/vendor/**/*'
- '*/spec/dummy/**/*'
- 'sandbox/**/*'
- '**/templates/**/*'
- 'tmp/**/*'
- '**/{tmp,vendor,spec/dummy,sandbox,templates,pkg}/**/*'
TargetRubyVersion: 3.0
NewCops: disable
SuggestExtensions: false
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ group :admin do
end

group :lint do
gem 'erb-formatter', require: false
gem 'erb-formatter', '~> 0.7', require: false
gem 'rubocop', '~> 1', require: false
gem 'rubocop-performance', '~> 1.4', require: false
gem 'rubocop-rails', '~> 2.9', require: false
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
import 'tasks/cleaning.rake'
import 'tasks/releasing.rake'
import 'tasks/testing.rake'
import 'tasks/linting.rake'
19 changes: 19 additions & 0 deletions tasks/linting.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

namespace :lint do
task :rb do
ci_options = "-f junit -o '#{__dir__}/../test-results/rubocop-results.xml' " if ENV['CI']

sh %{bundle exec rubocop -P -f q #{ci_options}$(git ls-files -co --exclude-standard | grep -E "\\.rb$" | grep -v "/templates/")}
end

task :erb do
sh 'bundle exec erb-format $(git ls-files -co --exclude-standard | grep -E "\.html.erb$") > /dev/null'
end

task :js do
sh 'npx -y eslint $(git ls-files -co --exclude-standard | grep -E "\.js$" | grep -vE "/(vendor|config|spec)/")'
end
end

task lint: %w[lint:rb lint:erb lint:js]

0 comments on commit 7815e54

Please sign in to comment.