Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint v9 #81

Closed
wants to merge 2 commits into from
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
25 changes: 0 additions & 25 deletions .eslintrc.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a

This means when upgrading minor versions of the SDK, you may notice type errors. You can safely ignore these or fix by adding additional type guards.

## 2.1.2 - 2024-11-26

### Fixed

- Updated imports to use `.js` extension

### Changed

- Upgrade to eslint v9 with updated rules

## 2.1.1 - 2024-11-25

### Fixed
Expand Down
49 changes: 49 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import globals from 'globals';
import js from '@eslint/js';
import ts from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import';

/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{
languageOptions: {
globals: {
...globals.browser,
},
parser: tsParser,
parserOptions: {
project: './tsconfig.cjs.json',
},
},
},
js.configs.recommended,
...ts.configs.recommended,
{
plugins: {
import: importPlugin,
},
rules: {
'@typescript-eslint/semi': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/comma-dangle': 'off',
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/indent': 'off',
'generator-star-spacing': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'import/extensions': ['error', 'always', { js: 'always' }],
},
},
{
ignores: ['**/__tests__/**', '/dist', 'index.esm.*.ts'],
},
];
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paddle/paddle-node-sdk",
"version": "2.1.1",
"version": "2.1.2",
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
"main": "dist/cjs/index.cjs.node.js",
"module": "dist/esm/index.esm.node.js",
Expand All @@ -17,8 +17,8 @@
"build-types": "tsc -b tsconfig.types.json",
"prettier": "prettier --check ./src",
"prettier:fix": "prettier --check ./src --write",
"lint": "eslint --ext .ts,.tsx ./src",
"lint:fix": "eslint --ext .ts,.tsx ./src --fix",
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"clean": "rm -rf ./dist",
"release:rc": "yarn version --prerelease --preid rc --no-git-tag-version --no-commit-hooks",
"publish:rc": "yarn publish --tag rc --access public",
Expand All @@ -43,20 +43,19 @@
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.23.0",
"@eslint/js": "^9.15.0",
"@types/jest": "^29.5.6",
"@types/lodash": "^4.14.202",
"@types/node": "^20.6.0",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"babel-jest": "^29.7.0",
"dotenv": "^16.3.1",
"eslint": "^8.0.1",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint": "^9.15.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^16.0.0 ",
"eslint-plugin-promise": "^6.0.0",
"globals": "^15.12.0",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"typescript-eslint": "^8.16.0"
},
"exports": {
"types": "./dist/types/index.cjs.node.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/entities/customer-portal-session/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Urls {
constructor(urlsResponse: IUrlsResponse) {
this.general = new General(urlsResponse.general);
this.subscriptions = urlsResponse.subscriptions?.map(
(subscription) => new CustomerPortalSubscriptionUrl(subscription) ?? [],
(subscription) => new CustomerPortalSubscriptionUrl(subscription),
);
}
}
35 changes: 35 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
declare global {
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;

interface ResponseInit {
status?: number;
statusText?: string;
headers?: HeadersInit;
}

class Response {
constructor(body?: BodyInit | null, init?: ResponseInit);

readonly status: number;
readonly statusText: string;
readonly ok: boolean;
readonly headers: Headers;
readonly type: ResponseType;
readonly url: string;

json(): Promise<any>;
text(): Promise<string>;
blob(): Promise<Blob>;
arrayBuffer(): Promise<ArrayBuffer>;
formData(): Promise<FormData>;
}

interface ResponseConstructor {
new (body?: BodyInit | null, init?: ResponseInit): Response;
prototype: Response;
}

declare const Response: ResponseConstructor;
}

export {};
3 changes: 1 addition & 2 deletions src/internal/providers/crypto/crypto-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ export abstract class CryptoProvider {
throw new Error('randomUUID not implemented.');
}

// @ts-expect-error - unused params.
async computeHmac(payload: string, secret: string): Promise<string> {
async computeHmac(_payload: string, _secret: string): Promise<string> {
throw new Error('computeHmac not implemented.');
}
}
3 changes: 2 additions & 1 deletion src/internal/providers/crypto/edge-crypto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { type CryptoProvider } from './crypto-provider.js';

declare const crypto: any;

const byteHexMapping = new Array(256);
for (let i = 0; i < byteHexMapping.length; i++) {
byteHexMapping[i] = i.toString(16).padStart(2, '0');
Expand Down Expand Up @@ -34,7 +36,6 @@ export class EdgeCrypto implements CryptoProvider {

for (let i = 0; i < signatureBytes.length; i++) {
if (signatureBytes[i] !== undefined && signatureBytes[i] !== null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
signatureHexCodes[i] = byteHexMapping[signatureBytes[i]!];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/payment-methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { type ErrorResponse, type Response } from '../../internal/index.js';
import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js';
import { type ListCustomerPaymentMethodQueryParameters } from './operations/index.js';

export * from './operations';
export * from './operations/index.js';

const PaymentMethodPaths = {
list: '/customers/{customer_id}/payment-methods',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"module": "commonjs"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/esm",
"module": "esnext"
Expand Down
39 changes: 25 additions & 14 deletions tsconfig.base.json → tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
{
"compilerOptions": {
"target": "es2016",
"lib": ["ESNext", "dom"],
// Base Options
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"moduleDetection": "force",
"isolatedModules": true,

/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,

/* Transpiling for a typescript library */
"module": "NodeNext",
"rootDir": "./src",
"moduleResolution": "Node",
"baseUrl": "./src",
"declaration": false,
"outDir": "./dist",
"outDir": "dist",
"sourceMap": true,
"declaration": true,

/* Not running in the DOM */
"lib": ["es2022"],

/* Misc */
"removeComments": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
Expand All @@ -25,10 +38,8 @@
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"skipLibCheck": true
"noPropertyAccessFromIndexSignature": true
},
"include": ["./src"],
"include": ["src/"],
"exclude": ["**/__tests__/**/*"]
}
3 changes: 2 additions & 1 deletion tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"outDir": "./dist/types",
"declaration": true,
"moduleResolution": "NodeNext",
Expand Down
Loading
Loading