From 13829f5b04e68708df15c581348ff7b3903c4286 Mon Sep 17 00:00:00 2001 From: Lukas Eipert <leipert@gitlab.com> Date: Mon, 26 Aug 2024 15:03:25 +0200 Subject: [PATCH] Remove legacy util danger check Since https://gitlab.com/gitlab-org/gitlab/-/merge_requests/163878 we have a check against using legacy utilities. This makes this danger message kind of obsolete. The check against interpolated utility classes could be a rubocop / eslint rule instead. --- danger/tailwindcss/Dangerfile | 62 +---------------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/danger/tailwindcss/Dangerfile b/danger/tailwindcss/Dangerfile index bd78a3423b1d..6b97afb2140c 100644 --- a/danger/tailwindcss/Dangerfile +++ b/danger/tailwindcss/Dangerfile @@ -29,66 +29,6 @@ module Danger MARKDOWN end - def report_legacy_utils_usage - `yarn tailwindcss:build` - - legacy_utils = File - .read("./config/helpers/tailwind/css_in_js.js") - .scan(/'(\.[^\']*)'/).flatten.map do |legacy_util| - legacy_util.gsub('.', 'gl-').gsub('\\\\!', '!') - end - - files_with_legacy_utils = @helper.all_changed_files.flat_map do |file| - next [] if file.end_with?('tailwind_equivalents.json') - - diff = @git.diff_for_file(file) - - # When a file is just moved around it appears in the changed files list - # but the diff is empty so we are skipping it. - next [] if diff.nil? - - used_legacy_utils = diff.patch.each_line.flat_map do |line| - next [] unless line.start_with?('+') - - legacy_utils.select do |legacy_util| - legacy_util_regex = if legacy_util.end_with?('!') - /#{legacy_util.gsub('\\\\!', '!')}/ - else - /#{legacy_util}(?!!)/ - end - - line.match?(legacy_util_regex) - end - end - - next [] if used_legacy_utils.empty? - - [[file, used_legacy_utils]] - end - - return "" if files_with_legacy_utils.empty? - - <<~MARKDOWN - ### Legacy CSS utility classes - - The following files contain legacy CSS utility classes: - #{format_files_with_legacy_utils_list(files_with_legacy_utils)} - - We are in the process of migrating our CSS utility classes to [Tailwind CSS](https://tailwindcss.com/). - The above CSS utility classes do not comply with Tailwind CSS naming conventions. - Please use the Tailwind CSS equivalent if it is available. - For more information see [Tailwind CSS developer documentation](https://docs.gitlab.com/ee/development/fe_guide/style/scss.html#tailwind-css). - - If the Tailwind CSS equivalent is not available, it is okay to use the legacy CSS utility class for now. - The Tailwind CSS equivalent will be made available when the corresponding migration issue - in [&13521](https://gitlab.com/groups/gitlab-org/-/epics/13521) is completed. - - If a legacy CSS utility class is listed above but you did not change it in this MR it is okay to leave for now. - If it is a small or simple MR, feel free to leave the code better than you found it and migrate those - legacy CSS utility classes to Tailwind CSS. - MARKDOWN - end - private def frontend_tailwindy_files(files) @@ -145,7 +85,7 @@ module Danger end danger_tailwind = Danger::Tailwind.new(helper, git) -report = danger_tailwind.report_interpolated_utils + danger_tailwind.report_legacy_utils_usage +report = danger_tailwind.report_interpolated_utils unless report.empty? markdown <<~MSG -- GitLab