From ebcd18795591784ec6b83a9bd23116f8059ef880 Mon Sep 17 00:00:00 2001 From: "primer[bot]" <119360173+primer[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 02:00:18 +0000 Subject: [PATCH 1/2] Release Tracking (#3206) Co-authored-by: github-actions[bot] --- .changeset/odd-dots-laugh.md | 5 ----- .changeset/quiet-papayas-sparkle.md | 5 ----- .changeset/seven-experts-return.md | 5 ----- .changeset/two-badgers-suffer.md | 5 ----- .changeset/weak-birds-unite.md | 5 ----- .changeset/wild-shirts-heal.md | 5 ----- CHANGELOG.md | 18 ++++++++++++++++++ Gemfile.lock | 2 +- demo/Gemfile.lock | 2 +- lib/primer/view_components/version.rb | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 12 files changed, 25 insertions(+), 37 deletions(-) delete mode 100644 .changeset/odd-dots-laugh.md delete mode 100644 .changeset/quiet-papayas-sparkle.md delete mode 100644 .changeset/seven-experts-return.md delete mode 100644 .changeset/two-badgers-suffer.md delete mode 100644 .changeset/weak-birds-unite.md delete mode 100644 .changeset/wild-shirts-heal.md diff --git a/.changeset/odd-dots-laugh.md b/.changeset/odd-dots-laugh.md deleted file mode 100644 index 8667f57324..0000000000 --- a/.changeset/odd-dots-laugh.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/view-components': minor ---- - -Support leading and trailing icons for Links diff --git a/.changeset/quiet-papayas-sparkle.md b/.changeset/quiet-papayas-sparkle.md deleted file mode 100644 index 46364f467c..0000000000 --- a/.changeset/quiet-papayas-sparkle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/view-components": patch ---- - -Fix issue causing AutoComplete elements to overflow their container diff --git a/.changeset/seven-experts-return.md b/.changeset/seven-experts-return.md deleted file mode 100644 index 27c4dc91c7..0000000000 --- a/.changeset/seven-experts-return.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/view-components': patch ---- - -Ensure `full_width:` option is respected by the auto_complete input diff --git a/.changeset/two-badgers-suffer.md b/.changeset/two-badgers-suffer.md deleted file mode 100644 index 6e00104a91..0000000000 --- a/.changeset/two-badgers-suffer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/view-components': patch ---- - -Prevent hidden inputs from taking up space on the page diff --git a/.changeset/weak-birds-unite.md b/.changeset/weak-birds-unite.md deleted file mode 100644 index 34740cb2de..0000000000 --- a/.changeset/weak-birds-unite.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/view-components': patch ---- - -Remove redundant code for better performance. diff --git a/.changeset/wild-shirts-heal.md b/.changeset/wild-shirts-heal.md deleted file mode 100644 index 37f3218fca..0000000000 --- a/.changeset/wild-shirts-heal.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/view-components": minor ---- - -Removing the validate classname check that forces system arguments instead of utility classes diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d796414f..943e383f77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # CHANGELOG +## 0.36.0 + +### Minor Changes + +- [#3041](https://github.com/primer/view_components/pull/3041) [`14dd0d3`](https://github.com/primer/view_components/commit/14dd0d3c4cbf2e6ce46f4d80ed94ccc06374299e) Thanks [@HDinger](https://github.com/HDinger)! - Support leading and trailing icons for Links + +- [#3219](https://github.com/primer/view_components/pull/3219) [`633bd05`](https://github.com/primer/view_components/commit/633bd05ea6675e2b54b1cd025d86462a810e6e94) Thanks [@camertron](https://github.com/camertron)! - Removing the validate classname check that forces system arguments instead of utility classes + +### Patch Changes + +- [#3217](https://github.com/primer/view_components/pull/3217) [`0bbb076`](https://github.com/primer/view_components/commit/0bbb076a978f1029d3f1724bda821ee136be408b) Thanks [@camertron](https://github.com/camertron)! - Fix issue causing AutoComplete elements to overflow their container + +- [#3205](https://github.com/primer/view_components/pull/3205) [`79ca4f9`](https://github.com/primer/view_components/commit/79ca4f91a67ac79623584a89d4afe5931ae0bbd6) Thanks [@camertron](https://github.com/camertron)! - Ensure `full_width:` option is respected by the auto_complete input + +- [#3202](https://github.com/primer/view_components/pull/3202) [`a574b0e`](https://github.com/primer/view_components/commit/a574b0e2becdc057c23aa6e26230851f90976605) Thanks [@camertron](https://github.com/camertron)! - Prevent hidden inputs from taking up space on the page + +- [#3216](https://github.com/primer/view_components/pull/3216) [`23dd4fa`](https://github.com/primer/view_components/commit/23dd4fa4308c91abef13e8e23876ab12ea79db2e) Thanks [@keithamus](https://github.com/keithamus)! - Remove redundant code for better performance. + ## 0.35.2 ### Patch Changes diff --git a/Gemfile.lock b/Gemfile.lock index a76455775a..cd5fbfc160 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - primer_view_components (0.35.2) + primer_view_components (0.36.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) octicons (>= 18.0.0) diff --git a/demo/Gemfile.lock b/demo/Gemfile.lock index 84165e7985..798388160f 100644 --- a/demo/Gemfile.lock +++ b/demo/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - primer_view_components (0.35.2) + primer_view_components (0.36.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) octicons (>= 18.0.0) diff --git a/lib/primer/view_components/version.rb b/lib/primer/view_components/version.rb index f32780fe65..2e9b07cb42 100644 --- a/lib/primer/view_components/version.rb +++ b/lib/primer/view_components/version.rb @@ -5,8 +5,8 @@ module Primer module ViewComponents module VERSION MAJOR = 0 - MINOR = 35 - PATCH = 2 + MINOR = 36 + PATCH = 0 STRING = [MAJOR, MINOR, PATCH].join(".") end diff --git a/package-lock.json b/package-lock.json index 2274ab472b..be2be3fe8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@primer/view-components", - "version": "0.35.2", + "version": "0.36.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@primer/view-components", - "version": "0.35.2", + "version": "0.36.0", "license": "MIT", "dependencies": { "@github/auto-check-element": "^5.2.0", diff --git a/package.json b/package.json index cd1fc659a4..c1c37d0eb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@primer/view-components", - "version": "0.35.2", + "version": "0.36.0", "description": "ViewComponents for the Primer Design System", "main": "app/assets/javascripts/primer_view_components.js", "module": "app/components/primer/primer.js", From 688a4a263deb4be70763b9ba39cae854896b44ce Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Thu, 5 Dec 2024 10:37:13 -0800 Subject: [PATCH 2/2] Remove SystemArgumentInsteadOfClass linter and fix bug with whitespace in rendered class (#3220) --- .changeset/wet-houses-own.md | 5 ++ .rubocop.yml | 3 - docs/contributors/linting.md | 2 +- lib/primer/classify.rb | 2 +- lib/rubocop/config/default.yml | 3 - .../system_argument_instead_of_class.rb | 57 ------------------ test/components/base_component_test.rb | 6 ++ .../system_arguments_instead_of_class_test.rb | 60 ------------------- 8 files changed, 13 insertions(+), 125 deletions(-) create mode 100644 .changeset/wet-houses-own.md delete mode 100644 lib/rubocop/cop/primer/system_argument_instead_of_class.rb delete mode 100644 test/lib/rubocop/system_arguments_instead_of_class_test.rb diff --git a/.changeset/wet-houses-own.md b/.changeset/wet-houses-own.md new file mode 100644 index 0000000000..512f5291f5 --- /dev/null +++ b/.changeset/wet-houses-own.md @@ -0,0 +1,5 @@ +--- +"@primer/view-components": patch +--- + +Remove SystemArgumentInsteadOfClass linter and fix bug with whitespace in rendered class diff --git a/.rubocop.yml b/.rubocop.yml index c3371ed86d..4900ebfdb8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,9 +57,6 @@ Primer/NoTagMemoize: Include: - "app/components/**/*" -Primer/SystemArgumentInsteadOfClass: - Enabled: true - Lint/MissingSuper: Enabled: false diff --git a/docs/contributors/linting.md b/docs/contributors/linting.md index 7e3742a6c7..7cd3de47a1 100644 --- a/docs/contributors/linting.md +++ b/docs/contributors/linting.md @@ -18,7 +18,7 @@ inherit_gem: You can also modify that configuration enabling/disabling the cops you want: ```yml -Primer/SystemArgumentInsteadOfClass: +Primer/NoTagMemoize: Enabled: false ``` diff --git a/lib/primer/classify.rb b/lib/primer/classify.rb index 7c00476f19..acc8e1a920 100644 --- a/lib/primer/classify.rb +++ b/lib/primer/classify.rb @@ -49,7 +49,7 @@ def call(args = {}) case key when :classes # insert :classes first to avoid huge doc diffs - result.unshift(val) + result.unshift(val) unless val.blank? next when :style style = val diff --git a/lib/rubocop/config/default.yml b/lib/rubocop/config/default.yml index 65fee4cdbd..e51130db04 100644 --- a/lib/rubocop/config/default.yml +++ b/lib/rubocop/config/default.yml @@ -1,9 +1,6 @@ require: - rubocop/cop/primer -Primer/SystemArgumentInsteadOfClass: - Enabled: true - Primer/NoTagMemoize: Enabled: false diff --git a/lib/rubocop/cop/primer/system_argument_instead_of_class.rb b/lib/rubocop/cop/primer/system_argument_instead_of_class.rb deleted file mode 100644 index c2ebdc937d..0000000000 --- a/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require "rubocop" -require "primer/classify/utilities" - -# :nocov: -module RuboCop - module Cop - module Primer - # This cop ensures that components use System Arguments instead of CSS classes. - # - # bad - # Component.new(classes: "mr-1") - # - # good - # Component.new(mr: 1) - class SystemArgumentInsteadOfClass < BaseCop - INVALID_MESSAGE = <<~STR - Avoid using CSS classes when you can use System Arguments: https://primer.style/view-components/system-arguments. - STR - - def on_send(node) - return unless valid_node?(node) - return unless node.arguments? - - # we are looking for hash arguments and they are always last - kwargs = node.arguments.last - - return unless kwargs.type == :hash - - # find classes pair - classes_arg = kwargs.pairs.find { |kwarg| kwarg.key.value == :classes } - - return if classes_arg.nil? - return unless classes_arg.value.type == :str - - # get actual classes - classes = classes_arg.value.value - - system_arguments = ::Primer::Classify::Utilities.classes_to_hash(classes) - - # no classes are fixable - return if system_arguments[:classes] == classes - - add_offense(classes_arg, message: INVALID_MESSAGE) - end - - def autocorrect(node) - lambda do |corrector| - args = ::Primer::Classify::Utilities.classes_to_args(node.value.value) - corrector.replace(node.loc.expression, args) - end - end - end - end - end -end diff --git a/test/components/base_component_test.rb b/test/components/base_component_test.rb index b87efd44d2..b581cdd8fa 100644 --- a/test/components/base_component_test.rb +++ b/test/components/base_component_test.rb @@ -73,6 +73,12 @@ def test_does_not_render_class_attribute_if_none_is_set refute_selector("div[class='']") end + def test_renders_system_argument_class_with_no_whitespace + render_inline(Primer::BaseComponent.new(tag: :div, ml: 3)) + + assert_selector("div[class='ml-3']") + end + def test_does_not_render_primer_layout_classes_as_attributes render_inline(Primer::BaseComponent.new(tag: :div, my: 4)) diff --git a/test/lib/rubocop/system_arguments_instead_of_class_test.rb b/test/lib/rubocop/system_arguments_instead_of_class_test.rb deleted file mode 100644 index b0a56be2ee..0000000000 --- a/test/lib/rubocop/system_arguments_instead_of_class_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -require "lib/cop_test_case" - -class RubocopSystemArgumentInsteadOfClassTest < CopTestCase - def cop_class - RuboCop::Cop::Primer::SystemArgumentInsteadOfClass - end - - def test_non_primer_component - investigate(cop, <<-RUBY) - Component.new(classes: "mr-1") - RUBY - - assert_empty cop.offenses - end - - def test_primer_component - investigate(cop, <<-RUBY) - Primer::BaseComponent.new(classes: "mr-1") - RUBY - - assert_equal 1, cop.offenses.count - assert_equal "Primer/SystemArgumentInsteadOfClass: Avoid using CSS classes when you can use System Arguments: https://primer.style/view-components/system-arguments.\n", cop.offenses.first.message - end - - def test_non_primer_view_helper - investigate(cop, <<-RUBY) - octicon(classes: "mr-1") - RUBY - - assert_empty cop.offenses - end - - def test_primer_view_helper - investigate(cop, <<-RUBY) - primer_octicon(classes: "mr-1") - RUBY - - assert_equal 1, cop.offenses.count - assert_equal "Primer/SystemArgumentInsteadOfClass: Avoid using CSS classes when you can use System Arguments: https://primer.style/view-components/system-arguments.\n", cop.offenses.first.message - end - - def test_custom_class - investigate(cop, <<-RUBY) - Primer::BaseComponent.new(classes: "mr-1 custom") - RUBY - - assert_equal 1, cop.offenses.count - assert_equal "Primer/SystemArgumentInsteadOfClass: Avoid using CSS classes when you can use System Arguments: https://primer.style/view-components/system-arguments.\n", cop.offenses.first.message - end - - def test_no_classes - investigate(cop, <<-RUBY) - Primer::BaseComponent.new - RUBY - - assert_empty cop.offenses - end -end