Skip to content

Commit b95bbd8

Browse files
DEV: Introduce syntax_tree for ruby formatting (#24)
1 parent 8276498 commit b95bbd8

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

.github/workflows/plugin-linting.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ jobs:
5555
- name: Rubocop
5656
if: ${{ !cancelled() }}
5757
run: bundle exec rubocop .
58+
59+
- name: Syntax Tree
60+
if: ${{ !cancelled() }}
61+
run: |
62+
if test -f .streerc; then
63+
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake')
64+
else
65+
echo "Stree config not detected for this repository. Skipping."
66+
fi

.github/workflows/plugin-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080

8181
- name: Get yarn cache directory
8282
id: yarn-cache-dir
83-
run: echo "::set-output name=dir::$(yarn cache dir)"
83+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
8484

8585
- name: Yarn cache
8686
uses: actions/cache@v3
@@ -130,7 +130,7 @@ jobs:
130130
shell: bash
131131
run: |
132132
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
133-
echo "::set-output name=files_exist::true"
133+
echo "files_exist=true" >> $GITHUB_OUTPUT
134134
fi
135135
136136
- name: Plugin RSpec
@@ -142,7 +142,7 @@ jobs:
142142
shell: bash
143143
run: |
144144
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
145-
echo "::set-output name=files_exist::true"
145+
echo "files_exist=true" >> $GITHUB_OUTPUT
146146
fi
147147
148148
- name: Plugin QUnit

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
inherit_gem:
2-
rubocop-discourse: default.yml
2+
rubocop-discourse: stree-compat.yml

.streerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--print-width=100
2+
--plugins=plugin/trailing_comma

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
source "https://rubygems.org"
44

55
group :development do
6-
gem 'rubocop-discourse'
6+
gem "rubocop-discourse"
7+
gem "syntax_tree"
78
end

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ GEM
66
parallel (1.22.1)
77
parser (3.1.2.1)
88
ast (~> 2.4.1)
9+
prettier_print (1.2.0)
910
rainbow (3.1.1)
1011
regexp_parser (2.6.0)
1112
rexml (3.2.5)
@@ -27,6 +28,8 @@ GEM
2728
rubocop-rspec (2.13.2)
2829
rubocop (~> 1.33)
2930
ruby-progressbar (1.11.0)
31+
syntax_tree (5.1.0)
32+
prettier_print (>= 1.2.0)
3033
unicode-display_width (2.3.0)
3134

3235
PLATFORMS
@@ -39,6 +42,7 @@ PLATFORMS
3942

4043
DEPENDENCIES
4144
rubocop-discourse
45+
syntax_tree
4246

4347
BUNDLED WITH
4448
2.3.10

plugin.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99

1010
enabled_site_setting :plugin_name_enabled
1111

12-
after_initialize do
13-
end
12+
after_initialize {}

0 commit comments

Comments
 (0)