bvaughn / personal-logger

Webapp for tracking personal diet, sleep, and general wellness
https://personal-logger.now.sh
124 stars 11 forks source link

Is linting always desired for JSON and CSS files, or only at precommit? #21

Closed MikeTheCanuck closed 6 years ago

MikeTheCanuck commented 6 years ago

I'm intrigued by your use of precommit/staged-files linting - I'd like to implement that in my own project.

In my research to understand how the options work for this project, it appears you've configured prettier twice - once for precommit and again for its own script. However, there are different file types being applied depending on the context - is there a particular reason to leave json,css out of the prettier script call, or just historical evolution?

See line 33 of package.json:

    "prettier": "prettier --single-quote --trailing-comma=es5 --write 'src/**/*.{js,jsx}'",

versus the lint-staged configuration at line 22 of package.json:

    "src/**/*.{js,jsx,json,css}": [

Aside: I'd be interested to understand in which contexts you're calling the prettier script outside of the git commit flow? Is this something you do just occasionally or arbitrarily, or is the inclusion of a prettier script an artifact of the initial inclusion of prettier in the project?

bvaughn commented 6 years ago

The precommit / lint-staged bit was just copy-pasted from the suggested lint-staged + Prettier docs. It lints/formats only staged files. The separate prettier command formats everything which can be useful after updating Prettier or changing its config in some way.

The difference of js,jsx,json,css vs js,jsx is unintentional.

Aside: I'd be interested to understand in which contexts you're calling the prettier script outside of the git commit flow?

Just whenever I feel like it. No hidden secret here. Nothing to really read into. 😄