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
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

69 changes: 0 additions & 69 deletions .eslintrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ CVE-2025-68429
# tar

CVE-2026-23745

# ajv

CVE-2025-69873

# minimatch

CVE-2026-26996
124 changes: 124 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
const { defineConfig, globalIgnores } = require('eslint/config')

const js = require('@eslint/js')
const tseslint = require('typescript-eslint')
const importPlugin = require('eslint-plugin-import')
const jestPlugin = require('eslint-plugin-jest')
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended')
const reactPlugin = require('eslint-plugin-react')
const storybook = require('eslint-plugin-storybook')
const globals = require('globals')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint 9 doesn't support env: to set the globals anymore, so we need the globals package (if we're not hardcoding all the globals we need). See https://eslint.org/docs/latest/use/configure/language-options#predefined-global-variables


module.exports = defineConfig([
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactPlugin.configs.flat.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
eslintPluginPrettierRecommended,
],

languageOptions: {
ecmaVersion: 6,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
},
},

rules: {
'@typescript-eslint/no-require-imports': 0,
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-restricted-types': 0,
'@typescript-eslint/no-unsafe-function-type': 0,
'@typescript-eslint/no-wrapper-object-types': 0,
'no-shadow': 0,
'import/named': 0,
'prettier/prettier': 'error',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
},

groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],

'newlines-between': 'never',
},
],

'react/prop-types': 0,
},

settings: {
react: {
version: 'detect',
},
},
},

{
files: ['**/*.{spec,test}.{ts,tsx}'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate, so it is only applied to test files

plugins: {
jest: jestPlugin,
},
languageOptions: {
globals: jestPlugin.environments.globals.globals,
},
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
},

{
settings: {
'import/resolver': {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to resolve aliases based on tsconfig

typescript: true,
node: true,
},
},
},

...storybook.configs['flat/recommended'],

globalIgnores([
'**/.devcontainer',
'**/.github',
'**/.vscode',
'**/node_modules',
'**/dist',
'!.storybook',
'**/*.js',
]),
])
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,31 @@
"@babel/preset-react": "^7.27.1",
"@babel/preset-typescript": "^7.27.1",
"@chalbert/enzyme-adapter-react-18": "^0.7.2",
"@eslint/js": "^9.39.2",
"@peculiar/webcrypto": "^1.5.0",
"@types/jest": "^29.5.14",
"@types/node": "^20.19.33",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"typescript-eslint": "^8.56.0",
"auto": "^11.3.6",
"babel-jest": "^29.7.0",
"babel-loader": "^9.2.1",
"css-loader": "^6.11.0",
"dotenv-webpack": "^6.0.4",
"enzyme": "^3.11.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.2",
"eslint-loader": "^4.0.2",
"eslint": "^9.39.2",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^4.2.5",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.5",
"globals": "^15.9.0",
"html-webpack-plugin": "^5.6.6",
"http-server": "^13.1.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lerna": "9.0.4",
"prettier": "^2.2.1",
"prettier": "^3.8.0",
"style-loader": "^3.3.4",
"ts-jest": "^29.4.6",
"ts-loader": "^9.5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/embed-cdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clean": "rm -rf lib",
"prebuild": "yarn clean",
"build": "webpack --config webpack.prod.js",
"lint": "eslint src --ext ts",
"lint": "eslint src/**/*.ts",
"prepack": "echo 'This is a private project and should not be packed.'; exit 1;"
},
"dependencies": {
Expand Down
11 changes: 0 additions & 11 deletions packages/embed-react/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/embed-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev": "webpack serve --config webpack.dev.js",
"prebuild": "yarn clean",
"build": "tsc",
"lint": "eslint src dev --ext ts,tsx",
"lint": "eslint src/**/*.{ts,tsx} dev/**/*.tsx",
"prepack": "yarn build",
"storybook": "storybook dev",
"test": "jest --colors"
Expand Down
9 changes: 0 additions & 9 deletions packages/embed/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dev": "webpack serve --config webpack.dev.js",
"build": "tsc && webpack --config webpack.prod.js",
"prepack": "yarn build",
"lint": "eslint src/ --ext ts",
"lint": "eslint src/**/*.ts",
"test": "jest --colors"
},
"files": [
Expand Down
23 changes: 12 additions & 11 deletions packages/embed/src/apple-pay/apple-pay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ beforeEach(() => {
abort: jest.fn(),
oncancel: jest.fn(),
}
window.ApplePaySession = (jest
window.ApplePaySession = jest
.fn()
.mockReturnValue(mockAppleSession) as unknown) as ApplePaySession
.mockReturnValue(mockAppleSession) as unknown as ApplePaySession
;(window.ApplePaySession as any).STATUS_SUCCESS = 1
;(window.ApplePaySession as any).STATUS_FAILURE = 0
mockSubjectManager = createSubjectManager()
Expand All @@ -34,9 +34,10 @@ test('should start a session with version 3 and session data', () => {

jest.runAllTimers()

expect(
(window.ApplePaySession as unknown) as jest.Mock
).toHaveBeenCalledWith(3, { foo: 'bar' })
expect(window.ApplePaySession as unknown as jest.Mock).toHaveBeenCalledWith(
3,
{ foo: 'bar' }
)
expect(mockAppleSession.begin).toHaveBeenCalled()
})

Expand Down Expand Up @@ -186,9 +187,9 @@ describe('loadApplePaySdk', () => {
})

it('skips adding the script if ApplePaySession already exists', async () => {
window.ApplePaySession = ({
window.ApplePaySession = {
begin: jest.fn(),
} as unknown) as ApplePaySession
} as unknown as ApplePaySession

const result = await loadApplePaySdk()
expect(result).toBe(true)
Expand All @@ -198,9 +199,9 @@ describe('loadApplePaySdk', () => {
it('loads the script successfully', async () => {
const logSpy = jest.spyOn(console, 'log').mockImplementation()
appendChildSpy.mockImplementation((script) => {
window.ApplePaySession = ({
window.ApplePaySession = {
begin: jest.fn(),
} as unknown) as ApplePaySession
} as unknown as ApplePaySession
script?.onload()
return script
})
Expand Down Expand Up @@ -244,9 +245,9 @@ describe('loadApplePaySdk', () => {

it('sets the correct script attributes', async () => {
appendChildSpy.mockImplementation((script) => {
window.ApplePaySession = ({
window.ApplePaySession = {
begin: jest.fn(),
} as unknown) as ApplePaySession
} as unknown as ApplePaySession
script?.onload()
return script
})
Expand Down
4 changes: 2 additions & 2 deletions packages/embed/src/apple-pay/browser-support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
} from './browser-support'

beforeEach(() => {
window.ApplePaySession = ({
window.ApplePaySession = {
canMakePayments: jest.fn(),
supportsVersion: jest.fn(),
} as unknown) as ApplePaySession
} as unknown as ApplePaySession
})

test('checks support for apple pay version 3', () => {
Expand Down
8 changes: 5 additions & 3 deletions packages/embed/src/form/form.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ describe('createFormController', () => {
jest.runAllTimers()

expect(
(document.getElementsByName(
'gr4vy_transaction_id'
)[0] as HTMLInputElement).value
(
document.getElementsByName(
'gr4vy_transaction_id'
)[0] as HTMLInputElement
).value
).toBe('123')
})

Expand Down
Loading