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

This file was deleted.

7 changes: 5 additions & 2 deletions __tests__/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ export const getDefaultLoadOptions = () => ({

export const createWrapper =
(providerProps: Partial<FingerprintProviderOptions> = {}) =>
({ children }: PropsWithChildren<{}>) => (
({ children }: PropsWithChildren<object>) => (
<FingerprintProvider {...getDefaultLoadOptions()} {...providerProps}>
{children}
</FingerprintProvider>
)

export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
export const wait = (ms: number) =>
new Promise<void>((resolve) => {
setTimeout(resolve, ms)
})

export const actWait = async (ms: number) => {
await act(async () => {
Expand Down
3 changes: 3 additions & 0 deletions __tests__/use-visitor-data.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ describe('useVisitorData', () => {
await actWait(1000)

act(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
userEvent.click(container.querySelector('button')!)
})

Expand Down Expand Up @@ -293,6 +294,7 @@ describe('useVisitorData', () => {
)

await act(async () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
await userEvent.click(container.querySelector('button')!)
})

Expand All @@ -303,6 +305,7 @@ describe('useVisitorData', () => {
// in between renders if this click were in the previous act block.
// This ensures that the case is covered where the options
// object does not semantically change.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
await userEvent.click(container.querySelector('button')!)
})

Expand Down
4 changes: 2 additions & 2 deletions __tests__/with-environment.preact.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ describe('WithEnvironment', () => {
})
it('should detect env as "preact"', async () => {
const { WithEnvironment } = await import('../src/components/with-environment')
const PrintEnv = (props: any) => h('div', null, props?.env?.name)
const PrintEnv = (props: { env?: { name: string } }) => h('div', null, props?.env?.name)

// @ts-ignore
// @ts-expect-error -- preact's render signature does not match React's @testing-library/react types
const { container } = preactRender(h(WithEnvironment, null, h(PrintEnv, null)))

expect(container.innerHTML).toContain('preact')
Expand Down
3 changes: 2 additions & 1 deletion __tests__/with-environment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { describe, it, expect, vi } from 'vitest'

describe('WithEnvironment', () => {
it('enhances provided element with `env` prop', () => {
const Mock = vi.fn(() => <div>foo</div>) as FunctionComponent
const Mock: FunctionComponent = vi.fn(() => <div>foo</div>)

render(
<WithEnvironment>
Expand Down Expand Up @@ -56,6 +56,7 @@ describe('WithEnvironment', () => {
)

act(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
userEvent.click(container.querySelector('#test')!)
})

Expand Down
35 changes: 35 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { includeIgnoreFile } from 'eslint/config'
import path from 'path'
import { fileURLToPath } from 'url'
import cfg from '@fingerprintjs/eslint-config-dx-team'
import tseslint from 'typescript-eslint'
import nextConfig from 'eslint-config-next/core-web-vitals'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

const config = [
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
{ ignores: ['examples/'] },
...cfg,
...nextConfig,
// eslint-config-next overrides the parser to @babel/eslint-parser for all files, then
// restores @typescript-eslint/parser only for .ts/.tsx. Re-apply it here for .js files
// so that the ESLint v10-compatible scope manager is used everywhere.
{
files: ['**/*.{js,mjs,cjs,jsx}'],
languageOptions: { parser: tseslint.parser },
},
{
settings: {
react: { version: '18.2' },
},
rules: {
'react/display-name': 'off',
'react/self-closing-comp': ['error', { component: true, html: true }],
'react/react-in-jsx-scope': 'off',
'@next/next/no-html-link-for-pages': 'off',
},
},
]

export default config
20 changes: 0 additions & 20 deletions examples/preact/.eslintrc.js

This file was deleted.

29 changes: 29 additions & 0 deletions examples/preact/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import { fileURLToPath } from 'url'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

const config = [
{ ignores: ['build/'] },
...compat.extends('preact'),
...tseslint.configs.recommended,
{
rules: {
semi: ['error', 'never'],
'linebreak-style': ['error', 'unix'],
'prefer-const': 'error',
'@typescript-eslint/no-unused-vars': ['error'],
curly: [2, 'all'],
},
},
]

export default config
6 changes: 3 additions & 3 deletions examples/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
"build": "preact build --no-sw",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch --no-sw",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'"
"lint": "eslint --max-warnings 0"
},
"dependencies": {
"@fingerprint/react": "workspace:*",
"preact": "10.19.6",
"preact-render-to-string": "^6.4.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "*",
"@typescript-eslint/parser": "*",
"eslint": "*",
"eslint-config-preact": "*",
"typescript": "*"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"typescript-eslint": "^8.60.0",
"dotenv": "^16.4.5",
"preact-cli": "^3.5.1",
"sirv-cli": "^2.0.2"
Expand Down
1 change: 0 additions & 1 deletion examples/preact/preact.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import dotenv from 'dotenv'

dotenv.config()

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default (config, env, helpers) => {
const { plugin } = helpers.getPluginsByName(config, 'DefinePlugin')[0]
plugin.definitions['process.env.PREACT_APP_FPJS_PUBLIC_API_KEY'] = JSON.stringify(
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"watch": "vite build --watch",
"build": "vite build",
"start:spa": "pnpm start --prefix=examples/spa",
"lint": "eslint --ext .js,.ts,.tsx --ignore-path .gitignore --max-warnings 0 .",
"lint": "eslint --max-warnings 0",
"lint:fix": "pnpm lint --fix",
"test": "vitest",
"test:coverage": "vitest run --coverage",
Expand Down Expand Up @@ -67,7 +67,7 @@
"@commitlint/cli": "^19.2.0",
"@fingerprintjs/changesets-changelog-format": "^0.2.0",
"@fingerprintjs/commit-lint-dx-team": "^0.0.2",
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^2.0.0",
"@fingerprintjs/prettier-config-dx-team": "^0.2.0",
"@fingerprintjs/tsconfig-dx-team": "^0.0.2",
"@testing-library/preact": "^3.2.4",
Expand All @@ -77,12 +77,13 @@
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitest/coverage-istanbul": "^4.0.18",
"eslint": "8.57.0",
"eslint-config-next": "14.1.3",
"eslint": "^10.4.1",
"eslint-config-next": "^16.2.0",
"@eslint/eslintrc": "^3.0.0",
"typescript-eslint": "^8.60.0",
"eslint-config-preact": "^1.3.0",
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-react": "7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.37.0",
"eslint-plugin-react-hooks": "^7.0.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"preact": "^10.19.6",
Expand Down
Loading
Loading