Skip to content

Commit

Permalink
Merge pull request #5457 from solidusio/elia/restore-eslint-checks
Browse files Browse the repository at this point in the history
Restore ERB and JS linting
  • Loading branch information
elia authored Oct 25, 2023
2 parents 6f724f3 + 99a687f commit c068fd5
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 54 deletions.
20 changes: 17 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ executors:
SOLIDUS_RAISE_DEPRECATIONS: true
CIRCLE_TEST_REPORTS: /tmp/test-results
CIRCLE_ARTIFACTS: /tmp/test-artifacts
BUNDLE_WITHOUT: "utils"
BUNDLE_WITHOUT: "lint,release"
docker:
- image: &image cimg/ruby:<< parameters.ruby >>-browsers

Expand Down Expand Up @@ -229,14 +229,28 @@ commands:
jobs:
lint_code:
docker:
- image: cimg/ruby:3.1
- image: cimg/ruby:3.2-node
environment:
BUNDLE_ONLY: "lint"
steps:
- checkout
- run: 'bundle install'
- run:
name: Check with rubocop
name: Check Ruby
command: |
bundle exec rubocop --parallel --format junit --out "$PWD/test-results/rubocop-results.xml" --format progress
- run:
name: Check ERB
command: |
# enable recursive globbing with "**"
shopt -s globstar
# we're only interested in errors
bundle exec erb-format **/*.html.erb > /dev/null
- run:
name: Check JavaScript
command: |
npx -y eslint "**/*.js"
- store_test_results:
path: test-results

Expand Down
15 changes: 13 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"extends": "airbnb-base",
"extends": "eslint:recommended",
"ignorePatterns": [
"**/spec",
"**/vendor",
"**/node_modules",
"sandbox",
"core/doc",
"tmp"
],
"parserOptions": {
"ecmaVersion": 2019
},
"env": {
"es6": false,
"es6": true,
"browser": true,
"jquery": true
},
Expand Down
6 changes: 6 additions & 0 deletions .format-erb-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sandbox/**
tmp/**
**/generators/**

# this file is using tail `if` checks which are not supported by erb-formatter
backend/app/views/spree/admin/shared/_product_tabs.html.erb
10 changes: 0 additions & 10 deletions .hound.yml

This file was deleted.

15 changes: 7 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ end
# and https://github.com/rails/sprockets-rails/issues/369
gem 'sprockets', '~> 3'

gem 'pry'
gem 'launchy', require: false

dbs = ENV['DB_ALL'] ? 'all' : ENV.fetch('DB', 'sqlite')
gem 'mysql2', '~> 0.5.0', require: false if dbs.match?(/all|mysql/)
gem 'pg', '~> 1.0', require: false if dbs.match?(/all|postgres/)
Expand All @@ -31,6 +34,8 @@ gem 'simplecov-cobertura', require: false
gem 'rails-controller-testing', require: false
gem 'puma', '< 6', require: false
gem 'i18n-tasks', '~> 0.9', require: false
gem 'rspec_junit_formatter', require: false
gem 'yard', require: false

# Ensure the requirement is also updated in core/lib/spree/testing_support/factory_bot.rb
gem 'factory_bot_rails', '>= 4.8', require: false
Expand All @@ -53,9 +58,8 @@ group :admin do
gem 'axe-core-capybara', '~> 4.7', require: false
end

group :utils do
gem 'pry'
gem 'launchy', require: false
group :lint do
gem 'erb-formatter', require: false
gem 'rubocop', '~> 1', require: false
gem 'rubocop-performance', '~> 1.4', require: false
gem 'rubocop-rails', '~> 2.9', require: false
Expand All @@ -66,10 +70,5 @@ group :release do
gem 'faraday-retry', '~> 2.0', require: false
end

gem 'rspec_junit_formatter', require: false, group: :ci

# Documentation
gem 'yard', require: false, group: :docs

custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
eval File.read(custom_gemfile), nil, custom_gemfile, 0 if File.exist?(custom_gemfile)
7 changes: 7 additions & 0 deletions admin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
content_tag(:span, "0", "data-#{stimulus_id}-target": "selectedRowsCount"),
" #{t('.rows_selected')}.",
])), colspan: @columns.count - 1) %>
</div>
</tr>
</thead>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion admin/app/components/solidus_admin/ui/table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class extends Controller {
}

selectAllRows(event) {
if (this.modeValue = event.target.checked) {
if (event.target.checked) {
this.modeValue = "batch"
} else if (this.searchFieldTarget.value !== '') {
this.modeValue = "search"
Expand Down
4 changes: 3 additions & 1 deletion admin/app/javascript/solidus_admin/controllers/components.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */

import "@hotwired/stimulus"

const registeredControllers = {}
Expand Down Expand Up @@ -32,4 +34,4 @@ function registerController(name, module, application) {
application.register(name, module.default)
registeredControllers[name] = true
}
};
}
6 changes: 1 addition & 5 deletions backend/app/views/spree/admin/images/_image_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
"spree/admin/shared/modal",
target: "modal-image-#{image.id}",
title: image.alt,
content: %{
<div class='align-center'>
#{image_tag(image.url(:large))}
</div>
}.html_safe
content: tag.div(image_tag(image.url(:large)), class: 'align-center')
) %>
</td>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</tr>
<% end %>
</table>
<p>
</td>
<td class="expander"></td>
</tr>
Expand Down
22 changes: 0 additions & 22 deletions package.json

This file was deleted.

0 comments on commit c068fd5

Please sign in to comment.