fix: performances, sécurité et qualité — 4 corrections audit LaForge#10
Open
naarob wants to merge 1 commit into0N0K0:mainfrom
Open
fix: performances, sécurité et qualité — 4 corrections audit LaForge#10naarob wants to merge 1 commit into0N0K0:mainfrom
naarob wants to merge 1 commit into0N0K0:mainfrom
Conversation
…UG flag - variableBuilder.ts: findVariables() remplace la boucle séquentielle (N appels getLocalVariablesAsync) par un seul getCollectionVariables() + filter en mémoire - colorUtils.ts: Math.min/max.apply() → Math.min/max(...arr) (ES2020 idiomatic) - colorUtils.ts: lightness dans generateGreyShades() clampée dans [0,1] pour éviter les valeurs négatives si step > 1000 - colorUtils.ts: ajout JSDoc sur les 3 fonctions exportées - ui/*.ts: console.log/warn conditionnés à const DEBUG = false — silencieux en production, activables pour le débogage sans modifier le code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexte
Audit statique automatique effectué par LaForge sur les 50 fichiers TypeScript du projet (7 669 lignes). 4 problèmes concrets identifiés et corrigés.
Corrections
⚡
variableBuilder.ts—findVariables(): N appels API → 1La méthode faisait une boucle séquentielle sur
findVariable(), qui appellefigma.variables.getLocalVariablesAsync()à chaque itération. Avec 10 variables = 10 round-trips vers Figma.Fix : un seul
getCollectionVariables()+Set.has()en mémoire.🐛
colorUtils.ts—lightnessnon clampée dansgenerateGreyShades()Si
step > 1000,lightness = 1 - step/1000devient négative. culori accepte silencieusement les valeurs hors[0, 1]avec un rendu indéfini.Fix :
Math.max(0, Math.min(1, 1 - t))colorUtils.ts—Math.min/max.apply()antipatternMath.min.apply(Math, arr)est un idiome ES5. Letsconfigcible ES2020 — utiliser le spread natif.Fix :
Math.min(...arr)/Math.max(...arr)🔍 4 fichiers UI —
console.log/warnen productionLes logs étaient actifs inconditionnellement dans
colorSelector.ts,buttonListeners.ts,main.ts,formData.ts. Ils exposent des données de formulaire dans la console Figma.Fix : ajout de
const DEBUG = falseen haut de chaque fichier, chaque appel conditionné parif (DEBUG). Silencieux en production, activable localement sans modifier la logique.Build :
npm run build✅ —tsc --noEmit✅ — bundle 104KBJSDoc ajouté sur les 3 fonctions exportées de
colorUtils.ts.