Skip to content

Commit e56f09e

Browse files
authored
Add type checking commands (#56)
- Install rbs and steep - Initialize type checkers bundle exec steep init bundle exec rbs collection init bundle exec rbs collection install - Configure Steep to check app and lib - Add typecheck commands to Makefile ## Context Now that we moved off of the template structure we're unblocked to add type checking
1 parent 8174b1c commit e56f09e

7 files changed

Lines changed: 492 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ spec/dummy/db/*.sqlite[0-9]*
2020

2121
# simplecov coverage report
2222
coverage/*
23+
24+
# typechecking
25+
.gem_rbs_collection

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ group :development do
2727
gem "rubocop-rails-omakase", require: false
2828
gem "rubocop-rspec", require: false
2929

30+
# Type checking
31+
gem "rbs"
32+
gem "steep", require: false
33+
3034
# Hot reloading for Lookbook
3135
gem "listen"
3236
gem "actioncable"

Gemfile.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ GEM
9191
crass (1.0.6)
9292
css_parser (1.21.1)
9393
addressable
94+
csv (3.3.4)
9495
date (3.4.1)
9596
diff-lcs (1.6.0)
9697
docile (1.4.1)
@@ -104,6 +105,7 @@ GEM
104105
ffi (1.17.1-x86_64-darwin)
105106
ffi (1.17.1-x86_64-linux-gnu)
106107
ffi (1.17.1-x86_64-linux-musl)
108+
fileutils (1.7.3)
107109
formatador (1.1.0)
108110
globalid (1.2.1)
109111
activesupport (>= 6.1)
@@ -164,6 +166,7 @@ GEM
164166
method_source (1.1.0)
165167
mini_mime (1.1.5)
166168
minitest (5.25.5)
169+
mutex_m (0.3.0)
167170
nenv (0.3.0)
168171
net-imap (0.5.6)
169172
date
@@ -254,6 +257,8 @@ GEM
254257
rb-fsevent (0.11.2)
255258
rb-inotify (0.11.1)
256259
ffi (~> 1.0)
260+
rbs (3.9.3)
261+
logger
257262
rdoc (6.12.0)
258263
psych (>= 4.0.0)
259264
redcarpet (3.6.1)
@@ -338,7 +343,27 @@ GEM
338343
sqlite3 (2.6.0-x86_64-darwin)
339344
sqlite3 (2.6.0-x86_64-linux-gnu)
340345
sqlite3 (2.6.0-x86_64-linux-musl)
346+
steep (1.10.0)
347+
activesupport (>= 5.1)
348+
concurrent-ruby (>= 1.1.10)
349+
csv (>= 3.0.9)
350+
fileutils (>= 1.1.0)
351+
json (>= 2.1.0)
352+
language_server-protocol (>= 3.17.0.4, < 4.0)
353+
listen (~> 3.0)
354+
logger (>= 1.3.0)
355+
mutex_m (>= 0.3.0)
356+
parser (>= 3.1)
357+
rainbow (>= 2.2.2, < 4.0)
358+
rbs (~> 3.9)
359+
securerandom (>= 0.1)
360+
strscan (>= 1.0.0)
361+
terminal-table (>= 2, < 5)
362+
uri (>= 0.12.0)
341363
stringio (3.1.5)
364+
strscan (3.1.5)
365+
terminal-table (4.0.0)
366+
unicode-display_width (>= 1.1.1, < 4)
342367
thor (1.3.2)
343368
timeout (0.4.3)
344369
tzinfo (2.0.6)
@@ -376,13 +401,15 @@ DEPENDENCIES
376401
listen
377402
lookbook (>= 2.3.9)
378403
puma
404+
rbs
379405
rspec-rails (~> 7.0.0)
380406
rubocop-rails-omakase
381407
rubocop-rspec
382408
shoulda-matchers (~> 6.0)
383409
simplecov
384410
sprockets-rails
385411
sqlite3
412+
steep
386413

387414
BUNDLED WITH
388415
2.5.22

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
lint-ci \
44
test \
55
test-coverage \
6-
test-watch
6+
test-watch \
7+
typecheck \
8+
help
79

810
setup:
911
bundle install
@@ -23,5 +25,8 @@ test-watch: ## Watch for file changes and run the test suite
2325
test-coverage: ## Open the test coverage report
2426
open coverage/index.html
2527

28+
typecheck: ## Run type checking
29+
bundle exec steep check
30+
2631
help: ## Prints the help documentation and info about each command
2732
@grep -Eh '^[/a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

Steepfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# D = Steep::Diagnostic
2+
#
3+
target :lib do
4+
signature "sig"
5+
ignore_signature "sig/test"
6+
7+
check "app"
8+
check "lib"
9+
# check "path/to/source.rb" # File name
10+
# check "app/models/**/*.rb" # Glob
11+
# ignore "lib/templates/*.rb"
12+
13+
# library "pathname" # Standard libraries
14+
# library "strong_json" # Gems
15+
16+
# configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
17+
# configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
18+
# configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
19+
# configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
20+
# configure_code_diagnostics do |hash| # You can setup everything yourself
21+
# hash[D::Ruby::NoMethod] = :information
22+
# end
23+
end
24+
25+
# target :test do
26+
# unreferenced! # Skip type checking the `lib` code when types in `test` target is changed
27+
# signature "sig/test" # Put RBS files for tests under `sig/test`
28+
# check "test" # Type check Ruby scripts under `test`
29+
#
30+
# configure_code_diagnostics(D::Ruby.lenient) # Weak type checking for test code
31+
#
32+
# # library "pathname" # Standard libraries
33+
# end

0 commit comments

Comments
 (0)