eslint-pre-commit-diff
v1.0.4
Published
Eslint only the changed lines in the commit
Downloads
490
Maintainers
Readme
Библиотека для проверки изменненых кусков кода с помощью ESLint
Установка
npm i eslint-pre-commit-diff -D
Использование
В package.json нужно добавить поле
На вход принимаются 2 параметра:
--folder - Название папки, которое должно присутствовать в пути до файла. @default: ''
--file-type - Какой тип файлов нужно проверять. @default: '.js'
История
В одном из проектов нужно было внедрить линтер для проверки кодстайла. Но как выяснилось было много разработчиком и еще больше легаси кода. Ошибок линтер находил больше 500к, руками править долго, а автофиксер не подходил из-за старых и объемных кусков кода. Поскольку разработчиков много, а времени на мерджреквесты не всегда найти для тщательной проверки, решили выбрать такой вариант: Перед коммитов проверять изменненый/новй код разработчика и не давать ему сделать коммит, пока он не поправит его по оговоренным правилам.
Краткое описание
Используется библиотека pre-commit для вызова функции проверки. Она собирает все измененные файлы в данный момент, прогоняет их через eslint и оставляет только те куски кода, которые были изменены, что упрощает головную боль разработчикам и снимает её с кодревью.