Skip to content

Commit

Permalink
Integrate rubocop.vscode-rubocop
Browse files Browse the repository at this point in the history
This updates #314
  • Loading branch information
kachick committed Jul 13, 2023
1 parent 77a8a70 commit dcdc343
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 59 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/dprint-update-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: ['main']
paths:
- '.github/workflows/dprint-update-plugin.yml'
- 'dprint-ci.json'
- 'dprint.json'
schedule:
- cron: '42 0 * * *'
# Allows you to run this workflow manually from the Actions tab
Expand All @@ -25,11 +25,9 @@ jobs:
timeout-minutes: 15
steps:
- id: update-dprint-plugins
uses: kachick/action-update-dprint-plugins@v1.0.0
uses: kachick/action-update-dprint-plugins@v1
with:
base-branch: 'main'
github-token: '${{ secrets.GITHUB_TOKEN }}'
config-path: 'dprint-ci.json'
# Enable `Allow auto-merge` in your repository settings if you need following steps
- name: Merge sent PR
# Merge if `dprint fmt` does not make any diff even after updating plugins
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
with:
# Keep same version as *.nix
dprint-version: '0.36.1'
config-path: 'dprint-ci.json'

typos:
timeout-minutes: 15
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"soutaro.steep-vscode",
"soutaro.rbs-syntax",
"dprint.dprint",
"rubocop.vscode-rubocop",
"jnoortheen.nix-ide"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"[ruby]": {
"editor.defaultFormatter": "rubocop.vscode-rubocop"
},
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
}
Expand Down
27 changes: 8 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,24 @@ $ bundle install || bundle update

## Dprint

Using [dprint](https://dprint.dev/) as below
Using [dprint](https://dprint.dev/) for common formatter except ruby.

```console
$ dprint --config dprint-ci.json check
$ dprint --config dprint-ci.json fmt
$ dprint check
$ dprint fmt
...
```

Providing 2 config files. For the purpose below

- [dprint-ci.json](dprint-ci.json) - Except ruby for faster run
- [dprint.json](dprint.json) - Includes rubocop integration. Just using in vscode

## Rubocop

Using rubocop as a formatter. So recommend to execute it with servermode before editing code to reduce time.
Using rubocop as a ruby formatter.

```console
$ bundle exec rubocop --start-server
$ bundle exec rubocop
$ bundle exec rubocop --autocorrect
...
```

Vscode tasks does not include it because of executed server process will exists even after closing vscode.\
Please manually kill it as below.

```console
$ bundle exec rubocop --stop-server
```

See [microsoft/vscode#65986](https://github.com/microsoft/vscode/issues/65986) for further detail.

## Touch the development version with REPL

```console
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ task(:view_packaging_files) do
end

task(:dprint) do
sh('dprint check --config dprint-ci.json')
sh('dprint check')
end

task(:update) do
sh('dprint config update --config dprint-ci.json')
sh('dprint config update')
end

desc 'Print dependencies'
Expand Down
27 changes: 0 additions & 27 deletions dprint-ci.json

This file was deleted.

19 changes: 13 additions & 6 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
{
"extends": "dprint-ci.json",
"exec": {
"associations": ["**/*.{rb,gemspec,rake}", "Rakefile", "Gemfile", "Steepfile"],
"rubocop": "bundle exec rubocop --autocorrect --stdin {{file_path}} --stderr",
"rubocop.associations": "**/**"
"json": {
},
"includes": ["**/*.{json,md,yml,html,css,rb,gemspec,rake}", "{Rakefile,Gemfile,Steepfile}"],
"markdown": {
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"includes": ["**/*.{json,md,yml,html,css}"],
"excludes": [
".git",
"**/*lock.json",
"docs",
"doc",
"steep_expectations.yml",
"vendor"
],
"plugins": [
"https://plugins.dprint.dev/json-0.17.4.wasm",
"https://plugins.dprint.dev/markdown-0.15.3.wasm",
"https://plugins.dprint.dev/prettier-0.26.1.json@fdbe31f6aecd24f9d6b924214710a6766050d03146163b4e241e6056b2462f2e"
]
}

0 comments on commit dcdc343

Please sign in to comment.