mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 17:08:31 +01:00
auto-fix prefer-const
This commit is contained in:
parent
5b03a84be8
commit
15aea9e9ea
5 changed files with 14 additions and 14 deletions
|
@ -426,7 +426,7 @@ const Code = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
_replaceVariableNames(input, replacer) {
|
_replaceVariableNames(input, replacer) {
|
||||||
let tokenRegex = /\\"|"(?:\\"|[^"])*"|(\b[a-z0-9\-_]+\b)/ig;
|
const tokenRegex = /\\"|"(?:\\"|[^"])*"|(\b[a-z0-9\-_]+\b)/ig;
|
||||||
|
|
||||||
return input.replace(tokenRegex, (...args) => {
|
return input.replace(tokenRegex, (...args) => {
|
||||||
let match = args[0],
|
let match = args[0],
|
||||||
|
@ -450,7 +450,7 @@ const Code = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
runToSnakeCase(input, args) {
|
runToSnakeCase(input, args) {
|
||||||
let smart = args[0];
|
const smart = args[0];
|
||||||
|
|
||||||
if (smart) {
|
if (smart) {
|
||||||
return Code._replaceVariableNames(input, snakeCase);
|
return Code._replaceVariableNames(input, snakeCase);
|
||||||
|
@ -469,7 +469,7 @@ const Code = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
runToCamelCase(input, args) {
|
runToCamelCase(input, args) {
|
||||||
let smart = args[0];
|
const smart = args[0];
|
||||||
|
|
||||||
if (smart) {
|
if (smart) {
|
||||||
return Code._replaceVariableNames(input, camelCase);
|
return Code._replaceVariableNames(input, camelCase);
|
||||||
|
@ -488,7 +488,7 @@ const Code = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
runToKebabCase(input, args) {
|
runToKebabCase(input, args) {
|
||||||
let smart = args[0];
|
const smart = args[0];
|
||||||
|
|
||||||
if (smart) {
|
if (smart) {
|
||||||
return Code._replaceVariableNames(input, kebabCase);
|
return Code._replaceVariableNames(input, kebabCase);
|
||||||
|
|
|
@ -471,7 +471,7 @@ const StrUtils = {
|
||||||
number = args[1];
|
number = args[1];
|
||||||
|
|
||||||
delimiter = Utils.charRep[delimiter];
|
delimiter = Utils.charRep[delimiter];
|
||||||
let splitInput = input.split(delimiter);
|
const splitInput = input.split(delimiter);
|
||||||
|
|
||||||
return splitInput
|
return splitInput
|
||||||
.filter((line, lineIndex) => {
|
.filter((line, lineIndex) => {
|
||||||
|
@ -499,7 +499,7 @@ const StrUtils = {
|
||||||
number = args[1];
|
number = args[1];
|
||||||
|
|
||||||
delimiter = Utils.charRep[delimiter];
|
delimiter = Utils.charRep[delimiter];
|
||||||
let splitInput = input.split(delimiter);
|
const splitInput = input.split(delimiter);
|
||||||
|
|
||||||
return splitInput
|
return splitInput
|
||||||
.filter((line, lineIndex) => {
|
.filter((line, lineIndex) => {
|
||||||
|
|
|
@ -244,8 +244,8 @@ ControlsWaiter.prototype.loadClick = function() {
|
||||||
* Saves the recipe specified in the save textarea to local storage.
|
* Saves the recipe specified in the save textarea to local storage.
|
||||||
*/
|
*/
|
||||||
ControlsWaiter.prototype.saveButtonClick = function() {
|
ControlsWaiter.prototype.saveButtonClick = function() {
|
||||||
let recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
|
const recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
|
||||||
let recipeStr = document.getElementById("save-text").value;
|
const recipeStr = document.getElementById("save-text").value;
|
||||||
|
|
||||||
if (!recipeName) {
|
if (!recipeName) {
|
||||||
this.app.alert("Please enter a recipe name", "danger", 2000);
|
this.app.alert("Please enter a recipe name", "danger", 2000);
|
||||||
|
|
|
@ -38,7 +38,7 @@ import Chef from "../src/core/Chef.js";
|
||||||
TestRegister.prototype.runTests = function() {
|
TestRegister.prototype.runTests = function() {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
this.tests.map(function(test, i) {
|
this.tests.map(function(test, i) {
|
||||||
let chef = new Chef();
|
const chef = new Chef();
|
||||||
|
|
||||||
return Promise.resolve(chef.bake(
|
return Promise.resolve(chef.bake(
|
||||||
test.input,
|
test.input,
|
||||||
|
@ -48,7 +48,7 @@ import Chef from "../src/core/Chef.js";
|
||||||
false
|
false
|
||||||
))
|
))
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
let ret = {
|
const ret = {
|
||||||
test: test,
|
test: test,
|
||||||
status: null,
|
status: null,
|
||||||
output: null,
|
output: null,
|
||||||
|
|
|
@ -32,7 +32,7 @@ let allTestsPassing = true,
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function statusToIcon(status) {
|
function statusToIcon(status) {
|
||||||
let icons = {
|
const icons = {
|
||||||
erroring: "🔥",
|
erroring: "🔥",
|
||||||
failing: "❌",
|
failing: "❌",
|
||||||
passing: "✔️️",
|
passing: "✔️️",
|
||||||
|
@ -48,7 +48,7 @@ function statusToIcon(status) {
|
||||||
*/
|
*/
|
||||||
function handleTestResult(testResult) {
|
function handleTestResult(testResult) {
|
||||||
allTestsPassing = allTestsPassing && testResult.status === "passing";
|
allTestsPassing = allTestsPassing && testResult.status === "passing";
|
||||||
let newCount = (testStatusCounts[testResult.status] || 0) + 1;
|
const newCount = (testStatusCounts[testResult.status] || 0) + 1;
|
||||||
testStatusCounts[testResult.status] = newCount;
|
testStatusCounts[testResult.status] = newCount;
|
||||||
testStatusCounts.total += 1;
|
testStatusCounts.total += 1;
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ TestRegister.runTests()
|
||||||
|
|
||||||
console.log("\n");
|
console.log("\n");
|
||||||
|
|
||||||
for (let testStatus in testStatusCounts) {
|
for (const testStatus in testStatusCounts) {
|
||||||
let count = testStatusCounts[testStatus];
|
const count = testStatusCounts[testStatus];
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
console.log(testStatus.toUpperCase(), count);
|
console.log(testStatus.toUpperCase(), count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue