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
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import prettier from 'eslint-plugin-prettier';

export default [
js.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: ['./tsconfig.json', './test/tsconfig.json'],
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
Buffer: 'readonly',
atob: 'readonly',
globalThis: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
'import': importPlugin,
'jsx-a11y': jsxA11y,
'prettier': prettier,
},
rules: {
'import/extensions': 0,
'no-alert': 0,
'@typescript-eslint/await-thenable': 0,
'react/button-has-type': 0,
'no-cond-assign': 0,
'class-methods-use-this': 0,
'no-underscore-dangle': 0,
'no-useless-constructor': 0,
'no-shadow': 0,
'@typescript-eslint/no-shadow': 'warn',
'no-empty-function': 0,
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'ignoreRestSiblings': true
}],
},
settings: {
'import/resolver': {
typescript: {
directory: ['./tsconfig.json', './test/tsconfig.json'],
},
},
},
},
{
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
},
];
6 changes: 3 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const config: Config.InitialOptions = {
branches: 99,
}
},
globals: {
'ts-jest': {
transform: {
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: './test/tsconfig.json',
isolatedModules: true,
},
}],
},
};

Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@magic-sdk/admin",
"version": "2.8.0",
"description": "Magic Authentication Admin Javascript SDK.",
"description": "Magic Authentication Admin JavaScript SDK.",
"author": "Magic Labs <team@magic.link>",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -33,35 +33,35 @@
"prepare": "husky install"
},
"devDependencies": {
"@ikscodes/eslint-config": "^8.4.1",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/jest": "^27.4.1",
"@types/node": "^13.1.2",
"@types/node-fetch": "^2.5.4",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"auto": "11.0.5",
"boxen-cli": "^1.0.0",
"esbuild": "^0.25.0",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^8.0.3",
"jest": "^27.5.1",
"lint-staged": "^10.0.8",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/jest": "^30.0.0",
"@types/node": "^24.3.1",
"@types/node-fetch": "^2.6.13",
"@typescript-eslint/eslint-plugin": "^8.43.0",
"@typescript-eslint/parser": "^8.43.0",
"auto": "11.3.0",
"boxen-cli": "^4.0.0",
"esbuild": "^0.25.9",
"eslint": "^9.35.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-prettier": "^5.5.4",
"husky": "^9.1.7",
"jest": "^30.1.3",
"lint-staged": "^16.1.6",
"npm-run-all": "~4.1.5",
"prettier": "^3.2.4",
"rimraf": "~3.0.0",
"ts-jest": "^27.1.3",
"prettier": "^3.6.2",
"rimraf": "~6.0.1",
"ts-jest": "^29.4.1",
"ts-node": "^10.2.0",
"tslint": "~5.20.1",
"typescript": "^5.3.3"
"typescript": "^5.9.2"
},
"dependencies": {
"ethereum-cryptography": "^1.0.1",
"ethers": "^6.11.1",
"node-fetch": "^2.6.7"
"ethereum-cryptography": "^3.2.0",
"ethers": "^6.15.0",
"node-fetch": "^2.7.0"
},
"lint-staged": {
"*.{ts,tsx}": "eslint --fix"
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/users/getMetadataByIssuer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test('Fails GET if API key is missing', async () => {
const expectedError = createApiKeyMissingError();
expect(sdk.users.getMetadataByIssuer('did:ethr:0x1234')).rejects.toThrow(expectedError);

expect(getStub).not.toBeCalled();
expect(getStub).not.toHaveBeenCalled();
});

test('Successfully GETs to metadata endpoint via issuer and wallet type', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/users/logoutByIssuer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ test('Fails POST if API key is missing', async () => {

await expect(sdk.users.logoutByIssuer('did:ethr:0x1234')).rejects.toThrow(expectedError);

expect(postStub).not.toBeCalled();
expect(postStub).not.toHaveBeenCalled();
});
8 changes: 6 additions & 2 deletions test/spec/utils/rest/post.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'node-fetch';
import { API_KEY } from '../../../lib/constants';
import { post } from '../../../../src/utils/rest';

Expand All @@ -9,9 +8,14 @@ const successRes = Promise.resolve({
}),
});

jest.mock('../../../../src/utils/fetch', () => ({
fetch: jest.fn(),
}));

test('Successfully POSTs to the given endpoint & stringifies body', async () => {
const { fetch } = require('../../../../src/utils/fetch');
const fetchStub = jest.fn().mockImplementation(() => successRes);
(fetch as any) = fetchStub;
fetch.mockImplementation(fetchStub);

await expect(post('https://example.com/hello/world', API_KEY, { public_address: '0x0123' })).resolves.toEqual({
message: 'hello world',
Expand Down
Loading