Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate dprint-plugin-exec to use rubocop as a simple formatter #317

Merged
merged 4 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dprint/[email protected]
- name: Install dprint
run: |
curl -fsSL https://dprint.dev/install.sh | sh -s 0.34.1 > /dev/null 2>&1
echo "/home/runner/.dprint/bin" >> $GITHUB_PATH
- name: Check formatting
run: ~/.dprint/bin/dprint --config dprint-ci.json check
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"soutaro.steep-vscode",
"soutaro.rbs-syntax",
"dprint.dprint",
"pucelle.run-on-save",
"jnoortheen.nix-ide"
]
}
10 changes: 0 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"runOnSave.statusMessageTimeout": 3000,
"runOnSave.commands": [
{
"match": "(.*\\.rb|Rakefile|Gemfile|.*\\.gemspec)$",
"command": "bundle exec rubocop --autocorrect ${file}",
"runIn": "backend",
"runningStatusMessage": "Formatting with rubocop ${fileBasename}",
"finishStatusMessage": "${fileBasename} formatted"
}
],
"cSpell.words": [
"kwargs",
"Undocumentable",
Expand Down
16 changes: 9 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ $ dprint --version
$ bundle install || bundle update
```

Author is using vscode for development.
## Dprint

### Note - rubocop in vscode
Use dprint as below

For your information, the rubocop vscode integration shows wrong errors for Rakefile and ruby-ulid.gemspec as below

```text
The name of this source file (`Rakefile'`) should use snake_case.
```console
$ dprint --config dprint-ci.json check
$ dprint --config dprint-ci.json fmt
```

`bundle exec rubocop` does not show this messsage. It looks fixed in https://github.com/rubyide/vscode-ruby/pull/647. However it is not released yet at 2022-05-26. (https://github.com/rubyide/vscode-ruby/commit/dc81c809c82003d26af9c4dc7c89fa8f8a26cbf5 "rebornix.ruby" maintainance is inactive now)
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

## Touch the development version with REPL

Expand Down
26 changes: 26 additions & 0 deletions dprint-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"json": {
},
"markdown": {
},
"exec": {
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"includes": ["**/*.{json,md,yml,html,css}"],
"excludes": [
".git",
"**/*lock.json",
"docs",
"doc",
"steep_expectations.yml"
],
"plugins": [
"https://plugins.dprint.dev/json-0.17.0.wasm",
"https://plugins.dprint.dev/markdown-0.15.2.wasm",
"https://plugins.dprint.dev/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab",
"https://plugins.dprint.dev/prettier-0.19.0.json@f2ca8ddf0a5d7eca344681f54a9280250727324d09475f201fa2584faa2300c5"
]
}
19 changes: 6 additions & 13 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
{
"json": {
"extends": "dprint-ci.json",
"exec": {
"associations": ["**/*.{rb,gemspec,rake}", "Rakefile", "Gemfile", "Steepfile"],
"rubocop": "bundle exec rubocop --autocorrect --stdin {{file_path}} --stderr",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using servermode makde faster, However closing vscode does not kill it. So it should be done in another PR or commit.

"rubocop.associations": "**/**"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"markdown": {
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"includes": ["**/*.{json,md,yml,html,css}"],
"includes": ["**/*.{json,md,yml,html,css,rb,gemspec,rake}", "{Rakefile,Gemfile,Steepfile}"],
"excludes": [
".git",
"**/*lock.json",
"docs",
"doc",
"steep_expectations.yml"
],
"plugins": [
"https://plugins.dprint.dev/json-0.17.0.wasm",
"https://plugins.dprint.dev/markdown-0.15.2.wasm",
"https://plugins.dprint.dev/prettier-0.19.0.json@f2ca8ddf0a5d7eca344681f54a9280250727324d09475f201fa2584faa2300c5"
]
}