mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:01:05 +08:00
DEV: Replace Overcommit with Lefthook (#7826)
Overcommit uses prebuilt hooks and require global installation. To avoid this issues replace it with Lefthook. Lefthook will be installed with npm packages. New contributors will have fully consistent git hooks.
This commit is contained in:
parent
1b45096aa5
commit
0872a1182d
|
@ -1,45 +0,0 @@
|
|||
# Use this file to configure the Overcommit hooks you wish to use. This will
|
||||
# extend the default configuration defined in:
|
||||
# https://github.com/brigade/overcommit/blob/master/config/default.yml
|
||||
#
|
||||
# At the topmost level of this YAML file is a key representing type of hook
|
||||
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
||||
# customize each hook, such as whether to only run it on certain files (via
|
||||
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
||||
#
|
||||
# For a complete list of hooks, see:
|
||||
# https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
|
||||
#
|
||||
# For a complete list of options that you can use to customize hooks, see:
|
||||
# https://github.com/brigade/overcommit#configuration
|
||||
|
||||
PreCommit:
|
||||
RuboCop:
|
||||
enabled: true
|
||||
command: ['bundle', 'exec', 'rubocop']
|
||||
EsLint:
|
||||
enabled: true
|
||||
required_executable: './node_modules/.bin/eslint'
|
||||
install_command: 'yarn install'
|
||||
command: ['yarn', 'eslint', '--ext', '.es6', '-f', 'compact']
|
||||
include: '**/*.es6'
|
||||
YamlSyntax:
|
||||
enabled: true
|
||||
|
||||
PostCheckout:
|
||||
BundleInstall:
|
||||
enabled: true
|
||||
YarnInstall:
|
||||
enabled: true
|
||||
|
||||
PostMerge:
|
||||
BundleInstall:
|
||||
enabled: true
|
||||
YarnInstall:
|
||||
enabled: true
|
||||
|
||||
PostRewrite:
|
||||
BundleInstall:
|
||||
enabled: true
|
||||
YarnInstall:
|
||||
enabled: true
|
|
@ -74,13 +74,7 @@ script:
|
|||
- |
|
||||
bash -c "
|
||||
if [ '$RUN_LINT' == '1' ]; then
|
||||
bundle exec rubocop --parallel && \
|
||||
yarn prettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.es6" "test/javascripts/**/*.es6"
|
||||
yarn eslint --ext .es6 app/assets/javascripts && \
|
||||
yarn eslint --ext .es6 test/javascripts && \
|
||||
yarn eslint --ext .es6 plugins/**/assets/javascripts && \
|
||||
yarn eslint --ext .es6 plugins/**/test/javascripts && \
|
||||
yarn eslint app/assets/javascripts test/javascripts
|
||||
npx lefthook run lints
|
||||
else
|
||||
if [ '$QUNIT_RUN' == '1' ]; then
|
||||
bundle exec rake qunit:test['1200000'] && \
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -152,6 +152,7 @@ group :development do
|
|||
gem 'bullet', require: !!ENV['BULLET']
|
||||
gem 'better_errors'
|
||||
gem 'binding_of_caller'
|
||||
gem 'yaml-lint'
|
||||
|
||||
# waiting on 2.7.5 per: https://github.com/ctran/annotate_models/pull/595
|
||||
if rails_master?
|
||||
|
|
|
@ -412,6 +412,7 @@ GEM
|
|||
webpush (0.3.8)
|
||||
hkdf (~> 0.2)
|
||||
jwt (~> 2.0)
|
||||
yaml-lint (0.0.10)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -533,6 +534,7 @@ DEPENDENCIES
|
|||
unicorn
|
||||
webmock
|
||||
webpush
|
||||
yaml-lint
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
|
|
49
lefthook.yml
Normal file
49
lefthook.yml
Normal file
|
@ -0,0 +1,49 @@
|
|||
pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
rubocop:
|
||||
glob: '*.rb'
|
||||
run: bundle exec rubocop {staged_files}
|
||||
eslint:
|
||||
glob: '*.{js,es6}'
|
||||
run: yarn eslint --ext .es6 -f compact {staged_files}
|
||||
yaml-syntax:
|
||||
glob: '*.{yaml,yml}'
|
||||
run: bundle exec yaml-lint {staged_files}
|
||||
|
||||
commands: &commands
|
||||
bundle-install:
|
||||
files: git diff --name-only HEAD master
|
||||
glob: '{Gemfile,Gemfile.lock,*.gemspec}'
|
||||
run: bundle install
|
||||
yarn-install:
|
||||
files: git diff --name-only HEAD master
|
||||
glob: '{package.json,yarn.lock}'
|
||||
run: yarn install
|
||||
|
||||
post-checkout:
|
||||
commands: *commands
|
||||
|
||||
post-merge:
|
||||
commands: *commands
|
||||
|
||||
post-rewrite:
|
||||
commands: *commands
|
||||
|
||||
lints:
|
||||
parallel: true
|
||||
commands:
|
||||
rubocop:
|
||||
run: bundle exec rubocop --parallel
|
||||
prettier:
|
||||
run: yarn prettier --list-different app/assets/stylesheets/**/*.scss app/assets/javascripts/**/*.es6 test/javascripts/**/*.es6
|
||||
eslint-assets:
|
||||
run: yarn eslint --ext .es6 app/assets/javascripts
|
||||
eslint-test:
|
||||
run: yarn eslint --ext .es6 test/javascripts
|
||||
eslint-plugins-assets:
|
||||
run: yarn eslint --ext .es6 plugins/**/assets/javascripts
|
||||
eslint-plugins-test:
|
||||
run: yarn eslint --ext .es6 plugins/**/test/javascripts
|
||||
eslint-assets-tests:
|
||||
run: yarn eslint app/assets/javascripts test/javascripts
|
|
@ -33,6 +33,7 @@
|
|||
"spectrum-colorpicker": "1.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arkweid/lefthook": "^0.5.6",
|
||||
"babel-eslint": "^8.2",
|
||||
"chrome-launcher": "^0.10",
|
||||
"chrome-remote-interface": "^0.25",
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@arkweid/lefthook@^0.5.6":
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/@arkweid/lefthook/-/lefthook-0.5.6.tgz#6c44bc257c2ea2c2498c25df1757fd224a69a088"
|
||||
integrity sha512-hnzXNq/tq7LZGOFE1CigEdSOd1lkhJpUX83pyseIQg7hzrwytnm3+qVLqnMAY/Zk/L7kvWVLXiYxJofDc+2TNg==
|
||||
|
||||
"@babel/code-frame@7.0.0-beta.44":
|
||||
version "7.0.0-beta.44"
|
||||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
|
||||
|
|
Loading…
Reference in New Issue
Block a user