Skip to content

Commit 94194d8

Browse files
authored
Add rubocop-md to lint markdown snippets with Ruby code (#2003)
1 parent 6d5b1e4 commit 94194d8

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ inherit_gem:
33

44
require:
55
- rubocop-sorbet
6+
- rubocop-md
67
- rubocop-minitest
78
- rubocop-rake
89
- ./lib/rubocop/cop/ruby_lsp/use_language_server_aliases
@@ -15,6 +16,7 @@ AllCops:
1516
- "sorbet/rbi/shims/**/*.rbi"
1617
Exclude:
1718
- "vendor/**/*"
19+
- "vscode/**/*"
1820
- "features/**/*"
1921
- "test/fixtures/**/*"
2022
- "test/expectations/**/*"

ADDONS.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ module RubyLsp
148148
# pre-computed information in the addon. These factory methods are invoked on every request
149149
Hover.new(client, response_builder, @config, dispatcher)
150150
end
151+
end
151152

152153
class Hover
153154
# The Requests::Support::Common module provides some helper methods you may find helpful.
@@ -175,9 +176,10 @@ module RubyLsp
175176
# Listeners must define methods for each event they registered with the dispatcher. In this case, we have to
176177
# define `on_constant_read_node_enter` to specify what this listener should do every time we find a constant
177178
def on_constant_read_node_enter(node)
178-
# Certain builders are made available to listeners to build LSP responses. The classes under `RubyLsp::ResponseBuilders`
179-
# are used to build responses conforming to the LSP Specification.
180-
# ResponseBuilders::Hover itself also requires a content category to be specified (title, links, or documentation).
179+
# Certain builders are made available to listeners to build LSP responses. The classes under
180+
# `RubyLsp::ResponseBuilders` are used to build responses conforming to the LSP Specification.
181+
# ResponseBuilders::Hover itself also requires a content category to be specified (title, links,
182+
# or documentation).
181183
@response_builder.push("Hello!", category: :documentation)
182184
end
183185
end
@@ -271,7 +273,7 @@ module RubyLsp
271273
params: Interface::ProgressParams.new(
272274
token: "progress-token-id",
273275
value: Interface::WorkDoneProgressBegin.new(kind: "begin", title: "Starting slow work!"),
274-
)
276+
),
275277
)
276278
end
277279
end
@@ -324,7 +326,6 @@ module RubyLsp
324326
)
325327
end
326328

327-
328329
def workspace_did_change_watched_files(changes)
329330
if changes.any? { |change| change[:uri].end_with?(".my-config.yml") }
330331
# Do something to reload the config here
@@ -348,7 +349,7 @@ require "ruby_lsp/check_docs"
348349
# The second argument is the file list of GIF files with the demos of all listeners
349350
RubyLsp::CheckDocs.new(
350351
FileList["#{__dir__}/lib/ruby_lsp/ruby_lsp_rails/**/*.rb"],
351-
FileList.new("#{__dir__}/misc/**/*.gif")
352+
FileList.new("#{__dir__}/misc/**/*.gif"),
352353
)
353354
```
354355

DESIGN_AND_ROADMAP.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ long term roadmap to see what’s planned
7777
"".upcase
7878
1.to_s
7979
{}.merge!({ a: 1 })
80-
[].concat([])
80+
[].push(1)
8181

8282
## Scenarios where can assume the receiver type
8383
class Foo

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ group :development do
1313
gem "psych", "~> 5.1", require: false
1414
gem "rake", "~> 13.2"
1515
gem "rdoc", require: false, github: "Shopify/rdoc", branch: "create_snapper_generator"
16+
gem "rubocop-md", "~> 1.2.0", require: false
1617
gem "rubocop-minitest", "~> 0.35.0", require: false
1718
gem "rubocop-rake", "~> 0.6.0", require: false
1819
gem "rubocop-shopify", "~> 2.15", require: false

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ GEM
7171
unicode-display_width (>= 2.4.0, < 3.0)
7272
rubocop-ast (1.31.2)
7373
parser (>= 3.3.0.4)
74+
rubocop-md (1.2.2)
75+
rubocop (>= 1.0)
7476
rubocop-minitest (0.35.0)
7577
rubocop (>= 1.61, < 2.0)
7678
rubocop-ast (>= 1.31.1, < 2.0)
@@ -137,6 +139,7 @@ DEPENDENCIES
137139
rake (~> 13.2)
138140
rdoc!
139141
rubocop (~> 1.63)
142+
rubocop-md (~> 1.2.0)
140143
rubocop-minitest (~> 0.35.0)
141144
rubocop-rake (~> 0.6.0)
142145
rubocop-shopify (~> 2.15)

0 commit comments

Comments
 (0)