mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 22:38:10 +08:00
What is the problem?
Running `bin/lint` or `bin/lint --fix` without arguments did not run
syntax_tree checks on Ruby files. The `lints` and `fix-all` hooks in
`lefthook.yml` were missing syntax_tree commands, so Ruby formatting
issues would not be detected or fixed.
Additionally, users with `LEFTHOOK=0` in their environment would have
`bin/lint` silently skip all checks.
What is the solution?
Add `syntax_tree` commands to both the `lints` hook (for checking) and
`fix-all` hook (for auto-fixing) in `lefthook.yml`. These use
`{all_files}` with glob filtering to check all tracked Ruby files.
Also update `LefthookLinter#exec_lefthook` in `bin/lint` to explicitly
set `LEFTHOOK=1` environment variable, ensuring lefthook runs regardless
of the user's environment settings.
175 lines
4.5 KiB
YAML
175 lines
4.5 KiB
YAML
output:
|
|
- summary
|
|
- empty_summary
|
|
- failure
|
|
- execution
|
|
- execution_out
|
|
- execution_info
|
|
- skips
|
|
|
|
glob_matcher: doublestar
|
|
|
|
pre-commit:
|
|
parallel: true
|
|
skip:
|
|
- merge
|
|
- rebase
|
|
commands:
|
|
rubocop:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec rubocop --force-exclusion {staged_files}
|
|
syntax_tree:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec stree check Gemfile {staged_files}
|
|
prettier:
|
|
glob:
|
|
- "app/assets/stylesheets/**/*.{css,scss}"
|
|
- "frontend/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
- "plugins/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
- "themes/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
run: pnpm pprettier --list-different {staged_files}
|
|
eslint:
|
|
glob:
|
|
- "frontend/**/*.{js,gjs}"
|
|
- "plugins/**/*.{js,gjs}"
|
|
- "themes/**/*.{js,gjs}"
|
|
run: pnpm eslint --quiet {staged_files}
|
|
ember-template-lint:
|
|
glob:
|
|
- "frontend/**/*.gjs"
|
|
- "plugins/**/*.gjs"
|
|
- "themes/**/*.gjs"
|
|
run: pnpm ember-template-lint {staged_files}
|
|
yaml-syntax:
|
|
glob: "**/*.{yaml,yml}"
|
|
# database.yml is an erb file not a yaml file
|
|
exclude: "config/database.yml"
|
|
run: bundle exec yaml-lint {staged_files}
|
|
i18n-lint:
|
|
glob: "**/{client,server}.en.yml"
|
|
run: bundle exec ruby script/i18n_lint.rb {staged_files}
|
|
stylelint:
|
|
glob:
|
|
- "app/assets/stylesheets/**/*.scss"
|
|
- "plugins/**/assets/stylesheets/**/*.scss"
|
|
- "themes/**/*.scss"
|
|
run: pnpm stylelint {staged_files}
|
|
|
|
fix-staged:
|
|
parallel: false
|
|
commands:
|
|
prettier:
|
|
glob:
|
|
- "app/assets/stylesheets/**/*.{css,scss}"
|
|
- "frontend/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
- "plugins/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
- "themes/**/*.{js,gjs,scss,css,cjs,mjs}"
|
|
run: pnpm pprettier --write {staged_files}
|
|
eslint:
|
|
glob:
|
|
- "frontend/**/*.{js,gjs}"
|
|
- "plugins/**/*.{js,gjs}"
|
|
- "themes/**/*.{js,gjs}"
|
|
run: pnpm eslint --fix {staged_files}
|
|
ember-template-lint:
|
|
glob:
|
|
- "frontend/**/*.gjs"
|
|
- "plugins/**/*.gjs"
|
|
- "themes/**/*.gjs"
|
|
run: pnpm ember-template-lint --fix {staged_files}
|
|
stylelint:
|
|
glob:
|
|
- "app/assets/stylesheets/**/*.scss"
|
|
- "plugins/**/assets/stylesheets/**/*.scss"
|
|
- "themes/**/*.scss"
|
|
run: pnpm stylelint --fix {staged_files}
|
|
rubocop:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec rubocop --force-exclusion -A {staged_files}
|
|
syntax_tree:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec stree write Gemfile {staged_files}
|
|
|
|
fix-all:
|
|
parallel: false
|
|
commands:
|
|
prettier:
|
|
run: pnpm lint:prettier:fix
|
|
eslint:
|
|
run: pnpm lint:js:fix
|
|
ember-template-lint:
|
|
run: pnpm lint:hbs:fix
|
|
stylelint:
|
|
run: pnpm lint:css:fix
|
|
rubocop:
|
|
run: bundle exec rubocop --force-exclusion -A
|
|
syntax_tree:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec stree write Gemfile {all_files}
|
|
|
|
lints:
|
|
parallel: true
|
|
commands:
|
|
rubocop:
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec rubocop
|
|
syntax_tree:
|
|
exclude:
|
|
- "bin/notify_file_change"
|
|
- "bin/docker/**/*"
|
|
glob:
|
|
- "**/*.{rb,rake,thor}"
|
|
- "bin/**/*"
|
|
- "Gemfile"
|
|
run: bundle exec stree check Gemfile {all_files}
|
|
prettier:
|
|
run: pnpm lint:prettier
|
|
eslint:
|
|
run: pnpm lint:js
|
|
ember-template-lint:
|
|
run: pnpm lint:hbs
|
|
stylelint:
|
|
run: pnpm lint:css
|
|
yaml-syntax:
|
|
glob: "**/*.{yaml,yml}"
|
|
# database.yml is an erb file not a yaml file
|
|
exclude: "config/database.yml"
|
|
run: bundle exec yaml-lint {all_files}
|
|
i18n-lint:
|
|
glob: "**/{client,server}.en.yml"
|
|
run: bundle exec ruby script/i18n_lint.rb {all_files}
|
|
glint:
|
|
run: pnpm lint:types
|