8000 Add sass-rails linter to ensure webpacker compatibility · stephancom/activeadmin@338bd33 · GitHub
[go: up one dir, main page]

Skip to content

Commit 338bd33

Browse files
committed
Add sass-rails linter to ensure webpacker compatibility
1 parent 1f494ec commit 338bd33

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ you use the correct Gemfile, for example:
6464
export BUNDLE_GEMFILE=gemfiles/rails_51.gemfile
6565
```
6666

67+
**Warning** SCSS assets are aimed to be used indifferently with Sprockets **and** webpacker.
68+
As such, make sure not to use any sass-rails directives such as `asset-url` or `image-url`.
69+
6770
### Did you find a bug?
6871

6972
* **Ensure the bug was not already reported** by [searching all issues].

tasks/lint.rake

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,25 @@ class FixmeLinter
8888
end
8989
end
9090

91+
#
92+
# Checks sass-rails directives
93+
#
94+
class SassRailsLinter
95+
include LinterMixin
96+
97+
def applicable_files
98+
Dir["app/assets/stylesheets/**/*.scss"]
99+
end
100+
101+
def clean?(file)
102+
relative_path = Pathname.new(__FILE__).relative_path_from(Pathname.new(File.dirname(__dir__))).to_s
103+
104+
file == relative_path || File.read(file, encoding: Encoding::UTF_8) !~ /(asset-url|asset-path|image-url|image-path|asset-data-url)/
105+
end
106+
end
107+
91108
desc "Lints ActiveAdmin code base"
92-
task lint: ["lint:rubocop", "lint:mdl", "lint:gherkin_lint", "lint:trailing_blank_lines", "lint:missing_final_new_line", "lint:trailing_whitespace", "lint:fixme", "lint:rspec"]
109+
task lint: ["lint:rubocop", "lint:mdl", "lint:gherkin_lint", "lint:trailing_blank_lines", "lint:missing_final_new_line", "lint:trailing_whitespace", "lint:fixme", "lint:sass_rails", "lint:rspec"]
93110

94111
namespace :lint do
95112
require "rubocop/rake_task"
@@ -138,6 +155,13 @@ namespace :lint do
138155
FixmeLinter.new.run
139156
end
140157

158+
desc "Check for sass-rails directives to ensure webpacker compatibility"
159+
task :sass_rails do
160+
puts ""
161+
162+
SassRailsLinter.new.run
163+
end
164+
141165
desc "RSpec specs for linting project files"
142166
task :rspec do
143167
puts "Linting project files..."

0 commit comments

Comments
 (0)
0