Lorsque nous travaillons sur un projet angulaire, lors de l’édition de .ts fichiers, nous ne codons peut-être pas de manière aussi standard, comme les définitions de variables, les espaces, les guillemets, etc.
Nous pouvons utiliser la commande suivante pour vérifier l’avertissement généré dans le projet.
C:\project\colors>ng lint Linting « couleurs »...
ERROR: C:/project/colors/src/app/app.component.ts:1497:17 - Unnecessarily quoted property 'strength' found.
ERROR: C:/project/colors/src/app/app.component.ts:1497:17 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1517:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1517:6 - Identifier 'a' is never reassigned; use 'const' instead of 'let'.
ERROR: C:/project/colors/src/app/app.component.ts:1517:10 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1518:5 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1519:5 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1522:25 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1523:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1523:2 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1523:4 - missing whitespace
ERROR: C:/project/colors/src/app/app.component.ts:1523:17 - == should be ===
ERROR: C:/project/colors/src/app/app.component.ts:1523:20 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1523:24 - missing whitespace
ERROR: C:/project/colors/src/app/app.component.ts:1524:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1524:15 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1525:1 - space indentation expected
Des erreurs de peluches trouvées dans les fichiers listés.
Comme montré ci-dessous :
Comment puis-je corriger ces avertissements ?
La commande est la suivante :
Les erreurs qui peuvent être corrigées automatiquement incluent : espace blanc manquant, point-virgule manquant, « devrait être ', 'else' mal placé, fichier doit se terminer par une nouvelle ligne, espaces blancs à la fin, point et virgule inutile, identifiant « XXX » n’est jamais modifié
L’utilisation de la commande d’avertissement automatique ne corrige pas nécessairement tous les avertissements,Si cela ne peut pas être corrigé automatiquement, nous devons corriger l’avertissement manuellement。
|