Skip to content

Commit

Permalink
Merge pull request #139 from fingerprintjs/use-reusable-configs
Browse files Browse the repository at this point in the history
Apply reusable configs, migrate to pnpm
  • Loading branch information
ilfa authored Jan 29, 2024
2 parents 9ef2475 + 2206d67 commit 2692fc7
Show file tree
Hide file tree
Showing 28 changed files with 17,333 additions and 33,965 deletions.
23 changes: 2 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
ignorePatterns: ['dist/', 'build/'],
extends: [
'next/core-web-vitals',
'@fingerprintjs/eslint-config-dx-team',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:react-hooks/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020,
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
plugins: ['@typescript-eslint', 'prettier'],
ignorePatterns: ['build/*'],
rules: {
semi: ['error', 'never'],
'linebreak-style': ['error', 'unix'],
'react/display-name': 'off',
'prefer-const': 'error',
'react/self-closing-comp': [
'error',
{
Expand All @@ -42,9 +26,6 @@ module.exports = {
},
],
'react/react-in-jsx-scope': 'off',
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': ['error'],
'@next/next/no-html-link-for-pages': 'off',
curly: [2, 'all'],
},
}
13 changes: 1 addition & 12 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always"
}
"@fingerprintjs/prettier-config-dx-team"
85 changes: 3 additions & 82 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -10,93 +10,14 @@
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{
"type": "build",
"scope": "deps",
"release": "patch"
},
{
"type": "docs",
"scope": "README",
"release": "patch"
}
]
"config": "@fingerprintjs/conventional-changelog-dx-team",
"releaseRules": "@fingerprintjs/conventional-changelog-dx-team/release-rules"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalCommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "feature",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "docs",
"scope": "README",
"section": "Documentation"
},
{
"type": "build",
"scope": "deps",
"section": "Build System"
},
{
"type": "docs",
"section": "Documentation",
"hidden": true
},
{
"type": "style",
"section": "Styles",
"hidden": true
},
{
"type": "chore",
"section": "Miscellaneous Chores",
"hidden": true
},
{
"type": "refactor",
"section": "Code Refactoring",
"hidden": true
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System",
"hidden": true
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
]
}
"config": "@fingerprintjs/conventional-changelog-dx-team"
}
],
"@semantic-release/changelog",
Expand Down
11 changes: 5 additions & 6 deletions __tests__/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export const getDefaultLoadOptions = () => ({

export const createWrapper =
({ loadOptions = getDefaultLoadOptions(), ...options }: Partial<FpjsClientOptions> = {}) =>
({ children }: PropsWithChildren<{}>): JSX.Element =>
(
<FpjsProvider loadOptions={loadOptions} {...options}>
{children}
</FpjsProvider>
)
({ children }: PropsWithChildren<{}>): JSX.Element => (
<FpjsProvider loadOptions={loadOptions} {...options}>
{children}
</FpjsProvider>
)

export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))

Expand Down
8 changes: 4 additions & 4 deletions __tests__/use-visitor-data.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { actWait, createWrapper } from './helpers'
import { act } from 'react-dom/test-utils'
import { useState } from 'react'
import userEvent from '@testing-library/user-event'
import { ERROR_CLIENT_TIMEOUT } from '@fingerprintjs/fingerprintjs-pro'
import { FingerprintJSPro } from '@fingerprintjs/fingerprintjs-pro-spa'

const testData = {
visitorId: 'abcdef123456',
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('useVisitorData', () => {
})

it('should correctly pass errors from SPA library', async () => {
getVisitorData.mockRejectedValue(new Error(ERROR_CLIENT_TIMEOUT))
getVisitorData.mockRejectedValue(new Error(FingerprintJSPro.ERROR_CLIENT_TIMEOUT))

const wrapper = createWrapper()
const hook = renderHook(() => useVisitorData({ ignoreCache: true }, { immediate: false }), { wrapper })
Expand All @@ -148,10 +148,10 @@ describe('useVisitorData', () => {
ignoreCache: false,
})

await expect(promise).rejects.toThrow(ERROR_CLIENT_TIMEOUT)
await expect(promise).rejects.toThrow(FingerprintJSPro.ERROR_CLIENT_TIMEOUT)
})

expect(hook.result.current.error?.message).toBe(ERROR_CLIENT_TIMEOUT)
expect(hook.result.current.error?.message).toBe(FingerprintJSPro.ERROR_CLIENT_TIMEOUT)
})

it('`getVisitorData` `getOptions` should be passed from `getVisitorData` `getOptions`', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/with-environment.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent } from 'react'
import { FunctionComponent } from 'react'
import { act, render } from '@testing-library/react'
import { WithEnvironment } from '../src/components/with-environment'
import { Link, MemoryRouter, Route, Routes } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
module.exports = { extends: ['@fingerprintjs/commit-lint-dx-team'] }
20 changes: 7 additions & 13 deletions examples/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@fingerprintjs/fingerprintjs-pro-react": "link:../../",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"react": "link:../../node_modules/react",
"react-dom": "link:../../node_modules/react-dom",
"@fingerprintjs/fingerprintjs-pro-react": "workspace:*",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.1",
"typescript": "^4.4.2"
"react-scripts": "5.0.1"
},
"peerDependencies": {
"react": "*",
"react-dom": "*",
"typescript": "*"
},
"scripts": {
"start": "PORT=3001 DISABLE_ESLINT_PLUGIN=true react-scripts start",
Expand Down
Loading

0 comments on commit 2692fc7

Please sign in to comment.