oxsecurity / megalinter

🦙 MegaLinter analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
https://megalinter.io
GNU Affero General Public License v3.0
1.8k stars 215 forks source link

[solved] Vale (prose linter) setup #3087

Open wesley-dean-flexion opened 7 months ago

wesley-dean-flexion commented 7 months ago

I found that SPELL_VALE works well locally on projects where I'm already using it. Cool. However, I found that just dropping a .vale.ini file into a project tends to fail if the following conditions are true:

For example:

E201 Invalid value [/path/to/repo/.vale.ini:9:45]:

   8  ##
   9* ## See: https://vale.sh/docs/topics/config/#stylespath
  10  StylesPath = styles
  11  

The path '/path/to/repo/styles' does not exist.

or:

E100 [loadStyles] Runtime error
style 'alex' does not exist on StylesPath

(examples included so they show up in searches)

So, to fix that, one could create a styles directory in one's repo, then install Vale locally and run vale sync to acquire the styles, then commit all of that to the repo. That seems like an anti-pattern to me.

Therefore, I added the following to my .mega-linter.yml file:

# make sure Vale is setup to run with the styles it needs
SPELL_VALE_PRE_COMMANDS:
  - command: mkdir -p "$(git rev-parse --show-toplevel)/$(sed -Ene 's/^[[:space:]]*StylesPath[[:space:]]*=[[:space:]]*([^#]*)/\1/Ip' < .vale.ini)"
    cwd: "workspace"
  - command: vale sync
    cwd: "workspace"

This will:

  1. parse out the StylesPath line from the .vale.ini file, then run mkdir -p on it (the -p flag has the side effect of having mkdir not throw an error if the directory already exists)
  2. run vale sync which downloads the styles articulated in the .value.ini file

I believe that this is a better approach than having the Vale container synchronize the styles content itself as it allows the user to opt-in by including the steps needed to "make it go" while not requiring the addition of an additional MegaLinter configuration option to allow the user to opt-out.

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.