From 81e0e6871de527b57da165659e23335653dfa5f6 Mon Sep 17 00:00:00 2001 From: Steve Polito Date: Mon, 11 Dec 2023 12:00:40 -0500 Subject: [PATCH] Fix stylelint violations (#1150) In #1148 we introduce `stylelint`. However, the empty style sheets introduced in #1145 are empty file violations. By adding comments, we avoid that error. Note that we need to add these comments because there's no way to automatically fix those violations with something like `prettier`. --- lib/generators/suspenders/styles_generator.rb | 5 +++++ test/generators/suspenders/styles_generator_test.rb | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/generators/suspenders/styles_generator.rb b/lib/generators/suspenders/styles_generator.rb index 610dcc32b..a83b686ff 100644 --- a/lib/generators/suspenders/styles_generator.rb +++ b/lib/generators/suspenders/styles_generator.rb @@ -25,8 +25,13 @@ def build_directory_structure return if is_tailwind? create_file "app/assets/stylesheets/base.css" + append_to_file "app/assets/stylesheets/base.css", "/* Base Styles */" + create_file "app/assets/stylesheets/components.css" + append_to_file "app/assets/stylesheets/components.css", "/* Component Styles */" + create_file "app/assets/stylesheets/utilities.css" + append_to_file "app/assets/stylesheets/utilities.css", "/* Utility Styles */" end # Modify if https://github.com/rails/cssbundling-rails/pull/139 is merged diff --git a/test/generators/suspenders/styles_generator_test.rb b/test/generators/suspenders/styles_generator_test.rb index f9890be84..1c5f87234 100644 --- a/test/generators/suspenders/styles_generator_test.rb +++ b/test/generators/suspenders/styles_generator_test.rb @@ -186,9 +186,15 @@ class StylesGenerator::PostCssTest < Rails::Generators::TestCase test "creates stylesheets" do run_generator - assert_file app_root("app/assets/stylesheets/base.css") - assert_file app_root("app/assets/stylesheets/components.css") - assert_file app_root("app/assets/stylesheets/utilities.css") + assert_file app_root("app/assets/stylesheets/base.css") do |file| + assert_equal "/* Base Styles */", file + end + assert_file app_root("app/assets/stylesheets/components.css") do |file| + assert_equal "/* Component Styles */", file + end + assert_file app_root("app/assets/stylesheets/utilities.css") do |file| + assert_equal "/* Utility Styles */", file + end end private