DEV: Improve lefthook config and remove some slow hooks (#16626)

They were slowing down checkout, merge and rewrite.
This also cleans up the "lints" section which was running into problems with `{all_files}` being too much for some tools to handle. And it makes sure that eslint and prettier runs for core plugins as well.
This commit is contained in:
Gerhard Schlager 2022-05-04 17:37:01 +02:00 committed by GitHub
parent 28e8ae553d
commit 2d143ec2fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 38 deletions

View File

@ -9,11 +9,13 @@ app/assets/javascripts/discourse/lib/autosize.js
lib/javascripts/locale/ lib/javascripts/locale/
lib/javascripts/messageformat.js lib/javascripts/messageformat.js
lib/highlight_js/ lib/highlight_js/
lib/pretty_text/
plugins/**/lib/javascripts/locale plugins/**/lib/javascripts/locale
public/ public/
vendor/ vendor/
app/assets/javascripts/discourse/tests/test-boot-rails.js app/assets/javascripts/discourse/tests/test-boot-rails.js
app/assets/javascripts/discourse/tests/fixtures app/assets/javascripts/discourse/tests/fixtures
node_modules/ node_modules/
spec/
dist/ dist/
tmp/ tmp/

View File

@ -24,6 +24,7 @@ public/
vendor/ vendor/
app/assets/javascripts/discourse/tests/test-boot-rails.js app/assets/javascripts/discourse/tests/test-boot-rails.js
app/assets/javascripts/discourse/tests/fixtures app/assets/javascripts/discourse/tests/fixtures
spec/
node_modules/ node_modules/
dist/ dist/
**/*.rb **/*.rb

View File

@ -1,21 +1,25 @@
skip_output:
- meta
- success
pre-commit: pre-commit:
parallel: true parallel: true
commands: commands:
rubocop: rubocop:
glob: "*.rb" glob: "*.rb"
run: bundle exec rubocop --parallel {staged_files} run: bundle exec rubocop --parallel --force-exclusion {staged_files}
prettier: prettier:
glob: "*.js" glob: "*.js"
include: "app/assets/javascripts|test/javascripts" include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn pprettier --list-different {staged_files} run: yarn pprettier --list-different {staged_files}
prettier-scss: prettier-scss:
glob: "*.scss" glob: "*.scss"
include: "app/assets/stylesheets" include: "app/assets/stylesheets|plugins/.+?/assets/stylesheets"
run: yarn pprettier --list-different {staged_files} run: yarn pprettier --list-different {staged_files}
eslint: eslint:
glob: "*.js" glob: "*.js"
include: "app/assets/javascripts|test/javascripts" include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn eslint -f compact {staged_files} run: yarn eslint -f compact --quiet {staged_files}
ember-template-lint: ember-template-lint:
run: yarn run ember-template-lint {staged_files} run: yarn run ember-template-lint {staged_files}
yaml-syntax: yaml-syntax:
@ -27,46 +31,25 @@ pre-commit:
glob: "**/{client,server}.en.yml" glob: "**/{client,server}.en.yml"
run: bundle exec ruby script/i18n_lint.rb {staged_files} run: bundle exec ruby script/i18n_lint.rb {staged_files}
commands: &commands
bundle-install:
files: git diff --name-only HEAD main
glob: "{Gemfile,Gemfile.lock,*.gemspec}"
run: bundle install
yarn-install:
files: git diff --name-only HEAD main
glob: "{package.json,yarn.lock}"
run: yarn install
post-checkout:
commands: *commands
post-merge:
commands: *commands
post-rewrite:
commands: *commands
lints: lints:
parallel: true parallel: true
commands: commands:
rubocop: rubocop:
glob: "*.rb"
run: bundle exec rubocop --parallel run: bundle exec rubocop --parallel
prettier: prettier:
glob: "*.js" run: yarn pprettier --list-different **/*.js
include: "app/assets/javascripts|test/javascripts"
run: yarn pprettier --list-different {all_files}
prettier-scss: prettier-scss:
glob: "*.scss" run: yarn pprettier --list-different **/*.scss
include: "app/assets/stylesheets" eslint:
run: yarn pprettier --list-different {all_files} run: yarn eslint -f compact --quiet --ext .js .
eslint-assets-js: ember-template-lint:
run: yarn eslint app/assets/javascripts run: yarn run ember-template-lint .
eslint-test-js: yaml-syntax:
run: yarn eslint test/javascripts glob: "*.{yaml,yml}"
eslint-plugins-assets: # database.yml is an erb file not a yaml file
run: yarn eslint plugins/**/assets/javascripts exclude: "database.yml"
eslint-plugins-test: run: bundle exec yaml-lint {all_files}
run: yarn eslint plugins/**/test/javascripts
i18n-lint: i18n-lint:
glob: "**/{client,server}.en.yml" glob: "**/{client,server}.en.yml"
run: bundle exec ruby script/i18n_lint.rb {all_files} run: bundle exec ruby script/i18n_lint.rb {all_files}