Skip to content

Commit 46cc2ea

Browse files
committed
refactor: added tseslint config and added some typescript
1 parent 892fed1 commit 46cc2ea

File tree

12 files changed

+482
-147
lines changed

12 files changed

+482
-147
lines changed

eslint.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import babelParser from '@babel/eslint-parser';
22
import js from '@eslint/js';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
34
import react from 'eslint-plugin-react';
45
import reactHooks from 'eslint-plugin-react-hooks';
56
import reactRefresh from 'eslint-plugin-react-refresh';
67
import globals from 'globals';
8+
import tseslint from 'typescript-eslint';
79

810
export default [
911
js.configs.recommended,
@@ -48,4 +50,28 @@ export default [
4850
'react-refresh/only-export-components': ['off'],
4951
},
5052
},
53+
...tseslint.configs.recommendedTypeChecked.map((config) => ({
54+
...config,
55+
files: ['src/**/*.{ts,tsx}'], // We use TS config only for TS files
56+
})),
57+
{
58+
files: ['src/**/*.{ts,tsx}'],
59+
60+
// This is required, see the docs
61+
languageOptions: {
62+
parserOptions: {
63+
project: './tsconfig.app.json',
64+
},
65+
},
66+
67+
// This is needed in order to specify the desired behavior for its rules
68+
plugins: {
69+
'@typescript-eslint': tsPlugin,
70+
},
71+
72+
// After defining the plugin, you can use the rules like this
73+
rules: {
74+
'@typescript-eslint/no-unused-vars': 'error',
75+
},
76+
},
5177
];

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,22 @@
9191
"@testing-library/user-event": "^14.5.2",
9292
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
9393
"@types/enzyme": "^3.10.18",
94+
"@types/lodash.clonedeep": "^4.5.9",
95+
"@types/lodash.debounce": "^4.0.9",
96+
"@types/lodash.find": "^4.6.9",
97+
"@types/lodash.get": "^4.4.9",
98+
"@types/lodash.maxby": "^4.6.9",
99+
"@types/lodash.merge": "^4.6.9",
100+
"@types/lodash.sortby": "^4.7.9",
101+
"@types/lodash.takeright": "^4.1.9",
102+
"@types/lodash.takewhile": "^4.6.9",
103+
"@types/lodash.uniq": "^4.5.9",
94104
"@types/node": "^22.7.3",
95105
"@types/react": "^18.2.9",
96106
"@types/react-dom": "^18.2.0",
107+
"@types/react-redux": "^7.1.34",
97108
"@types/react-router-dom": "^5.3.3",
109+
"@typescript-eslint/eslint-plugin": "^8.18.0",
98110
"@vitejs/plugin-react": "^4.2.1",
99111
"@vitest/coverage-v8": "^2.0.0",
100112
"bootstrap-sass": "3.4.1",
@@ -103,8 +115,8 @@
103115
"enzyme-adapter-react-16": "^1.14.0",
104116
"eslint": "^9.15.0",
105117
"eslint-plugin-react": "^7.37.2",
106-
"eslint-plugin-react-hooks": "^5.0.0",
107-
"eslint-plugin-react-refresh": "^0.4.14",
118+
"eslint-plugin-react-hooks": "^5.1.0",
119+
"eslint-plugin-react-refresh": "^0.4.16",
108120
"font-awesome": "4.7.0",
109121
"globals": "^15.12.0",
110122
"husky": "^9.1.7",
@@ -119,9 +131,10 @@
119131
"sass": "1.32.13",
120132
"shx": "^0.3.3",
121133
"typescript": "^5.7.2",
122-
"vite": "^5.0.8",
134+
"typescript-eslint": "^8.10.0",
135+
"vite": "^5.4.9",
123136
"vite-tsconfig-paths": "^5.1.4",
124-
"vitest": "^2.0.0"
137+
"vitest": "^2.1.2"
125138
},
126139
"lint-staged": {
127140
"*.{js,jsx,ts,tsx}": [

src/forms/controls/generic-option.jsx

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
interface GenericOptionProps {
2+
value: string;
3+
children: string;
4+
className?: string;
5+
}
6+
7+
function GenericOption({
8+
value,
9+
children,
10+
className = '',
11+
}: Readonly<GenericOptionProps>) {
12+
return (
13+
<div data-value={value} className={className}>
14+
{children}
15+
</div>
16+
);
17+
}
18+
19+
export default GenericOption;

tests/setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '@testing-library/jest-dom';
2+
import { cleanup } from '@testing-library/react';
3+
import { afterEach } from 'vitest';
4+
5+
afterEach(() => {
6+
cleanup();
7+
});
File renamed without changes.

vite.config.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import react from '@vitejs/plugin-react';
2-
import { resolve } from 'node:path';
32
import tsconfigPaths from 'vite-tsconfig-paths';
4-
import { defineConfig } from 'vitest/config';
53

64
// https://vite.dev/config/
7-
export default defineConfig({
5+
export default {
86
plugins: [
97
react(),
108
tsconfigPaths({
@@ -13,16 +11,4 @@ export default defineConfig({
1311
],
1412
}),
1513
],
16-
define: {
17-
global: 'window',
18-
},
19-
test: {
20-
include: ['**/*.spec.jsx'],
21-
globals: true,
22-
environment: 'jsdom',
23-
setupFiles: ['./src/setupTests.ts'],
24-
coverage: {
25-
reporter: ['text', 'lcov'],
26-
},
27-
},
28-
});
14+
};

0 commit comments

Comments
 (0)