Skip to content

Commit

Permalink
feat:Resolved typescript fixes for components
Browse files Browse the repository at this point in the history
  • Loading branch information
112schauhan committed Jan 22, 2025
1 parent 387dae4 commit e79373d
Show file tree
Hide file tree
Showing 60 changed files with 5,159 additions and 3,802 deletions.
86 changes: 46 additions & 40 deletions src/web/.eslintrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
env: {
browser: true,
Expand All @@ -28,7 +29,9 @@ module.exports = {
version: 'detect',
},
'import/resolver': {
typescript: {},
typescript: {
project: './tsconfig.json',
},
},
},
extends: [
Expand All @@ -41,19 +44,17 @@ module.exports = {
'plugin:import/warnings',
'plugin:import/typescript',
],
plugins: [
'@typescript-eslint',
'react',
'react-hooks',
'import',
],
plugins: ['@typescript-eslint', 'react', 'react-hooks', 'import'],
rules: {
// TypeScript specific rules
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
}],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
Expand All @@ -62,9 +63,12 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/consistent-type-imports': ['error', {
prefer: 'type-imports',
}],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
},
],

// React specific rules
'react/react-in-jsx-scope': 'off',
Expand All @@ -84,20 +88,16 @@ module.exports = {
'react-hooks/exhaustive-deps': 'warn',

// Import/Export rules
'import/order': ['error', {
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
},
},
}],
],
'import/no-unresolved': 'error',
'import/no-cycle': 'error',
'import/no-unused-modules': 'error',
Expand All @@ -108,23 +108,29 @@ module.exports = {
'import/no-useless-path-segments': 'error',

// General code style rules
'no-console': ['warn', {
allow: ['warn', 'error'],
}],
'no-console': [
'warn',
{
allow: ['warn', 'error'],
},
],
'no-debugger': 'error',
'no-alert': 'error',
'no-var': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'eqeqeq': ['error', 'always'],
'curly': ['error', 'all'],
'max-len': ['error', {
code: 100,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
}],
eqeqeq: ['error', 'always'],
curly: ['error', 'all'],
'max-len': [
'error',
{
code: 100,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
},
overrides: [
{
Expand All @@ -138,4 +144,4 @@ module.exports = {
},
},
],
};
};
100 changes: 100 additions & 0 deletions src/web/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import importPlugin from 'eslint-plugin-import';

export default tseslint.config(
{
files: ['src/**/*.ts', 'src/**/*.tsx'],
ignores: ['**/node_modules/**', 'build/**', 'dist/**'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
import: importPlugin,
},
rules: {
// TypeScript rules
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',

// Import rules
'import/no-unresolved': 'error',
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
},
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
},
},
],
'import/no-cycle': 'error',
'import/no-self-import': 'error',
'import/no-useless-path-segments': 'error',

// React rules
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

// General rules
'no-console': ['warn', { allow: ['error'] }],
'no-debugger': 'error',
'no-alert': 'error',
'max-len': [
'error',
{
code: 100,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
},
},
eslintConfigPrettier
);
10 changes: 9 additions & 1 deletion src/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@fontsource/inter": "^4.5.0",
"@mui/icons-material": "^5.0.0",
"@mui/material": "^5.0.0",
"@react-aria/i18n": "^3.0.0",
"@react-aria/interactions": "^3.15.0",
"@reduxjs/toolkit": "^1.9.5",
"@sentry/browser": "^8.50.0",
Expand All @@ -36,6 +35,7 @@
"deepmerge": "^4.3.1",
"file-saver": "^2.0.5",
"lodash": "^4.17.21",
"node-cache": "^5.1.2",
"process": "^0.11.10",
"react": "^18.2.0",
"react-chartjs-2": "5.0.0",
Expand All @@ -55,19 +55,25 @@
"@babel/preset-env": "^7.26.0",
"@jest/globals": "^29.3.1",
"@jest/types": "^29.0.0",
"@react-aria/i18n": "^3.12.5",
"@react-aria/live-announcer": "^3.4.1",
"@segment/analytics-next": "^1.76.1",
"@sentry/react": "^8.50.0",
"@sentry/replay": "^7.116.0",
"@sentry/tracing": "^7.120.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.0.0",
"@types/crypto-js": "^4.2.2",
"@types/file-saver": "^2.0.7",
"@types/gapi": "0.0.44",
"@types/lodash": "^4.17.14",
"@types/react-dom": "^19.0.3",
"@types/sanitize-html": "^2.13.0",
"@types/segment-analytics": "^0.0.38",
"@types/styled-components": "^5.1.34",
"@types/validator": "^13.12.2",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@vitejs/plugin-react": "^4.0.0",
Expand All @@ -80,6 +86,7 @@
"eslint-plugin-import": "^2.27.0",
"eslint-plugin-react": "^7.32.0",
"eslint-plugin-react-hooks": "^4.6.0",
"focus-trap-react": "^11.0.3",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-performance": "^1.0.0",
Expand All @@ -89,6 +96,7 @@
"ts-jest": "^29.0.5",
"typescript": "^4.9.0",
"typescript-eslint": "^8.21.0",
"validator": "^13.12.0",
"vite": "^4.0.0",
"vite-tsconfig-paths": "^4.0.0",
"vitest": "^0.34.0",
Expand Down
Loading

0 comments on commit e79373d

Please sign in to comment.