Skip to content

Commit

Permalink
Updated eslint config to new format. Removed Node 16 from publish tes…
Browse files Browse the repository at this point in the history
…ts as thet is now EoL
  • Loading branch information
GCHQDeveloper1138 committed Oct 4, 2024
1 parent d919b67 commit 2d932c2
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 118 deletions.
106 changes: 0 additions & 106 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v1
Expand Down
116 changes: 116 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.node,
it: false,
describe: false,
},

ecmaVersion: 2020,
sourceType: "module",

parserOptions: {
ecmaFeatures: {
impliedStrict: true,
},

allowImportExportEverywhere: true,
},
},

rules: {
"no-eval": "error",
"no-implied-eval": "error",
"dot-notation": "error",
eqeqeq: ["error", "smart"],
"no-caller": "error",
"no-extra-bind": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-return": "error",
radix: "warn",

"no-unused-vars": ["error", {
args: "none",
vars: "all",
}],

"no-empty": ["error", {
allowEmptyCatch: true,
}],

"no-control-regex": "off",
"require-atomic-updates": "off",
"no-async-promise-executor": "off",
"brace-style": ["error", "1tbs"],
"block-spacing": "error",
"array-bracket-spacing": "error",
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"no-trailing-spaces": "warn",
"eol-last": "error",
"func-call-spacing": "error",

"key-spacing": ["warn", {
mode: "minimum",
}],

indent: ["error", 4, {
ignoreComments: true,
ArrayExpression: "first",
SwitchCase: 1,
}],

"linebreak-style": ["error", "unix"],

quotes: ["error", "double", {
avoidEscape: true,
}],

camelcase: ["error", {
properties: "always",
}],

semi: ["error", "always"],
"unicode-bom": "error",

"keyword-spacing": ["error", {
before: true,
after: true,
}],

"no-multiple-empty-lines": ["warn", {
max: 2,
maxEOF: 1,
maxBOF: 0,
}],

"no-whitespace-before-property": "error",
"operator-linebreak": ["error", "after"],
"space-in-parens": "error",
"no-var": "error",
"prefer-const": "error",
},
}, {
files: ["test/**/*"],

rules: {
"no-unused-expressions": "off",
"no-console": "off",
},
}];
4 changes: 2 additions & 2 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import app from "./src/app.mjs"
import app from "./src/app.mjs";


const port = process.env.PORT || 3000;

app.listen(port, function () {
console.log(`CyberChef Server listening on port ${port}!`);
});
});
19 changes: 11 additions & 8 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { exec } from 'node:child_process';
import { exec } from "node:child_process";

switch (process.platform) {
case "darwin":
exec(`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`);
exec("find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from \"\\.[^\"]*\\)\";/\\1.mjs\";/g'");
break;
default:
exec(`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`);
exec("find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i -e '/\\.mjs/!s/\\(from \"\\.[^\"]*\\)\";/\\1.mjs\";/g'");
}

switch (process.platform) {
case "darwin":
exec(`sed -i '' 's/<div id=snackbar-container\\/>/<div id=snackbar-container>/g' ./node_modules/snackbarjs/src/snackbar.js`);
exec("sed -i '' 's/<div id=snackbar-container\\/>/<div id=snackbar-container>/g' ./node_modules/snackbarjs/src/snackbar.js");
break;
default:
exec(`sed -i 's/<div id=snackbar-container\\/>/<div id=snackbar-container>/g' ./node_modules/snackbarjs/src/snackbar.js`);
exec("sed -i 's/<div id=snackbar-container\\/>/<div id=snackbar-container>/g' ./node_modules/snackbarjs/src/snackbar.js");
}

switch (process.platform) {
case "darwin":
// Space added before comma to prevent multiple modifications
exec(`sed -i '' 's/"es\\/index.js",/"es\\/index.js" ,\\n "type": "module",/' ./node_modules/jimp/package.json`);
exec("sed -i '' 's/\"es\\/index.js\",/\"es\\/index.js\" ,\\n \"type\": \"module\",/' ./node_modules/jimp/package.json");
break;
default:
exec(`sed -i 's/"es\\/index.js",/"es\\/index.js" ,\\n "type": "module",/' ./node_modules/jimp/package.json`);
}
exec("sed -i 's/\"es\\/index.js\",/\"es\\/index.js\" ,\\n \"type\": \"module\",/' ./node_modules/jimp/package.json");
}

0 comments on commit 2d932c2

Please sign in to comment.