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

Commit

Permalink
Integrate dprint-plugin-exec for rubocop (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick authored Feb 7, 2023
1 parent 4993342 commit 40c1ee9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dprint/[email protected]
with:
config-path: 'dprint-ci.json'
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 @@
"koichisasada.vscode-rdbg",
"soutaro.steep-vscode",
"soutaro.rbs-syntax",
"rebornix.ruby",
"jnoortheen.nix-ide"
]
}
8 changes: 0 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint",
"ruby.useBundler": true, // run non-lint commands with bundle exec
"ruby.useLanguageServer": true, // use the internal language server (see below)
"ruby.lint": {
"rubocop": {
"useBundler": true // enable rubocop via bundler
}
},
"ruby.format": "rubocop", // use rubocop for formatting
"cSpell.words": [
"dprint"
]
Expand Down
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,37 @@ $ dprint --version
$ bundle install || bundle update
```

## Dprint

Use dprint as below

```console
$ dprint --config dprint-ci.json check
$ dprint --config dprint-ci.json 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.

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

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
22 changes: 22 additions & 0 deletions dprint-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"json": {
},
"markdown": {
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"includes": ["**/*.{json,md,yml,html,css}"],
"excludes": [
".git",
"**/*-lock.json",
"doc"
],
"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.17.0.json@5e42cbabab9906ad32ffe1aa67f15824b1c39408840f0afeaddc495dd362e177"
]
}
24 changes: 9 additions & 15 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"json": {
"extends": "dprint-ci.json",
"exec": {
"associations": ["**/*.{rb,gemspec,rake}", "Rakefile", "Gemfile", "Steepfile"],
"rubocop": "bundle exec rubocop --autocorrect --stdin {{file_path}} --stderr",
"rubocop.associations": "**/**"
},
"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",
"doc"
],
"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.17.0.json@5e42cbabab9906ad32ffe1aa67f15824b1c39408840f0afeaddc495dd362e177"
"**/*lock.json",
"doc",
"steep_expectations.yml"
]
}

0 comments on commit 40c1ee9

Please sign in to comment.