Tresjs / tres

Declarative ThreeJS using Vue Components
https://tresjs.org
MIT License
2.16k stars 102 forks source link

Git pre-push hook to `lint --fix` the project #590

Closed andretchen0 closed 5 months ago

andretchen0 commented 6 months ago

Description

As a developer using TresJS ...

Problem

I forget to lint --fix before pushing. Others do too. This leads to messier commit histories, noisier diffs, and wasted time.

Suggested solution

Add a client-side pre-push git hook to lint --fix the project and abort the push if errors exist.

By default, the hook would run lint --fix during a push, before any objects have been transferred.

If there are no linter errors after running lint --fix, it would:

If there are unfixable-by-the-linter errors, it would:

Advantages

Disadvantages

Alternative

Do nothing. Keep the project as-is.

Additional context

The project runs a linter as a CI step and fails unlinted PRs already.

Validations

alvarosabu commented 6 months ago

Sounds good, I'm planning to refactor @tresjs/eslint-config to extend https://github.com/antfu/eslint-config flat config and using ESLint Stylistic. I did it with my personal eslint config last week to test it and it works fine.

alvarosabu commented 6 months ago

Here is the task https://github.com/Tresjs/configs/issues/4

damienmontastier commented 6 months ago

Hey @alvarosabu. Wouldn't using ESLint Vue or extending it be more viable for Vue's "good practices"?

alvarosabu commented 6 months ago

Hi @damienmontastier Antfu's config extends the eslint vue rules with some opinionated overrides (which I agree) https://github.com/antfu/eslint-config/blob/main/src/configs/vue.ts

You can check the tres eslint config here https://github.com/Tresjs/eslint-config

andretchen0 commented 6 months ago

Hey @alvarosabu !

alvarosabu commented 6 months ago

Hi, @andretchen0 sounds good, so the pre-commit of husky will lint fix then?

andretchen0 commented 6 months ago

Hi, @andretchen0 sounds good, so the pre-commit of husky will lint fix then?

Yeah.

Husky is a plugin that makes git hook configuration a bit more straightforward.

The usual git commit, push, etc. commands won't change. They'll trigger a git hook configured by husky.

andretchen0 commented 5 months ago

Made a PR on Cientos:

https://github.com/Tresjs/cientos/compare/chore/git-pre-push-lint?expand=1

andretchen0 commented 5 months ago

Closing here on TresJS as there's now a PR on Cientos. Continuing the discussion there.