From d08cea8611821b96129fc4f636768788c3984052 Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Fri, 20 Sep 2024 16:00:43 +0200 Subject: [PATCH] fix eslint config --- offchain/.eslint.config.cjs | 20 -------------------- offchain/esbuild.js | 16 ++++++++-------- offchain/esbuild/bundle.js | 2 +- offchain/esbuild/serve.js | 2 +- offchain/eslint.config.mjs | 23 +++++++++++++++++++++++ offchain/package-lock.json | 17 +++++++++++++++++ offchain/package.json | 1 + 7 files changed, 51 insertions(+), 30 deletions(-) delete mode 100644 offchain/.eslint.config.cjs create mode 100644 offchain/eslint.config.mjs diff --git a/offchain/.eslint.config.cjs b/offchain/.eslint.config.cjs deleted file mode 100644 index 19ecea33..00000000 --- a/offchain/.eslint.config.cjs +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = [ - { - env: { - browser: true, - commonjs: true, - es2021: true, - node: true, - }, - extends: 'eslint:recommended', - parserOptions: { - ecmaVersion: 'latest', - }, - rules: { - indent: ['error', 2], - 'linebreak-style': ['error', 'unix'], - quotes: ['error', 'double'], - semi: ['error', 'always'], - }, - }, -]; diff --git a/offchain/esbuild.js b/offchain/esbuild.js index 3fa94996..9e8aa4a9 100644 --- a/offchain/esbuild.js +++ b/offchain/esbuild.js @@ -1,13 +1,13 @@ -import * as esbuild from "esbuild" +import * as esbuild from "esbuild"; esbuild.build({ - entryPoints: [ './entry.js' ], - outfile: 'dist/index.js', + entryPoints: [ "./entry.js" ], + outfile: "dist/index.js", bundle: true, - platform: 'node', - format: 'esm', + platform: "node", + format: "esm", treeShaking: true, - logLevel: 'error', + logLevel: "error", minify: true, - packages: 'external', -}) + packages: "external", +}); diff --git a/offchain/esbuild/bundle.js b/offchain/esbuild/bundle.js index 29191f9a..bb21e5ee 100755 --- a/offchain/esbuild/bundle.js +++ b/offchain/esbuild/bundle.js @@ -2,7 +2,7 @@ import * as esbuild from "esbuild"; import { buildOptions } from "./config.js"; if (process.argv.length < 4) { - throw `usage: node bundle.js ENTRY_POINT OUTPUT_FILENAME`; + throw "usage: node bundle.js ENTRY_POINT OUTPUT_FILENAME"; } esbuild.build( diff --git a/offchain/esbuild/serve.js b/offchain/esbuild/serve.js index a77ae416..a0f0d66d 100755 --- a/offchain/esbuild/serve.js +++ b/offchain/esbuild/serve.js @@ -4,7 +4,7 @@ import http from "node:http"; import * as url from "url"; if (process.argv.length < 6) { - throw `usage: node serve.js ENTRY_POINT OUTPUT_FILE SERVE_DIR PORT`; + throw "usage: node serve.js ENTRY_POINT OUTPUT_FILE SERVE_DIR PORT"; } const ctx = await esbuild.context( diff --git a/offchain/eslint.config.mjs b/offchain/eslint.config.mjs new file mode 100644 index 00000000..e3abd39f --- /dev/null +++ b/offchain/eslint.config.mjs @@ -0,0 +1,23 @@ +import js from "@eslint/js"; +import globals from "globals"; + +export default [ + js.configs.recommended, + { + languageOptions: { + ecmaVersion: 'latest', + globals: { + ...globals.browser, + ...globals.commonjs, + ...globals.es2021, + ...globals.node, + } + }, + rules: { + indent: ['error', 2], + 'linebreak-style': ['error', 'unix'], + quotes: ['error', 'double'], + semi: ['error', 'always'], + }, + }, +]; diff --git a/offchain/package-lock.json b/offchain/package-lock.json index b0fa7858..21b6be59 100644 --- a/offchain/package-lock.json +++ b/offchain/package-lock.json @@ -22,6 +22,7 @@ "bip39": "^3.1.0", "blakejs": "1.2.1", "bufferutil": "4.0.5", + "globals": "^15.9.0", "isomorphic-ws": "^5.0.0", "puppeteer-core": "^15.3.2", "reconnecting-websocket": "4.4.0", @@ -1520,6 +1521,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/globals": { + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globalthis": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", @@ -4404,6 +4416,11 @@ "path-is-absolute": "^1.0.0" } }, + "globals": { + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==" + }, "globalthis": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", diff --git a/offchain/package.json b/offchain/package.json index e16b6a9d..94ad9142 100644 --- a/offchain/package.json +++ b/offchain/package.json @@ -28,6 +28,7 @@ "bip39": "^3.1.0", "blakejs": "1.2.1", "bufferutil": "4.0.5", + "globals": "^15.9.0", "isomorphic-ws": "^5.0.0", "puppeteer-core": "^15.3.2", "reconnecting-websocket": "4.4.0",