Skip to content
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

Ajout de prettier+husky pour reformater sur commit #49

Closed
wants to merge 2 commits into from

Conversation

thom4parisot
Copy link
Contributor

@thom4parisot thom4parisot commented Feb 9, 2017

Le but est de reformatter le code systématiquement de la même manière avant tout commit.
Le CI ne devrait pas avoir à foirer parce qu'un point-virgule est manquant.

eslint est toujours là pour prévenir d'erreurs en cours d'écriture (si un plugin eslint est activé dans l'éditeur de code).

Reste à faire :

  • lancer le reformattage en pre-commit
  • utiliser prettier-eslint pour cabler eslint sur les autres règles de syntaxe (et non celles de formatage)
  • lancer le reformatage uniquement sur les fichiers staged
  • ajouter uniquement ces fichiers au stage

fix #35

@@ -7,7 +7,7 @@ parserOptions:
rules:
indent:
- error
- 4
- 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

...
tiens, un changement ^^

"start": "serve --cors -p 3000",
"test": "exit 0",
"posttest": "npm run lint"
"precommit": "npm run beautify"
Copy link
Collaborator

Choose a reason for hiding this comment

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

On a besoin d'eslint pour a minima pour les règles no-undef, eqeqeq, strict, no-unsafe-negation, no-unused-vars

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oué, j'ai capturé ça en tant qu'élément de checklist dans l'issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pardon, j'avais raté la liste, dsl.

@@ -41,6 +40,8 @@
"devDependencies": {
"browserify": "^13.1.1",
"eslint": "^3.14.0",
"husky": "^0.13.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Il sert à quoi ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

À plugger les git-hooks (n'importe lesquels) en tant que npm script.

@thom4parisot
Copy link
Contributor Author

C'est cool le reformattage mais ça flingue la possibilité de faire des commits partiels (git add -p) :

$ git status --short
MM client/js/finance/visitHierarchical.js

Une partie est staged, l'autre ne l'est pas.

{
  "scripts": {
    "beautify": "prettier --write --single-quote -- --no-trailing-comma",
    "precommit": "npm run beautify -- $(git diff --name-only --cached) | xargs git add"
  }
}

Le reformattage s'applique à tout :-(

@thom4parisot
Copy link
Contributor Author

Spa encore ça. pre-commit ça sent pas bon et à part activer le reformatage au niveau de l'éditeur – ou en PR automatique – je vois pas encore de moyens de formater au bon moment.

Je réouvrirai une PR avec avec eslint --fix à minima, car ses modifications sont peu susceptibles de générer un conflit avec git.

@thom4parisot thom4parisot deleted the feature/code-beautifier branch February 17, 2017 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rajouter un pre-commit hook qui lance eslint
2 participants