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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
],
plugins: ['unicorn', 'sonarjs'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'prettier/prettier': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
-Dsonar.sonar.sourceEncoding=UTF-8
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.coverage.exclusions=**/node_modules/**,**/storage/**,**/**.config.js,**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx,**/icons/**,**/docs/**,**/cli/**,**/android/**,**/ios/**,env.js
-Dsonar.exclusions=,**/__mocks__/**
-Dsonar.exclusions=**/docs/**,**/__mocks__/**
2 changes: 1 addition & 1 deletion scripts/i18next-syntax-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const validate = (message = '') => {
'Interpolation error. See: https://www.i18next.com/misc/json-format'
);
}
if (message.includes('$t(') && !/\$t\([\w]+:\w+(?:\.\w+)*\)/g.test(message)) {
if (message.includes('$t(') && !/\$t\(\w+:\w+(?:\.\w+)*\)/g.test(message)) {
throw new SyntaxError(
'Nesting error. See: https://www.i18next.com/misc/json-format'
);
Expand Down
2 changes: 1 addition & 1 deletion src/api/common/axios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare module 'axios' {
interface AxiosInterceptorManager<V> {
handlers: Array<{
fulfilled: ((value: V) => V | Promise<V>) | null;
rejected: ((error: any) => any) | null;
rejected: ((error: unknown) => unknown) | null;
synchronous: boolean;
runWhen: (config: InternalAxiosRequestConfig) => boolean | null;
}>;
Expand Down
4 changes: 2 additions & 2 deletions src/api/common/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
import type { PaginateQuery } from '../types';

type KeyParams = {
[key: string]: any;
[key: string]: unknown;
};
export const DEFAULT_LIMIT = 10;

Expand Down Expand Up @@ -46,7 +46,7 @@ export const getNextPageParam: GetPreviousPageParamFunction<
PaginateQuery<unknown>
> = (page) => getUrlParameters(page.next)?.offset ?? null;

type GenericObject = { [key: string]: any };
type GenericObject = { [key: string]: unknown };

export const toCamelCase = (obj: GenericObject): GenericObject => {
const newObj: GenericObject = {};
Expand Down
2 changes: 1 addition & 1 deletion src/core/i18n/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type RecursiveKeyOfInner<TObj extends object> = {
type RecursiveKeyOfHandleValue<
TValue,
Text extends string
> = TValue extends any[]
> = TValue extends unknown[]
? Text
: TValue extends object
? Text | `${Text}${RecursiveKeyOfInner<TValue>}`
Expand Down
4 changes: 2 additions & 2 deletions src/core/i18n/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export const useSelectedLanguage = () => {
(lang: Language) => {
setLang(lang);
if (lang !== undefined) {
changeLanguage(lang as Language);
changeLanguage(lang);
}
},
[setLang]
);

return { language: language as Language, setLanguage };
return { language: language, setLanguage };
};
12 changes: 8 additions & 4 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ type WithSelectors<S> = S extends { getState: () => infer T }
? S & { use: { [K in keyof T]: () => T[K] } }
: never;

export const createSelectors = <S extends UseBoundStore<StoreApi<object>>>(
export const createSelectors = <
T extends object,
S extends UseBoundStore<StoreApi<T>>
>(
_store: S
) => {
const store = _store as WithSelectors<typeof _store>;
store.use = {};
for (const k of Object.keys(store.getState())) {
(store.use as any)[k] = () => store((s) => s[k as keyof typeof s]);
store.use = {} as { [K in keyof T]: () => T[K] };

for (const k of Object.keys(store.getState()) as Array<keyof T>) {
store.use[k] = () => store((s) => s[k]);
}

return store;
Expand Down