-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
169 additions
and
121 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; | ||
import react from 'eslint-plugin-react'; | ||
import typescriptEslint from '@typescript-eslint/eslint-plugin'; | ||
import regex from 'eslint-plugin-regex'; | ||
import lodash from 'eslint-plugin-lodash'; | ||
import globals from 'globals'; | ||
import tsParser from '@typescript-eslint/parser'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import js from '@eslint/js'; | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import testingLibrary from 'eslint-plugin-testing-library'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
export default [ | ||
{ | ||
ignores: ['public', 'src/serviceWorker.js', '**/eslint.config.mjs', 'dist'], | ||
}, | ||
...fixupConfigRules( | ||
compat.extends( | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
'prettier', | ||
), | ||
), | ||
{ | ||
plugins: { | ||
react: fixupPluginRules(react), | ||
'@typescript-eslint': fixupPluginRules(typescriptEslint), | ||
regex, | ||
lodash, | ||
'testing-library': fixupPluginRules({ | ||
rules: testingLibrary.rules, | ||
}), | ||
}, | ||
|
||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
}, | ||
|
||
parser: tsParser, | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
|
||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
|
||
project: './tsconfig.json', | ||
}, | ||
}, | ||
|
||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
|
||
rules: { | ||
'lodash/import-scope': 'error', | ||
|
||
'regex/required': [ | ||
'error', | ||
[ | ||
{ | ||
regex: 'describe.+from.+vitest', | ||
message: 'Import `describe` explicitly.', | ||
|
||
files: { | ||
inspect: '\\.(test|spec)\\.tsx?$', | ||
}, | ||
}, | ||
{ | ||
regex: 'it.+from.+vitest', | ||
message: 'Import `it` explicitly.', | ||
|
||
files: { | ||
inspect: '\\.(test|spec)\\.tsx?$', | ||
}, | ||
}, | ||
{ | ||
regex: 'expect.+from.+vitest', | ||
message: 'Import `expect` explicitly.', | ||
|
||
files: { | ||
inspect: '\\.(test|spec)\\.tsx?$', | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
{ | ||
files: [ | ||
'**/*.spec.ts', | ||
'**/*.spec.tsx', | ||
'**/__mocks__/**/*', | ||
'**/__tests__/**/*', | ||
'**/global-setup.ts', | ||
'src/lib/test/**/*', | ||
], | ||
|
||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
import { QueryObserverResult, useQuery } from 'react-query'; | ||
import { UseQueryOptions } from 'react-query'; | ||
import { useEffect } from 'react'; | ||
import { User, getMe } from '@taskratchet/sdk'; | ||
|
||
export function useMe( | ||
queryOptions: UseQueryOptions<User> | undefined = {}, | ||
): QueryObserverResult<User, unknown> { | ||
const result = useQuery({ | ||
return useQuery({ | ||
queryKey: 'me', | ||
queryFn: getMe, | ||
...queryOptions, | ||
}); | ||
|
||
const { data } = result; | ||
|
||
useEffect(() => { | ||
if (!data) return; | ||
|
||
const metadata = Object.keys(data).reduce( | ||
(prev, key) => { | ||
const value = data[key as keyof User]; | ||
|
||
prev[key] = typeof value === 'string' ? value : JSON.stringify(value); | ||
|
||
return prev; | ||
}, | ||
{} as Record<string, string>, | ||
); | ||
}, [data]); | ||
|
||
return result; | ||
} |
Oops, something went wrong.