Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import js from "@eslint/js";
import globals from "globals";
import {defineConfig} from "eslint/config";

const jestGlobals = {
beforeAll: "readonly",
beforeEach: "readonly",
afterAll: "readonly",
afterEach: "readonly",
describe: "readonly",
expect: "readonly",
fit: "readonly",
it: "readonly",
jest: "readonly",
test: "readonly",
xdescribe: "readonly",
xit: "readonly",
xtest: "readonly"
};

export default defineConfig([
{
ignores: [
"dist/**",
"coverage/**",
".npm-cache/**",
"test/browser/.npm-cache/**"
]
},
{
files: ["**/*.{js,mjs,cjs}"],
plugins: {js},
extends: ["js/recommended"],
languageOptions: {globals: {...globals.browser, ...globals.node}},
rules: {
indent: ["warn", 4, { SwitchCase: 1 }],
"no-const-assign": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty-pattern": "error",
"no-ex-assign": "error",
"no-func-assign": "error",
"no-import-assign": "error",
"no-irregular-whitespace": "error",
"no-loss-of-precision": "error",
"no-new-native-nonconstructor": "error",
"no-obj-calls": "error",
"no-prototype-builtins": "off",
"no-redeclare": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-this-before-super": "error",
"no-undef": "warn",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unused-private-class-members": "warn",
"no-unused-vars": ["warn", { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }],
"no-use-before-define": ["warn", { functions: false, classes: true, variables: true }],
"require-yield": "error",
"use-isnan": "error",
"valid-typeof": "error",
}
},
{
files: ["test/browser/**/*.js"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...jestGlobals,
fail: "readonly"
}
}
},
]);
18 changes: 5 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,8 @@ const operation = require('./modules/operation.js');
const constants = require('./constants.js');

// ===== OPTIONAL (browser/RN) =====
let b4a;
let sodium;

try {
b4a = require('b4a');
} catch {}

try {
sodium = require('sodium-universal');
} catch {}
const b4a = require('b4a');
const sodium = require('sodium-universal');

// ===== BASE =====
const sign = signature.sign;
Expand All @@ -63,8 +55,8 @@ const exported = {

// ===== BROWSER / RN EXTENSIONS =====
if (isBrowser || isRN) {
if (b4a) exported.b4a = b4a;
if (sodium) exported.sodium = sodium;
exported.b4a = b4a;
exported.sodium = sodium;
}

module.exports = exported;
module.exports = exported;
Loading
Loading