primer_view_components 0.0.79 → 0.0.80

Sign up to get free protection for your applications and to get access to all the features.
@@ -65,12 +65,10 @@ module Primer
65
65
  renders_one :tooltip, lambda { |**system_arguments|
66
66
  raise ArgumentError, "Buttons with a tooltip must have a unique `id` set on the `Button`." if @id.blank? && !Rails.env.production?
67
67
 
68
- @system_arguments = system_arguments
69
-
70
- @system_arguments[:for_id] = @id
71
- @system_arguments[:type] ||= :description
68
+ system_arguments[:for_id] = @id
69
+ system_arguments[:type] ||= :description
72
70
 
73
- Primer::Alpha::Tooltip.new(**@system_arguments)
71
+ Primer::Alpha::Tooltip.new(**system_arguments)
74
72
  }
75
73
 
76
74
  # @example Schemes
@@ -24,12 +24,10 @@ module Primer
24
24
  renders_one :tooltip, lambda { |**system_arguments|
25
25
  raise ArgumentError, "Links with a tooltip must have a unique `id` set on the `LinkComponent`." if @id.blank? && !Rails.env.production?
26
26
 
27
- @system_arguments = system_arguments
28
-
29
- @system_arguments[:for_id] = @id
30
- @system_arguments[:type] ||= :description
27
+ system_arguments[:for_id] = @id
28
+ system_arguments[:type] ||= :description
31
29
 
32
- Primer::Alpha::Tooltip.new(**@system_arguments)
30
+ Primer::Alpha::Tooltip.new(**system_arguments)
33
31
  }
34
32
 
35
33
  # @example Default
@@ -1 +1 @@
1
- gimport '@github/tab-container-element';
1
+ import '@github/tab-container-element';
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require_relative "helpers/rubocop_helpers"
5
+
6
+ module ERBLint
7
+ module Linters
8
+ # Finds usages of ActionList CSS classes.
9
+ class DisallowActionList < Linter
10
+ include ERBLint::LinterRegistry
11
+ include TagTreeHelpers
12
+
13
+ class ConfigSchema < LinterConfig
14
+ property :ignore_files, accepts: array_of?(String), default: -> { [] }
15
+ end
16
+ self.config_schema = ConfigSchema
17
+
18
+ def run(processed_source)
19
+ return if ignored?(processed_source.filename)
20
+
21
+ class_regex = /ActionList[\w-]*/
22
+ tags, * = build_tag_tree(processed_source)
23
+
24
+ tags.each do |tag|
25
+ next if tag.closing?
26
+
27
+ classes =
28
+ if (class_attrib = tag.attributes["class"])
29
+ loc = class_attrib.value_node.loc
30
+ loc.source_buffer.source[loc.begin_pos...loc.end_pos]
31
+ else
32
+ ""
33
+ end
34
+
35
+ indices = [].tap do |results|
36
+ classes.scan(class_regex) do
37
+ results << Regexp.last_match.offset(0)
38
+ end
39
+ end
40
+
41
+ next if indices.empty?
42
+
43
+ indices.each do |(start_idx, end_idx)|
44
+ new_loc = class_attrib.value_node.loc.with(
45
+ begin_pos: class_attrib.value_node.loc.begin_pos + start_idx,
46
+ end_pos: class_attrib.value_node.loc.begin_pos + end_idx
47
+ )
48
+
49
+ add_offense(
50
+ new_loc,
51
+ "ActionList classes are only designed to be used by Primer View Components and " \
52
+ "should be considered private. Please reach out in the #primer-rails Slack channel."
53
+ )
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def ignored?(filename)
61
+ filename = Pathname(filename)
62
+
63
+ begin
64
+ filename = filename.relative_path_from(Pathname(Dir.getwd))
65
+ rescue ArgumentError
66
+ # raised if the filename does not have Dir.getwd as a prefix
67
+ end
68
+
69
+ @config.ignore_files.any? { |pattern| filename.fnmatch?(pattern) }
70
+ end
71
+ end
72
+ end
73
+ end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 79
8
+ PATCH = 80
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.79
4
+ version: 0.0.80
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -536,6 +536,7 @@ files:
536
536
  - lib/primer/view_components/linters/button_component_migration_counter.rb
537
537
  - lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb
538
538
  - lib/primer/view_components/linters/close_button_component_migration_counter.rb
539
+ - lib/primer/view_components/linters/disallow_action_list.rb
539
540
  - lib/primer/view_components/linters/flash_migration_counter.rb
540
541
  - lib/primer/view_components/linters/helpers/rubocop_helpers.rb
541
542
  - lib/primer/view_components/linters/label_component_migration_counter.rb
@@ -594,7 +595,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
594
595
  - !ruby/object:Gem::Version
595
596
  version: '0'
596
597
  requirements: []
597
- rubygems_version: 3.2.32
598
+ rubygems_version: 3.2.22
598
599
  signing_key:
599
600
  specification_version: 4
600
601
  summary: ViewComponents for the Primer Design System