Skip to content

Commit 24b4b63

Browse files
ESLint configuration, apply prettier rules (#121)
* fix: linter config * chore: prettier auto fix
1 parent c323f86 commit 24b4b63

22 files changed

+199
-202
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
},
1616
plugins: [
1717
'unicorn',
18+
'prettier',
1819
'@typescript-eslint',
1920
'unused-imports',
2021
'tailwindcss',
@@ -38,6 +39,7 @@ module.exports = {
3839
'.eslintrc.js',
3940
],
4041
rules: {
42+
"prettier/prettier": "error",
4143
'import/no-duplicates': 'error',
4244
'@typescript-eslint/no-explicit-any': 'error',
4345
'unicorn/filename-case': [
@@ -113,6 +115,7 @@ module.exports = {
113115
files: ['src/translations/*.json'],
114116
extends: ['plugin:i18n-json/recommended'],
115117
rules: {
118+
"@typescript-eslint/ban-types": "off",
116119
'i18n-json/valid-message-syntax': [
117120
2,
118121
{
@@ -146,7 +149,7 @@ module.exports = {
146149
{
147150
// Configuration for testing files
148151
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
149-
extends: ['plugin:testing-library/react'],
152+
extends: ['plugin:testing-library/react', "prettier"],
150153
},
151154
],
152155
};

src/api/common/utils.spec.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,21 @@ describe('toCamelCase with nested objects', () => {
8585
});
8686

8787
describe('toSnakeCase with nested objects', () => {
88-
8988
it('should convert to snake_case only camelCase keys', () => {
90-
const obj = { user: {
91-
fooBar: 'foo',
92-
barBaz: 'bar',
93-
foo_bar: 'foo',
94-
bar_baz: 'bar',
95-
}};
96-
const expected = { user: {
97-
foo_bar: 'foo',
98-
bar_baz: 'bar',
99-
}}
89+
const obj = {
90+
user: {
91+
fooBar: 'foo',
92+
barBaz: 'bar',
93+
foo_bar: 'foo',
94+
bar_baz: 'bar',
95+
},
96+
};
97+
const expected = {
98+
user: {
99+
foo_bar: 'foo',
100+
bar_baz: 'bar',
101+
},
102+
};
100103
expect(toSnakeCase(obj)).toEqual(expected);
101104
});
102105
});
@@ -124,7 +127,7 @@ describe('getUrlParameters', () => {
124127

125128
it('should handle special characters in the URL parameters', () => {
126129
const result = getUrlParameters(
127-
'https://example.com?name=John%20Doe&city=New%20York'
130+
'https://example.com?name=John%20Doe&city=New%20York',
128131
);
129132
expect(result).toEqual({ name: 'John Doe', city: 'New York' });
130133
});

src/api/common/utils.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ export const getNextPageParam: GetPreviousPageParamFunction<
4949
type GenericObject = { [key: string]: unknown };
5050

5151
function isGenericObject(value: unknown): value is GenericObject {
52-
return typeof value === "object" && value !== null && !Array.isArray(value);
52+
return typeof value === 'object' && value !== null && !Array.isArray(value);
5353
}
5454

5555
export const toCamelCase = (obj: GenericObject): GenericObject => {
5656
const newObj: GenericObject = {};
5757
for (const key in obj) {
5858
if (Object.hasOwn(obj, key)) {
5959
const newKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
60-
const value = obj[key]
60+
const value = obj[key];
6161
if (isGenericObject(value)) {
6262
newObj[newKey] = toCamelCase(value);
6363
} else {
@@ -68,14 +68,16 @@ export const toCamelCase = (obj: GenericObject): GenericObject => {
6868
return newObj;
6969
};
7070

71-
const camelToSnake = (key: string): string => key.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
71+
const camelToSnake = (key: string): string =>
72+
key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
7273

7374
export const toSnakeCase = (obj: GenericObject): GenericObject => {
7475
const newObj: GenericObject = {};
75-
76+
7677
for (const [key, value] of Object.entries(obj)) {
7778
const newKey = camelToSnake(key);
78-
newObj[newKey] = isGenericObject(value) && value !== null ? toSnakeCase(value) : value;
79+
newObj[newKey] =
80+
isGenericObject(value) && value !== null ? toSnakeCase(value) : value;
7981
}
8082
return newObj;
8183
};

src/components/buttons.tsx

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,32 @@ import { Button, View } from '@/ui';
33
import { Title } from './title';
44

55
export const Buttons = () => (
6-
<>
7-
<Title text="Buttons" />
8-
<View>
9-
<View className="flex-row flex-wrap">
10-
<Button label="small" size="sm" className="mr-2" />
11-
<Button
12-
label="small"
13-
loading
14-
size="sm"
15-
className="mr-2 min-w-[60px]"
16-
/>
17-
<Button
18-
label="small"
19-
size="sm"
20-
variant="secondary"
21-
className="mr-2"
22-
/>
23-
<Button label="small" size="sm" variant="outline" className="mr-2" />
24-
<Button
25-
label="small"
26-
size="sm"
27-
variant="destructive"
28-
className="mr-2"
29-
/>
30-
<Button label="small" size="sm" variant="ghost" className="mr-2" />
31-
<Button label="small" size="sm" disabled className="mr-2" />
32-
</View>
33-
<Button label="Default Button" />
34-
<Button label="Secondary Button" variant="secondary" />
35-
<Button label="Outline Button" variant="outline" />
36-
<Button label="Destructive Button" variant="destructive" />
37-
<Button label="Ghost Button" variant="ghost" />
38-
<Button label="Button" loading={true} />
39-
<Button label="Button" loading={true} variant="outline" />
40-
<Button label="Default Button Disabled" disabled />
6+
<>
7+
<Title text="Buttons" />
8+
<View>
9+
<View className="flex-row flex-wrap">
10+
<Button label="small" size="sm" className="mr-2" />
11+
<Button label="small" loading size="sm" className="mr-2 min-w-[60px]" />
12+
<Button label="small" size="sm" variant="secondary" className="mr-2" />
13+
<Button label="small" size="sm" variant="outline" className="mr-2" />
4114
<Button
42-
label="Secondary Button Disabled"
43-
disabled
44-
variant="secondary"
15+
label="small"
16+
size="sm"
17+
variant="destructive"
18+
className="mr-2"
4519
/>
20+
<Button label="small" size="sm" variant="ghost" className="mr-2" />
21+
<Button label="small" size="sm" disabled className="mr-2" />
4622
</View>
47-
</>
48-
);
23+
<Button label="Default Button" />
24+
<Button label="Secondary Button" variant="secondary" />
25+
<Button label="Outline Button" variant="outline" />
26+
<Button label="Destructive Button" variant="destructive" />
27+
<Button label="Ghost Button" variant="ghost" />
28+
<Button label="Button" loading={true} />
29+
<Button label="Button" loading={true} variant="outline" />
30+
<Button label="Default Button Disabled" disabled />
31+
<Button label="Secondary Button Disabled" disabled variant="secondary" />
32+
</View>
33+
</>
34+
);

src/components/colors.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Title } from './title';
55
type ColorName = keyof typeof colors;
66

77
export const Colors = () => (
8-
<>
9-
<Title text="Colors" />
10-
{(Object.keys(colors) as ColorName[]).map((name) => (
11-
<Color name={name} key={name} />
12-
))}
13-
</>
14-
);
8+
<>
9+
<Title text="Colors" />
10+
{(Object.keys(colors) as ColorName[]).map((name) => (
11+
<Color name={name} key={name} />
12+
))}
13+
</>
14+
);
1515

1616
const Color = ({ name }: { name: ColorName }) => {
1717
if (typeof colors[name] === 'string') {
@@ -22,23 +22,19 @@ const Color = ({ name }: { name: ColorName }) => {
2222
<Text className="font-medium">{name.toUpperCase()}</Text>
2323
<View className="flex-row flex-wrap content-between justify-around ">
2424
{Object.entries(colors[name]).map(([key, value]) => (
25-
<ColorCard
26-
key={`${colors[name]}-${key}`}
27-
value={key}
28-
color={value}
29-
/>
30-
))}
25+
<ColorCard key={`${colors[name]}-${key}`} value={key} color={value} />
26+
))}
3127
</View>
3228
</View>
3329
);
3430
};
3531

3632
const ColorCard = ({ color, value }: { value: string; color: string }) => (
37-
<View className="flex-1">
38-
<View
39-
className="h-14 w-full rounded-sm"
40-
style={{ backgroundColor: color }}
41-
/>
42-
<Text className="text-sm">{value}</Text>
43-
</View>
44-
);
33+
<View className="flex-1">
34+
<View
35+
className="h-14 w-full rounded-sm"
36+
style={{ backgroundColor: color }}
37+
/>
38+
<Text className="text-sm">{value}</Text>
39+
</View>
40+
);

src/components/settings/theme-item.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ThemeItem = () => {
1616
setSelectedTheme(option.value as ColorSchemeType);
1717
modal.dismiss();
1818
},
19-
[setSelectedTheme, modal]
19+
[setSelectedTheme, modal],
2020
);
2121

2222
const themes = useMemo(
@@ -25,12 +25,12 @@ export const ThemeItem = () => {
2525
{ label: `${translate('settings.theme.light')} 🌞`, value: 'light' },
2626
{ label: `${translate('settings.theme.system')} ⚙️`, value: 'system' },
2727
],
28-
[]
28+
[],
2929
);
3030

3131
const theme = useMemo(
3232
() => themes.find((t) => t.value === selectedTheme),
33-
[selectedTheme, themes]
33+
[selectedTheme, themes],
3434
);
3535

3636
return (

src/components/title.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ type Props = {
44
text: string;
55
};
66
export const Title = ({ text }: Props) => (
7-
<View className="flex-row items-center justify-center py-4 pb-2">
8-
<Text className="pr-2 text-2xl">{text}</Text>
9-
<View className="h-[2px] flex-1 bg-neutral-300" />
10-
</View>
11-
);
7+
<View className="flex-row items-center justify-center py-4 pb-2">
8+
<Text className="pr-2 text-2xl">{text}</Text>
9+
<View className="h-[2px] flex-1 bg-neutral-300" />
10+
</View>
11+
);

src/components/typography.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ import { Text, View } from '@/ui';
33
import { Title } from './title';
44

55
export const Typography = () => (
6-
<>
7-
<Title text="Typography" />
8-
<View className="mb-4 flex-col">
9-
<Text className="text-3xl tracking-tight">
10-
H1: Lorem ipsum dolor sit
11-
</Text>
12-
<Text className="text-2xl ">H2: Lorem ipsum dolor sit</Text>
13-
<Text className="text-xl ">H3: Lorem ipsum dolor sit</Text>
14-
<Text className="text-lg ">H4: Lorem ipsum dolor sit</Text>
15-
<Text className="text-base">
16-
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Cumque quasi
17-
aut, expedita tempore ratione quidem in, corporis quia minus et
18-
dolorem sunt temporibus iusto consequatur culpa. Omnis sequi debitis
19-
recusandae?
20-
</Text>
21-
</View>
22-
</>
23-
);
6+
<>
7+
<Title text="Typography" />
8+
<View className="mb-4 flex-col">
9+
<Text className="text-3xl tracking-tight">
10+
H1: Lorem ipsum dolor sit
11+
</Text>
12+
<Text className="text-2xl ">H2: Lorem ipsum dolor sit</Text>
13+
<Text className="text-xl ">H3: Lorem ipsum dolor sit</Text>
14+
<Text className="text-lg ">H4: Lorem ipsum dolor sit</Text>
15+
<Text className="text-base">
16+
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Cumque quasi
17+
aut, expedita tempore ratione quidem in, corporis quia minus et dolorem
18+
sunt temporibus iusto consequatur culpa. Omnis sequi debitis recusandae?
19+
</Text>
20+
</View>
21+
</>
22+
);

src/core/hooks/use-selected-theme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const useSelectedTheme = () => {
2222
setColorScheme(t);
2323
_setTheme(t);
2424
},
25-
[setColorScheme, _setTheme]
25+
[setColorScheme, _setTheme],
2626
);
2727

2828
const selectedTheme = (theme ?? 'system') as ColorSchemeType;

src/core/i18n/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { I18nManager } from 'react-native';
66
import { resources } from './resources';
77
export * from './utils';
88

9-
const locales = getLocales()
9+
const locales = getLocales();
1010

1111
i18n.use(initReactI18next).init({
1212
resources,

0 commit comments

Comments
 (0)