rubocop-on-rbs 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb5ae6ae2ad5e254a1a024cd1ec1a929ffdee7b1177c7129242f102b1d8584f5
4
- data.tar.gz: 5746b9cf392adf155904757a34a9cfb2a98e019a235a7cd59788242bfd2242e8
3
+ metadata.gz: 442a7571452e14e42efbd73d0f0313f983f631a983fd5c861f5c54d333538fd6
4
+ data.tar.gz: 1803e6bdf3eb67a025a3d1286966bef98eb695cf16e7edf83a717d748f995eca
5
5
  SHA512:
6
- metadata.gz: b9ed39b9d6efafc3c3b04e821bf9749c615898250ad2d03efde2a574db350fefe5e3580017632ae23121b952a9293a5e5fe2bd4575e0d87e7e3673c8a2aad9db
7
- data.tar.gz: 5f113ba32e6e7a1e0fb5510ad3958000b28107920d85e2e94acc79feb96dd8d42172b6565c8902136871ba129f91f20dc461544ccaa542d23fb5f10a064b9090
6
+ metadata.gz: '037319b5e7725a91470530891915c93227eddf4899ad8ad1a332f23bf23c3abedfc47f34618fbaa5c9672ad37d3e0badd32c7dec13f6319622dd653726f0d76d'
7
+ data.tar.gz: f2009c6f0af208cb65f96d410461c435f5a5a919253f191af1ae58f96ab54137e95c1e56d433aaac474126cbe7740a8320fd475c5d5487277ec47c0f92b46c30
data/README.md CHANGED
@@ -33,20 +33,10 @@ def foo: ( void) -> untyped
33
33
 
34
34
  ## Support VSCode
35
35
 
36
- We are currently working on a response, but it is possible to modify part of [vscode-rubocop](https://github.com/rubocop/vscode-rubocop) as a temporary hack to use it in vscode as well.
36
+ [vscode-rubocop](https://github.com/rubocop/vscode-rubocop) with [rubocop.additionalLanguages](https://github.com/rubocop/vscode-rubocop?tab=readme-ov-file#rubocopadditionallanguages) option is recommended.
37
37
 
38
- Open your installed vscode extension.
39
-
40
- ```
41
- $ code ~/.vscode/extensions/rubocop.vscode-rubocop-X.Y.Z/
42
- ```
43
-
44
- Search `documentSelector:[{`.
45
-
46
- Then, Edit to add following to `documentSelector[]`
47
-
48
- ```js
49
- {scheme:"file",language:"rbs"}
38
+ ```json
39
+ "rubocop.additionalLanguages": ["rbs"]
50
40
  ```
51
41
 
52
42
  Additionally, by configuring the `settings.json` below, you can enable auto-correction to run on file save.
@@ -25,6 +25,12 @@ module RuboCop
25
25
  end
26
26
  end
27
27
 
28
+ def on_rbs_constant(decl) = check_type(decl.type)
29
+ alias on_rbs_global on_rbs_constant
30
+ alias on_rbs_type_alias on_rbs_constant
31
+ alias on_rbs_attribute on_rbs_constant
32
+ alias on_rbs_var on_rbs_constant
33
+
28
34
  # @rbs type: ::RBS::Types::t
29
35
  def check_type(type)
30
36
  case type
@@ -17,16 +17,26 @@ module RuboCop
17
17
  def on_rbs_def(decl)
18
18
  decl.overloads.each do |overload|
19
19
  overload.method_type.each_type do |type|
20
- find_replacement(type) do |t, replaced|
21
- range = location_to_range(t.location)
22
- add_offense(range, message: "Use `#{replaced}` instead of `#{t}`") do |corrector|
23
- corrector.replace(range, replaced.to_s)
24
- end
25
- end
20
+ check_type(type)
26
21
  end
27
22
  end
28
23
  end
29
24
 
25
+ def check_type(type)
26
+ find_replacement(type) do |t, replaced|
27
+ range = location_to_range(t.location)
28
+ add_offense(range, message: "Use `#{replaced}` instead of `#{t}`") do |corrector|
29
+ corrector.replace(range, replaced.to_s)
30
+ end
31
+ end
32
+ end
33
+
34
+ def on_rbs_constant(const) = check_type(const.type)
35
+ alias on_rbs_global on_rbs_constant
36
+ alias on_rbs_type_alias on_rbs_constant
37
+ alias on_rbs_attribute on_rbs_constant
38
+ alias on_rbs_var on_rbs_constant
39
+
30
40
  # @rbs type: ::RBS::Types::t
31
41
  def find_replacement(type, &block)
32
42
  case type
@@ -20,12 +20,22 @@ module RuboCop
20
20
  def on_rbs_def(decl)
21
21
  decl.overloads.each do |overload|
22
22
  overload.method_type.each_type do |type|
23
- find_replacement(type) do |t, replaced|
24
- range = location_to_range(t.location)
25
- add_offense(range, message: "Use `#{replaced}` instead of `#{t}`") do |corrector|
26
- corrector.replace(range, replaced.to_s)
27
- end
28
- end
23
+ check_type(type)
24
+ end
25
+ end
26
+ end
27
+
28
+ def on_rbs_constant(const) = check_type(const.type)
29
+ alias on_rbs_global on_rbs_constant
30
+ alias on_rbs_type_alias on_rbs_constant
31
+ alias on_rbs_attribute on_rbs_constant
32
+ alias on_rbs_var on_rbs_constant
33
+
34
+ def check_type(type)
35
+ find_replacement(type) do |t, replaced|
36
+ range = location_to_range(t.location)
37
+ add_offense(range, message: "Use `#{replaced}` instead of `#{t}`") do |corrector|
38
+ corrector.replace(range, replaced.to_s)
29
39
  end
30
40
  end
31
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module RBS
5
- VERSION = '1.5.0'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-on-rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-23 00:00:00.000000000 Z
10
+ date: 2025-04-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: lint_roller