Skip to content

[DO NOT MERGE] [FEAT] Pre Commit Hook #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leendrew
Copy link
Collaborator

@leendrew leendrew commented Aug 6, 2022

Story

  • Линтинг файлов при коммите

Problem

  • Запускается много (?) раз (несколько раз повторял процесс установки с пустой ветки с различными вариантами)
  • Если в пачке файлов есть хотя бы 1 из скоупа выше src отрабатывает нормально, иначе плюется ошибкой

How to Reproduce

git clone https://github.com/unnamed-crm/web-client.git -b feat/pre-commit-hook
yarn

Linux Users

chmod +x ./.husky/pre-commit
chmod +x ./.husky/_/husky.sh

Для успешного срабатывания:

  • Изменить какой-нибудь файл внутри src и вне
git add .
git commit -m 'test'

Для ошибки:

  • Изменить какой-нибудь файл только внутри src
git add .
git commit -m 'test'

@leendrew leendrew added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Aug 6, 2022
@ignavan39
Copy link
Contributor

Пример ошибки можно скрином?

@leendrew
Copy link
Collaborator Author

leendrew commented Aug 6, 2022

@ignavan39
Copy link
Contributor

Мне кажется ты с конфигом lintstagerc перемудрил, я думаю надо просто next lint ./src что-то типа такого


module.exports = {
'./src/**/*' : (filenames) => [
`next lint --fix --file ${filenames
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А просто по директории src нельзя?

Copy link
Collaborator Author

@leendrew leendrew Aug 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вся фишка именно в том, чтобы линтились только закомиченные файлы, если в прехуке просто прописать линтинг, все отлинченные файлы надо будет добавлять вторым комитом. Можно скостылить прехук:

yarn eslint --fix --quiet \"./src/**/*\"
yarn prettier --write \"./src/**/*\"
git add .
git commit -m 'chore: linted'

но это будет доп коммит на каждый коммит с неконтроллируемым выбором файлов, мне такое не нравится.
/* пройдет по первому уровню вложенности, /**/* пройдет по всем файлам во всех подпапках
В статьях и туторах у всех все работает, я как обычно об стену долблюсь 😢

@leendrew
Copy link
Collaborator Author

leendrew commented Aug 7, 2022

Windows users
Starege

@ignavan39
Copy link
Contributor

Ну я хз чо с виндой делать на линухе все ок работает

@ignavan39
Copy link
Contributor

Мб версию попробовать даунгрейднуть ?

@ignavan39 ignavan39 removed the bug Something isn't working label Aug 8, 2022
@ignavan39
Copy link
Contributor

Забей на это, я поресерчу что можно на винде с этим поделять, берись за бизнес фичи, это пока подождет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants