Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #180 from kachick/rubocop-vscode
Browse files Browse the repository at this point in the history
Integrate `rubocop.vscode-rubocop`
  • Loading branch information
kachick authored Jul 15, 2023
2 parents 80ce61b + 8b5dc05 commit 46c6ac0
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 56 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/dprint-update-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches: ['main']
paths:
- '.github/workflows/dprint-update-plugin.yml'
- 'dprint-ci.json'
schedule:
# Run at 17:00 UTC every Monday
- cron: '0 17 * * 1'
Expand All @@ -26,10 +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'
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
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
- uses: actions/checkout@v3
- uses: dprint/[email protected]
with:
config-path: 'dprint-ci.json'
# Keep same version as *.nix
dprint-version: '0.36.1'
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"dprint.dprint",
"github.vscode-github-actions",
"streetsidesoftware.code-spell-checker",
"rubocop.vscode-rubocop",
"koichisasada.vscode-rdbg",
"soutaro.steep-vscode",
"soutaro.rbs-syntax",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint",
"[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 editting 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.

## Feel the latest 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 @@ -73,7 +73,7 @@ task(:view_packaging_files) do
end

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

desc 'Print dependencies'
Expand All @@ -85,6 +85,6 @@ end

desc 'Tests except ruby'
task :check_non_ruby do
sh('dprint check --config dprint-ci.json')
sh('dprint check')
sh('nixpkgs-fmt --check ./*.nix')
end
23 changes: 0 additions & 23 deletions dprint-ci.json

This file was deleted.

23 changes: 15 additions & 8 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"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",
"**/*-lock.json",
"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/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab",
"https://plugins.dprint.dev/prettier-0.26.1.json@fdbe31f6aecd24f9d6b924214710a6766050d03146163b4e241e6056b2462f2e"
]
}

0 comments on commit 46c6ac0

Please sign in to comment.