Skip to content
Closed
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
54 changes: 0 additions & 54 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
paths:
- ".github/workflows/linters.yml"
- "src/**"
- ".eslintrc.json"
- "eslint.config.mjs"
- "tsconfig.json"
- "tsconfig.module.json"
- "package.json"
Expand Down
83 changes: 83 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import eslint from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import importX from 'eslint-plugin-import-x';
import tsdoc from 'eslint-plugin-tsdoc';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default defineConfig(
globalIgnores(['build/**', 'coverage/**', '.nyc_output/**']),
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
eslint.configs.recommended,
{
files: ['src/**/*.ts'],
extends: [
...tseslint.configs.recommended,
importX.flatConfigs.recommended,
importX.flatConfigs.typescript,
],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
tsdoc,
},
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
// Template-method hooks declare params their overrides may not use (tsconfig
// already has noUnusedParameters: false).
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'import-x/extensions': ['error', 'never'],
'import-x/no-extraneous-dependencies': [
'error',
{ devDependencies: ['src/spec/**'] },
],
'import-x/order': [
'error',
{
alphabetize: { order: 'asc' },
'newlines-between': 'always',
},
],
'no-console': ['error', { allow: ['warn', 'error'] }],
// Error.cause is unavailable on the SDK's supported Node 10 runtime.
'preserve-caught-error': 'off',
'no-restricted-syntax': [
'error',
'ForInStatement',
'LabeledStatement',
'WithStatement',
],
'sort-imports': [
'error',
{ ignoreCase: true, ignoreDeclarationSort: true },
],
'tsdoc/syntax': 'error',
},
},
{
files: ['src/spec/**/*.ts'],
rules: {
'no-console': 'off',
},
},
{
files: ['**/*.js'],
languageOptions: {
globals: globals.node,
sourceType: 'commonjs',
},
},
);
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"lint": "eslint src --ext .ts",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"test": "nyc --silent ava",
"watch:build": "tsc -p tsconfig.json -w",
"watch:test": "nyc --silent ava --watch --verbose",
Expand All @@ -40,21 +41,22 @@
"@ava/typescript": "^6.0.0",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/sinon": "^10.0.3",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@typescript-eslint/parser": "^8.69.0",
"@eslint/js": "^10.0.1",
"ava": "^6.4.0",
"codecov": "^3.5.0",
"eslint": "^7.8.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-tsdoc": "^0.2.14",
"eslint": "^10.9.1",
"eslint-import-resolver-typescript": "^4.4.5",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-tsdoc": "^0.5.2",
"globals": "^17.12.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"sinon": "^11.1.2",
"ts-node": "^9.0.0",
"typedoc": "^0.25.0",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"typescript-eslint": "^8.69.0"
},
"files": [
"build/main",
Expand Down
1 change: 0 additions & 1 deletion src/lib/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-classes-per-file */
import { Client } from './client';
import { API_BASE_URL } from './constants';
import {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable max-classes-per-file */

export class FintocError extends Error {
constructor(errorData: Record<string, string>) {
const errorType = errorData.type;
Expand Down
1 change: 0 additions & 1 deletion src/lib/managers/linksManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ResourceArguments } from '../../types';
import { ManagerMixin } from '../mixins';
import { Link } from '../resources/link';
Expand Down
2 changes: 0 additions & 2 deletions src/lib/mixins/managerMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export abstract class ManagerMixin<ResourceType extends IResourceMixin> {
return this.postDeleteHandler(identifier, innerArgs);
}

/* eslint-disable class-methods-use-this, @typescript-eslint/no-unused-vars */
protected postListHandler(
objects: ResourceType[] | AsyncGenerator<ResourceType>,
args: ResourceArguments,
Expand Down Expand Up @@ -246,5 +245,4 @@ export abstract class ManagerMixin<ResourceType extends IResourceMixin> {
}
return path;
}
/* eslint-enable class-methods-use-this, @typescript-eslint/no-unused-vars */
}
2 changes: 0 additions & 2 deletions src/lib/mixins/resourceMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export abstract class ResourceMixin<ResourceType> {
) {
const content: Record<string, any> = {};
for (const [key, value] of Object.entries(data)) {
/* eslint-disable no-await-in-loop */
const rawResource = (this.mappings as Record<string, any>)[key] || key;
if (value !== undefined) {
if (Array.isArray(value)) {
Expand All @@ -66,7 +65,6 @@ export abstract class ResourceMixin<ResourceType> {
content[key] = await objetize(klass, client, value);
}
}
/* eslint-enable no-await-in-loop */
}
// @ts-ignore: cannot create an instance of an abstract class
return new this(client, handlers, methods, path, content);
Expand Down
2 changes: 0 additions & 2 deletions src/lib/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export async function* paginate(options: IPaginationOptions) {
let response = await request({
client, path, headers, params,
});
/* eslint-disable no-await-in-loop */
for (const element of response.elements) {
yield element;
}
Expand All @@ -67,5 +66,4 @@ export async function* paginate(options: IPaginationOptions) {
yield element;
}
}
/* eslint-enable no-await-in-loop */
}
2 changes: 1 addition & 1 deletion src/lib/resources/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Account extends ResourceMixin<Account> {
return this.#movementsManager;
}

set movements(newValue) { /* eslint-disable-line class-methods-use-this */
set movements(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}
}
10 changes: 5 additions & 5 deletions src/lib/resources/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Link extends ResourceMixin<Link> {
return this.#accountsManager;
}

set accounts(newValue) { /* eslint-disable-line class-methods-use-this */
set accounts(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}

Expand All @@ -72,7 +72,7 @@ export class Link extends ResourceMixin<Link> {
return this.#subscriptionsManager;
}

set subscriptions(newValue) { /* eslint-disable-line class-methods-use-this */
set subscriptions(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}

Expand All @@ -90,7 +90,7 @@ export class Link extends ResourceMixin<Link> {
return this.#taxReturnsManager;
}

set taxReturns(newValue) { /* eslint-disable-line class-methods-use-this */
set taxReturns(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}

Expand All @@ -108,7 +108,7 @@ export class Link extends ResourceMixin<Link> {
return this.#invoicesManager;
}

set invoices(newValue) { /* eslint-disable-line class-methods-use-this */
set invoices(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}

Expand All @@ -126,7 +126,7 @@ export class Link extends ResourceMixin<Link> {
return this.#refreshIntentsManager;
}

set refreshIntents(newValue) { /* eslint-disable-line class-methods-use-this */
set refreshIntents(newValue) {
throw new ReferenceError('Attribute name corresponds to a manager');
}
}
4 changes: 2 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosError } from 'axios';
import axios from 'axios';

import { IModule } from '../interfaces/module';
import { GenericFunction } from '../types';
Expand Down Expand Up @@ -127,7 +127,7 @@ export function canRaiseHTTPError(
newDescriptor.value = async function wrapper(...args: any[]) {
try {
return await descriptor.value.apply(this, args);
} catch (exc: any | AxiosError<string>) {
} catch (exc: any) {
if (axios.isAxiosError(exc) && exc.response) {
const errorData = exc.response.data as Record<string, any>;
const ErrorKlass = getErrorClass(errorData.error.type);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class WebhookSignature {
* @param header - The Fintoc-Signature header value
* @param secret - Your webhook secret key (found in your Fintoc dashboard)
* @param tolerance - Number of seconds to tolerate when checking timestamp (default: 300)
* @throws {WebhookSignatureError} If the signature is invalid or timestamp is outside
* @throws {@link WebhookSignatureError} If the signature is invalid or timestamp is outside
* tolerance window
*/
public static verifyHeader(
Expand Down
3 changes: 0 additions & 3 deletions src/spec/jws.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,18 @@ test('JWSSignature initialization with file path', (t) => {

test('JWSSignature throws error with invalid input type', (t) => {
t.throws(() => {
// eslint-disable-next-line no-new
new JWSSignature(123 as any);
}, { message: /Private key must be a string/ });
});

test('JWSSignature throws error with non-existent file path', (t) => {
t.throws(() => {
// eslint-disable-next-line no-new
new JWSSignature('/non/existent/path.pem');
}, { message: /Failed to read private key file/ });
});

test('JWSSignature throws error with invalid key format', (t) => {
t.throws(() => {
// eslint-disable-next-line no-new
new JWSSignature('invalid-key-content');
}, { message: /Invalid private key format/ });
});
Expand Down
2 changes: 0 additions & 2 deletions src/spec/mixins/managerMixin/handlers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

import test from 'ava';

import { Client } from '../../../lib/client';
Expand Down
2 changes: 0 additions & 2 deletions src/spec/mixins/managerMixin/mocks/complexMockManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console, class-methods-use-this, @typescript-eslint/no-unused-vars */

import { ManagerMixin } from '../../../../lib/mixins';
import { ResourceArguments } from '../../../../types';

Expand Down
2 changes: 0 additions & 2 deletions src/spec/mixins/resourceMixin/serialization.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

import test from 'ava';

import { Client } from '../../../lib/client';
Expand Down
4 changes: 1 addition & 3 deletions src/spec/utils/canRaiseHTTPError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* eslint-disable class-methods-use-this */

import test from 'ava';

import { FintocError } from '../../lib/errors';
import { canRaiseHTTPError } from '../../lib/utils';

class Errors {
@canRaiseHTTPError
noError() { } /* eslint-disable-line @typescript-eslint/no-empty-function */
noError() { }

@canRaiseHTTPError
throwHTTPError() {
Expand Down
Loading
Loading