Fix Biome warnings
This commit is contained in:
Vendored
+33
-33
@@ -44,7 +44,7 @@
|
|||||||
function creerElement(type, nom, quantite, unite, valeur) {
|
function creerElement(type, nom, quantite, unite, valeur) {
|
||||||
if (!nom && nom !== 0) {
|
if (!nom && nom !== 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"CookieCode : un nom est obligatoire pour creer un " + type + ".",
|
`CookieCode : un nom est obligatoire pour creer un ${type}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,13 +103,13 @@
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return texte(q) + (u ? " " + texte(u) : "");
|
return texte(q) + (u ? ` ${texte(u)}` : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatElement(element, quantite, unite) {
|
function formatElement(element, quantite, unite) {
|
||||||
var quantiteTexte = quantiteDe(element, quantite, unite);
|
var quantiteTexte = quantiteDe(element, quantite, unite);
|
||||||
var nom = nomDe(element);
|
var nom = nomDe(element);
|
||||||
return quantiteTexte ? quantiteTexte + " de " + nom : nom;
|
return quantiteTexte ? `${quantiteTexte} de ${nom}` : nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
function conditionLisible(condition) {
|
function conditionLisible(condition) {
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
this._noterVariable(nomDe(nom));
|
this._noterVariable(nomDe(nom));
|
||||||
this._noterFonction("prendre");
|
this._noterFonction("prendre");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Prendre " + formatElement(nom, quantite, unite) + ".",
|
`Prendre ${formatElement(nom, quantite, unite)}.`,
|
||||||
"variable",
|
"variable",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
Recette.prototype.utiliser = function (outil) {
|
Recette.prototype.utiliser = function (outil) {
|
||||||
this._noterConstante(nomDe(outil));
|
this._noterConstante(nomDe(outil));
|
||||||
this._noterFonction("utiliser");
|
this._noterFonction("utiliser");
|
||||||
return this._ajouterEtape("Utiliser " + nomDe(outil) + ".", "constante");
|
return this._ajouterEtape(`Utiliser ${nomDe(outil)}.`, "constante");
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.ajouter = function (element, quantite, unite) {
|
Recette.prototype.ajouter = function (element, quantite, unite) {
|
||||||
@@ -205,20 +205,20 @@
|
|||||||
this._noterVariable(element.nom);
|
this._noterVariable(element.nom);
|
||||||
}
|
}
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Ajouter " + formatElement(element, quantite, unite) + ".",
|
`Ajouter ${formatElement(element, quantite, unite)}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.retirer = function (element) {
|
Recette.prototype.retirer = function (element) {
|
||||||
this._noterFonction("retirer");
|
this._noterFonction("retirer");
|
||||||
return this._ajouterEtape("Retirer " + nomDe(element) + ".", "fonction");
|
return this._ajouterEtape(`Retirer ${nomDe(element)}.`, "fonction");
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.couper = function (element, forme) {
|
Recette.prototype.couper = function (element, forme) {
|
||||||
this._noterFonction("couper");
|
this._noterFonction("couper");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Couper " + nomDe(element) + (forme ? " en " + texte(forme) : "") + ".",
|
`Couper ${nomDe(element)}${forme ? ` en ${texte(forme)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Verser " +
|
"Verser " +
|
||||||
nomDe(contenu) +
|
nomDe(contenu) +
|
||||||
(contenant ? " dans " + nomDe(contenant) : "") +
|
(contenant ? ` dans ${nomDe(contenant)}` : "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Chauffer " +
|
"Chauffer " +
|
||||||
nomDe(element) +
|
nomDe(element) +
|
||||||
(temperature ? " a " + nomDe(temperature) : "") +
|
(temperature ? ` a ${nomDe(temperature)}` : "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Cuire" +
|
"Cuire" +
|
||||||
(duree
|
(duree
|
||||||
? " pendant " + texte(duree) + (unite ? " " + texte(unite) : "")
|
? ` pendant ${texte(duree)}${unite ? ` ${texte(unite)}` : ""}`
|
||||||
: "") +
|
: "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
Recette.prototype.attendre = function (duree, unite) {
|
Recette.prototype.attendre = function (duree, unite) {
|
||||||
this._noterFonction("attendre");
|
this._noterFonction("attendre");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Attendre " + texte(duree) + (unite ? " " + texte(unite) : "") + ".",
|
`Attendre ${texte(duree)}${unite ? ` ${texte(unite)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -281,7 +281,7 @@
|
|||||||
|
|
||||||
this._fusionnerNotions(bloc);
|
this._fusionnerNotions(bloc);
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Repeter " + texte(nombre) + " fois :",
|
`Repeter ${texte(nombre)} fois :`,
|
||||||
"boucle",
|
"boucle",
|
||||||
bloc.etapes,
|
bloc.etapes,
|
||||||
);
|
);
|
||||||
@@ -314,7 +314,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Si " + conditionLisible(condition) + " :",
|
`Si ${conditionLisible(condition)} :`,
|
||||||
"condition",
|
"condition",
|
||||||
enfants,
|
enfants,
|
||||||
);
|
);
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
Recette.prototype.servir = function (element) {
|
Recette.prototype.servir = function (element) {
|
||||||
this._noterFonction("servir");
|
this._noterFonction("servir");
|
||||||
this._ajouterEtape(
|
this._ajouterEtape(
|
||||||
"Servir" + (element ? " " + nomDe(element) : "") + ".",
|
`Servir${element ? ` ${nomDe(element)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
return this.afficher();
|
return this.afficher();
|
||||||
@@ -370,11 +370,11 @@
|
|||||||
Recette.prototype._lignesEtapes = function (etapes, prefixe, indentation) {
|
Recette.prototype._lignesEtapes = function (etapes, prefixe, indentation) {
|
||||||
var lignes = [];
|
var lignes = [];
|
||||||
etapes.forEach(function (etape, index) {
|
etapes.forEach(function (etape, index) {
|
||||||
var numero = prefixe ? prefixe + "." + (index + 1) : String(index + 1);
|
var numero = prefixe ? `${prefixe}.${index + 1}` : String(index + 1);
|
||||||
lignes.push(indentation + numero + ". " + etape.texte);
|
lignes.push(`${indentation + numero}. ${etape.texte}`);
|
||||||
if (etape.enfants && etape.enfants.length > 0) {
|
if (etape.enfants && etape.enfants.length > 0) {
|
||||||
lignes = lignes.concat(
|
lignes = lignes.concat(
|
||||||
this._lignesEtapes(etape.enfants, numero, indentation + " "),
|
this._lignesEtapes(etape.enfants, numero, `${indentation} `),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
|
|
||||||
if (this.notions.variables.length > 0) {
|
if (this.notions.variables.length > 0) {
|
||||||
lignes.push(
|
lignes.push(
|
||||||
"- Ingredients = variables : " + this.notions.variables.join(", "),
|
`- Ingredients = variables : ${this.notions.variables.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.notions.constantes.length > 0) {
|
if (this.notions.constantes.length > 0) {
|
||||||
@@ -443,7 +443,7 @@
|
|||||||
}
|
}
|
||||||
if (this.notions.fonctions.length > 0) {
|
if (this.notions.fonctions.length > 0) {
|
||||||
lignes.push(
|
lignes.push(
|
||||||
"- Actions = fonctions : " + this.notions.fonctions.join(", "),
|
`- Actions = fonctions : ${this.notions.fonctions.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.notions.boucles) {
|
if (this.notions.boucles) {
|
||||||
@@ -457,7 +457,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.toText = function () {
|
Recette.prototype.toText = function () {
|
||||||
var lignes = ["Recette : " + this.nom, "", "Etapes :"];
|
var lignes = [`Recette : ${this.nom}`, "", "Etapes :"];
|
||||||
lignes = lignes.concat(this._lignesEtapes(this.etapes, "", ""));
|
lignes = lignes.concat(this._lignesEtapes(this.etapes, "", ""));
|
||||||
|
|
||||||
if (configuration.afficherNotions) {
|
if (configuration.afficherNotions) {
|
||||||
@@ -469,7 +469,7 @@
|
|||||||
|
|
||||||
Recette.prototype.toHTML = function () {
|
Recette.prototype.toHTML = function () {
|
||||||
var html = '<section class="cookiecode-recette">';
|
var html = '<section class="cookiecode-recette">';
|
||||||
html += "<h2>Recette : " + echapperHTML(this.nom) + "</h2>";
|
html += `<h2>Recette : ${echapperHTML(this.nom)}</h2>`;
|
||||||
html += "<h3>Etapes</h3>";
|
html += "<h3>Etapes</h3>";
|
||||||
html += etapesHTML(this.etapes);
|
html += etapesHTML(this.etapes);
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@
|
|||||||
this._lignesNotions()
|
this._lignesNotions()
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.forEach((ligne) => {
|
.forEach((ligne) => {
|
||||||
html += "<li>" + echapperHTML(ligne.replace(/^- /, "")) + "</li>";
|
html += `<li>${echapperHTML(ligne.replace(/^- /, ""))}</li>`;
|
||||||
});
|
});
|
||||||
html += "</ul>";
|
html += "</ul>";
|
||||||
}
|
}
|
||||||
@@ -546,34 +546,34 @@
|
|||||||
|
|
||||||
function valider(condition, succes, echec) {
|
function valider(condition, succes, echec) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
messages.push("✅ " + succes);
|
messages.push(`✅ ${succes}`);
|
||||||
} else {
|
} else {
|
||||||
reussi = false;
|
reussi = false;
|
||||||
messages.push("❌ " + echec);
|
messages.push(`❌ ${echec}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regles.ingredientsMinimum !== undefined) {
|
if (regles.ingredientsMinimum !== undefined) {
|
||||||
valider(
|
valider(
|
||||||
rapport.ingredients.length >= regles.ingredientsMinimum,
|
rapport.ingredients.length >= regles.ingredientsMinimum,
|
||||||
"Tu as utilise " + rapport.ingredients.length + " ingredient(s).",
|
`Tu as utilise ${rapport.ingredients.length} ingredient(s).`,
|
||||||
"Il faut au moins " + regles.ingredientsMinimum + " ingredient(s).",
|
`Il faut au moins ${regles.ingredientsMinimum} ingredient(s).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regles.materielsMinimum !== undefined) {
|
if (regles.materielsMinimum !== undefined) {
|
||||||
valider(
|
valider(
|
||||||
rapport.materiels.length >= regles.materielsMinimum,
|
rapport.materiels.length >= regles.materielsMinimum,
|
||||||
"Tu as utilise " + rapport.materiels.length + " materiel(s).",
|
`Tu as utilise ${rapport.materiels.length} materiel(s).`,
|
||||||
"Il faut au moins " + regles.materielsMinimum + " materiel(s).",
|
`Il faut au moins ${regles.materielsMinimum} materiel(s).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
(regles.actionsObligatoires || []).forEach((action) => {
|
(regles.actionsObligatoires || []).forEach((action) => {
|
||||||
valider(
|
valider(
|
||||||
rapport.actions.indexOf(action) !== -1,
|
rapport.actions.indexOf(action) !== -1,
|
||||||
"Action trouvee : " + action + ".",
|
`Action trouvee : ${action}.`,
|
||||||
"Action manquante : " + action + ".",
|
`Action manquante : ${action}.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -620,7 +620,7 @@
|
|||||||
rapport: rapport,
|
rapport: rapport,
|
||||||
toText: function () {
|
toText: function () {
|
||||||
return [
|
return [
|
||||||
"Defi : " + this.nom,
|
`Defi : ${this.nom}`,
|
||||||
this.reussi ? "Resultat : reussi" : "Resultat : a ameliorer",
|
this.reussi ? "Resultat : reussi" : "Resultat : a ameliorer",
|
||||||
]
|
]
|
||||||
.concat(this.messages)
|
.concat(this.messages)
|
||||||
@@ -632,7 +632,7 @@
|
|||||||
function etapesHTML(etapes) {
|
function etapesHTML(etapes) {
|
||||||
var html = "<ol>";
|
var html = "<ol>";
|
||||||
etapes.forEach((etape) => {
|
etapes.forEach((etape) => {
|
||||||
html += "<li>" + echapperHTML(etape.texte);
|
html += `<li>${echapperHTML(etape.texte)}`;
|
||||||
if (etape.enfants && etape.enfants.length > 0) {
|
if (etape.enfants && etape.enfants.length > 0) {
|
||||||
html += etapesHTML(etape.enfants);
|
html += etapesHTML(etape.enfants);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ const defi = CookieCode.defi("Cookie avec boucle", {
|
|||||||
actionsObligatoires: ["melanger", "cuire", "servir"],
|
actionsObligatoires: ["melanger", "cuire", "servir"],
|
||||||
boucleObligatoire: true,
|
boucleObligatoire: true,
|
||||||
terminerParServir: true,
|
terminerParServir: true,
|
||||||
interdireErreurs: true
|
interdireErreurs: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(CookieCode.verifier(recette, defi).toText());
|
console.log(CookieCode.verifier(recette, defi).toText());
|
||||||
|
|||||||
+33
-33
@@ -44,7 +44,7 @@
|
|||||||
function creerElement(type, nom, quantite, unite, valeur) {
|
function creerElement(type, nom, quantite, unite, valeur) {
|
||||||
if (!nom && nom !== 0) {
|
if (!nom && nom !== 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"CookieCode : un nom est obligatoire pour creer un " + type + ".",
|
`CookieCode : un nom est obligatoire pour creer un ${type}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,13 +103,13 @@
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return texte(q) + (u ? " " + texte(u) : "");
|
return texte(q) + (u ? ` ${texte(u)}` : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatElement(element, quantite, unite) {
|
function formatElement(element, quantite, unite) {
|
||||||
var quantiteTexte = quantiteDe(element, quantite, unite);
|
var quantiteTexte = quantiteDe(element, quantite, unite);
|
||||||
var nom = nomDe(element);
|
var nom = nomDe(element);
|
||||||
return quantiteTexte ? quantiteTexte + " de " + nom : nom;
|
return quantiteTexte ? `${quantiteTexte} de ${nom}` : nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
function conditionLisible(condition) {
|
function conditionLisible(condition) {
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
this._noterVariable(nomDe(nom));
|
this._noterVariable(nomDe(nom));
|
||||||
this._noterFonction("prendre");
|
this._noterFonction("prendre");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Prendre " + formatElement(nom, quantite, unite) + ".",
|
`Prendre ${formatElement(nom, quantite, unite)}.`,
|
||||||
"variable",
|
"variable",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
Recette.prototype.utiliser = function (outil) {
|
Recette.prototype.utiliser = function (outil) {
|
||||||
this._noterConstante(nomDe(outil));
|
this._noterConstante(nomDe(outil));
|
||||||
this._noterFonction("utiliser");
|
this._noterFonction("utiliser");
|
||||||
return this._ajouterEtape("Utiliser " + nomDe(outil) + ".", "constante");
|
return this._ajouterEtape(`Utiliser ${nomDe(outil)}.`, "constante");
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.ajouter = function (element, quantite, unite) {
|
Recette.prototype.ajouter = function (element, quantite, unite) {
|
||||||
@@ -205,20 +205,20 @@
|
|||||||
this._noterVariable(element.nom);
|
this._noterVariable(element.nom);
|
||||||
}
|
}
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Ajouter " + formatElement(element, quantite, unite) + ".",
|
`Ajouter ${formatElement(element, quantite, unite)}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.retirer = function (element) {
|
Recette.prototype.retirer = function (element) {
|
||||||
this._noterFonction("retirer");
|
this._noterFonction("retirer");
|
||||||
return this._ajouterEtape("Retirer " + nomDe(element) + ".", "fonction");
|
return this._ajouterEtape(`Retirer ${nomDe(element)}.`, "fonction");
|
||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.couper = function (element, forme) {
|
Recette.prototype.couper = function (element, forme) {
|
||||||
this._noterFonction("couper");
|
this._noterFonction("couper");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Couper " + nomDe(element) + (forme ? " en " + texte(forme) : "") + ".",
|
`Couper ${nomDe(element)}${forme ? ` en ${texte(forme)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Verser " +
|
"Verser " +
|
||||||
nomDe(contenu) +
|
nomDe(contenu) +
|
||||||
(contenant ? " dans " + nomDe(contenant) : "") +
|
(contenant ? ` dans ${nomDe(contenant)}` : "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Chauffer " +
|
"Chauffer " +
|
||||||
nomDe(element) +
|
nomDe(element) +
|
||||||
(temperature ? " a " + nomDe(temperature) : "") +
|
(temperature ? ` a ${nomDe(temperature)}` : "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Cuire" +
|
"Cuire" +
|
||||||
(duree
|
(duree
|
||||||
? " pendant " + texte(duree) + (unite ? " " + texte(unite) : "")
|
? ` pendant ${texte(duree)}${unite ? ` ${texte(unite)}` : ""}`
|
||||||
: "") +
|
: "") +
|
||||||
".",
|
".",
|
||||||
"fonction",
|
"fonction",
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
Recette.prototype.attendre = function (duree, unite) {
|
Recette.prototype.attendre = function (duree, unite) {
|
||||||
this._noterFonction("attendre");
|
this._noterFonction("attendre");
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Attendre " + texte(duree) + (unite ? " " + texte(unite) : "") + ".",
|
`Attendre ${texte(duree)}${unite ? ` ${texte(unite)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -281,7 +281,7 @@
|
|||||||
|
|
||||||
this._fusionnerNotions(bloc);
|
this._fusionnerNotions(bloc);
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Repeter " + texte(nombre) + " fois :",
|
`Repeter ${texte(nombre)} fois :`,
|
||||||
"boucle",
|
"boucle",
|
||||||
bloc.etapes,
|
bloc.etapes,
|
||||||
);
|
);
|
||||||
@@ -314,7 +314,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this._ajouterEtape(
|
return this._ajouterEtape(
|
||||||
"Si " + conditionLisible(condition) + " :",
|
`Si ${conditionLisible(condition)} :`,
|
||||||
"condition",
|
"condition",
|
||||||
enfants,
|
enfants,
|
||||||
);
|
);
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
Recette.prototype.servir = function (element) {
|
Recette.prototype.servir = function (element) {
|
||||||
this._noterFonction("servir");
|
this._noterFonction("servir");
|
||||||
this._ajouterEtape(
|
this._ajouterEtape(
|
||||||
"Servir" + (element ? " " + nomDe(element) : "") + ".",
|
`Servir${element ? ` ${nomDe(element)}` : ""}.`,
|
||||||
"fonction",
|
"fonction",
|
||||||
);
|
);
|
||||||
return this.afficher();
|
return this.afficher();
|
||||||
@@ -370,11 +370,11 @@
|
|||||||
Recette.prototype._lignesEtapes = function (etapes, prefixe, indentation) {
|
Recette.prototype._lignesEtapes = function (etapes, prefixe, indentation) {
|
||||||
var lignes = [];
|
var lignes = [];
|
||||||
etapes.forEach(function (etape, index) {
|
etapes.forEach(function (etape, index) {
|
||||||
var numero = prefixe ? prefixe + "." + (index + 1) : String(index + 1);
|
var numero = prefixe ? `${prefixe}.${index + 1}` : String(index + 1);
|
||||||
lignes.push(indentation + numero + ". " + etape.texte);
|
lignes.push(`${indentation + numero}. ${etape.texte}`);
|
||||||
if (etape.enfants && etape.enfants.length > 0) {
|
if (etape.enfants && etape.enfants.length > 0) {
|
||||||
lignes = lignes.concat(
|
lignes = lignes.concat(
|
||||||
this._lignesEtapes(etape.enfants, numero, indentation + " "),
|
this._lignesEtapes(etape.enfants, numero, `${indentation} `),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
|
|
||||||
if (this.notions.variables.length > 0) {
|
if (this.notions.variables.length > 0) {
|
||||||
lignes.push(
|
lignes.push(
|
||||||
"- Ingredients = variables : " + this.notions.variables.join(", "),
|
`- Ingredients = variables : ${this.notions.variables.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.notions.constantes.length > 0) {
|
if (this.notions.constantes.length > 0) {
|
||||||
@@ -443,7 +443,7 @@
|
|||||||
}
|
}
|
||||||
if (this.notions.fonctions.length > 0) {
|
if (this.notions.fonctions.length > 0) {
|
||||||
lignes.push(
|
lignes.push(
|
||||||
"- Actions = fonctions : " + this.notions.fonctions.join(", "),
|
`- Actions = fonctions : ${this.notions.fonctions.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.notions.boucles) {
|
if (this.notions.boucles) {
|
||||||
@@ -457,7 +457,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Recette.prototype.toText = function () {
|
Recette.prototype.toText = function () {
|
||||||
var lignes = ["Recette : " + this.nom, "", "Etapes :"];
|
var lignes = [`Recette : ${this.nom}`, "", "Etapes :"];
|
||||||
lignes = lignes.concat(this._lignesEtapes(this.etapes, "", ""));
|
lignes = lignes.concat(this._lignesEtapes(this.etapes, "", ""));
|
||||||
|
|
||||||
if (configuration.afficherNotions) {
|
if (configuration.afficherNotions) {
|
||||||
@@ -469,7 +469,7 @@
|
|||||||
|
|
||||||
Recette.prototype.toHTML = function () {
|
Recette.prototype.toHTML = function () {
|
||||||
var html = '<section class="cookiecode-recette">';
|
var html = '<section class="cookiecode-recette">';
|
||||||
html += "<h2>Recette : " + echapperHTML(this.nom) + "</h2>";
|
html += `<h2>Recette : ${echapperHTML(this.nom)}</h2>`;
|
||||||
html += "<h3>Etapes</h3>";
|
html += "<h3>Etapes</h3>";
|
||||||
html += etapesHTML(this.etapes);
|
html += etapesHTML(this.etapes);
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@
|
|||||||
this._lignesNotions()
|
this._lignesNotions()
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.forEach((ligne) => {
|
.forEach((ligne) => {
|
||||||
html += "<li>" + echapperHTML(ligne.replace(/^- /, "")) + "</li>";
|
html += `<li>${echapperHTML(ligne.replace(/^- /, ""))}</li>`;
|
||||||
});
|
});
|
||||||
html += "</ul>";
|
html += "</ul>";
|
||||||
}
|
}
|
||||||
@@ -546,34 +546,34 @@
|
|||||||
|
|
||||||
function valider(condition, succes, echec) {
|
function valider(condition, succes, echec) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
messages.push("✅ " + succes);
|
messages.push(`✅ ${succes}`);
|
||||||
} else {
|
} else {
|
||||||
reussi = false;
|
reussi = false;
|
||||||
messages.push("❌ " + echec);
|
messages.push(`❌ ${echec}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regles.ingredientsMinimum !== undefined) {
|
if (regles.ingredientsMinimum !== undefined) {
|
||||||
valider(
|
valider(
|
||||||
rapport.ingredients.length >= regles.ingredientsMinimum,
|
rapport.ingredients.length >= regles.ingredientsMinimum,
|
||||||
"Tu as utilise " + rapport.ingredients.length + " ingredient(s).",
|
`Tu as utilise ${rapport.ingredients.length} ingredient(s).`,
|
||||||
"Il faut au moins " + regles.ingredientsMinimum + " ingredient(s).",
|
`Il faut au moins ${regles.ingredientsMinimum} ingredient(s).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regles.materielsMinimum !== undefined) {
|
if (regles.materielsMinimum !== undefined) {
|
||||||
valider(
|
valider(
|
||||||
rapport.materiels.length >= regles.materielsMinimum,
|
rapport.materiels.length >= regles.materielsMinimum,
|
||||||
"Tu as utilise " + rapport.materiels.length + " materiel(s).",
|
`Tu as utilise ${rapport.materiels.length} materiel(s).`,
|
||||||
"Il faut au moins " + regles.materielsMinimum + " materiel(s).",
|
`Il faut au moins ${regles.materielsMinimum} materiel(s).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
(regles.actionsObligatoires || []).forEach((action) => {
|
(regles.actionsObligatoires || []).forEach((action) => {
|
||||||
valider(
|
valider(
|
||||||
rapport.actions.indexOf(action) !== -1,
|
rapport.actions.indexOf(action) !== -1,
|
||||||
"Action trouvee : " + action + ".",
|
`Action trouvee : ${action}.`,
|
||||||
"Action manquante : " + action + ".",
|
`Action manquante : ${action}.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -620,7 +620,7 @@
|
|||||||
rapport: rapport,
|
rapport: rapport,
|
||||||
toText: function () {
|
toText: function () {
|
||||||
return [
|
return [
|
||||||
"Defi : " + this.nom,
|
`Defi : ${this.nom}`,
|
||||||
this.reussi ? "Resultat : reussi" : "Resultat : a ameliorer",
|
this.reussi ? "Resultat : reussi" : "Resultat : a ameliorer",
|
||||||
]
|
]
|
||||||
.concat(this.messages)
|
.concat(this.messages)
|
||||||
@@ -632,7 +632,7 @@
|
|||||||
function etapesHTML(etapes) {
|
function etapesHTML(etapes) {
|
||||||
var html = "<ol>";
|
var html = "<ol>";
|
||||||
etapes.forEach((etape) => {
|
etapes.forEach((etape) => {
|
||||||
html += "<li>" + echapperHTML(etape.texte);
|
html += `<li>${echapperHTML(etape.texte)}`;
|
||||||
if (etape.enfants && etape.enfants.length > 0) {
|
if (etape.enfants && etape.enfants.length > 0) {
|
||||||
html += etapesHTML(etape.enfants);
|
html += etapesHTML(etape.enfants);
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-5
@@ -1,4 +1,4 @@
|
|||||||
const assert = require("assert");
|
const assert = require("node:assert");
|
||||||
const CookieCode = require("../dist/cookiecode.js");
|
const CookieCode = require("../dist/cookiecode.js");
|
||||||
|
|
||||||
CookieCode.configurer({ sortie: "test", afficherNotions: true });
|
CookieCode.configurer({ sortie: "test", afficherNotions: true });
|
||||||
@@ -86,11 +86,23 @@ const recetteIncomplete = CookieCode.recette("Cookie incomplet")
|
|||||||
.prendre("farine", 200, "g")
|
.prendre("farine", 200, "g")
|
||||||
.melanger();
|
.melanger();
|
||||||
|
|
||||||
const verificationIncomplete = CookieCode.verifier(recetteIncomplete, defiCookie);
|
const verificationIncomplete = CookieCode.verifier(
|
||||||
|
recetteIncomplete,
|
||||||
|
defiCookie,
|
||||||
|
);
|
||||||
assert.strictEqual(verificationIncomplete.reussi, false);
|
assert.strictEqual(verificationIncomplete.reussi, false);
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Il faut au moins 3 ingredient\(s\)\./);
|
assert.match(
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Il manque une boucle : essaie avec \.repeter\(\)\./);
|
verificationIncomplete.toText(),
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Ta recette doit se terminer par \.servir\(\)\./);
|
/❌ Il faut au moins 3 ingredient\(s\)\./,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
verificationIncomplete.toText(),
|
||||||
|
/❌ Il manque une boucle : essaie avec \.repeter\(\)\./,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
verificationIncomplete.toText(),
|
||||||
|
/❌ Ta recette doit se terminer par \.servir\(\)\./,
|
||||||
|
);
|
||||||
|
|
||||||
assert.strictEqual(CookieCode.version, "0.2.0");
|
assert.strictEqual(CookieCode.version, "0.2.0");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user