From dcdc343bd2bbd5f60f759d6d033257d60cb61777 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 14 Jul 2023 02:29:54 +0900 Subject: [PATCH] Integrate rubocop.vscode-rubocop This updates #314 --- .github/workflows/dprint-update-plugin.yml | 6 ++--- .github/workflows/lint.yml | 1 - .vscode/extensions.json | 1 + .vscode/settings.json | 3 +++ CONTRIBUTING.md | 27 +++++++--------------- Rakefile | 4 ++-- dprint-ci.json | 27 ---------------------- dprint.json | 19 ++++++++++----- 8 files changed, 29 insertions(+), 59 deletions(-) delete mode 100644 dprint-ci.json diff --git a/.github/workflows/dprint-update-plugin.yml b/.github/workflows/dprint-update-plugin.yml index 4d45229f..64fc72e3 100644 --- a/.github/workflows/dprint-update-plugin.yml +++ b/.github/workflows/dprint-update-plugin.yml @@ -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 @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f526fe82..279e5373 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3c00c909..edc11f54 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -7,6 +7,7 @@ "soutaro.steep-vscode", "soutaro.rbs-syntax", "dprint.dprint", + "rubocop.vscode-rubocop", "jnoortheen.nix-ide" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 526a84fb..ffda449f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,9 @@ { "editor.defaultFormatter": "dprint.dprint", "editor.formatOnSave": true, + "[ruby]": { + "editor.defaultFormatter": "rubocop.vscode-rubocop" + }, "[nix]": { "editor.defaultFormatter": "jnoortheen.nix-ide" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ca775ab..62771a8a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/Rakefile b/Rakefile index 8bd6402a..b250c880 100644 --- a/Rakefile +++ b/Rakefile @@ -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' diff --git a/dprint-ci.json b/dprint-ci.json deleted file mode 100644 index a289120e..00000000 --- a/dprint-ci.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "json": { - }, - "markdown": { - }, - "exec": { - }, - "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/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab", - "https://plugins.dprint.dev/prettier-0.26.1.json@fdbe31f6aecd24f9d6b924214710a6766050d03146163b4e241e6056b2462f2e" - ] -} diff --git a/dprint.json b/dprint.json index 4858827b..3f4d033f 100644 --- a/dprint.json +++ b/dprint.json @@ -1,11 +1,13 @@ { - "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", @@ -13,5 +15,10 @@ "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" ] }