Skip to content

Commit cab19dd

Browse files
authored
Refactor form field component props and tests for consistency (#28)
* Refactor form field component props and tests for consistency - Updated FormField component props to maintain consistent order of attributes. - Modified test cases for FormField to reflect the new prop order. - Changed FormFieldMessage and FormField model types from type to interface for better extensibility. - Adjusted imports and added missing imports in various components. - Updated SVG assets to ensure consistent class naming and structure. - Improved overall code readability and organization across multiple components. * fix: correct JSX syntax in FormFieldInput and update label format in tests
1 parent 02ab74f commit cab19dd

39 files changed

+804
-330
lines changed

.eslintignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
coverage/
2-
__tests__
2+
__tests__
3+
node_modules/
4+
dist/
5+
.github/
6+
.vscode/
7+
.husky/
8+
public/
9+
*.config.js
10+
*.config.ts
11+
*.d.ts
12+
vite-env.d.ts

.eslintrc.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// @ts-check
2+
import eslint from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
import reactPlugin from 'eslint-plugin-react';
5+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
6+
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
7+
import * as importPlugin from 'eslint-plugin-import';
8+
import securityPlugin from 'eslint-plugin-security';
9+
import sortKeysFixPlugin from 'eslint-plugin-sort-keys-fix';
10+
11+
export default tseslint.config(
12+
// Base ESLint recommended configuration
13+
eslint.configs.recommended,
14+
15+
// TypeScript ESLint recommended configuration
16+
...tseslint.configs.recommended,
17+
...tseslint.configs.stylistic,
18+
19+
// Ignore patterns (replaces .eslintignore)
20+
{
21+
ignores: [
22+
'node_modules/**',
23+
'dist/**',
24+
'coverage/**',
25+
'.github/**',
26+
'.vscode/**',
27+
'.husky/**',
28+
'public/**',
29+
'**/*.config.js',
30+
'**/*.config.ts',
31+
'**/*.d.ts',
32+
'vite-env.d.ts',
33+
'__tests__/**'
34+
]
35+
},
36+
37+
// Configure for React
38+
{
39+
files: ['**/*.{js,jsx,ts,tsx}'],
40+
plugins: {
41+
react: reactPlugin,
42+
'react-hooks': reactHooksPlugin,
43+
'jsx-a11y': jsxA11yPlugin,
44+
import: importPlugin,
45+
security: securityPlugin,
46+
'sort-keys-fix': sortKeysFixPlugin,
47+
},
48+
languageOptions: {
49+
ecmaVersion: 2022,
50+
sourceType: 'module',
51+
parserOptions: {
52+
ecmaFeatures: {
53+
jsx: true,
54+
},
55+
},
56+
},
57+
settings: {
58+
react: {
59+
version: 'detect',
60+
},
61+
'import/resolver': {
62+
typescript: {},
63+
},
64+
},
65+
rules: {
66+
// Disable problematic rules that cause circular dependencies
67+
'import/order': 'off',
68+
'import/no-duplicates': 'off',
69+
70+
// React rules
71+
'react/jsx-sort-props': 'off', // Disable for now to avoid circular fixes
72+
'react/jsx-runtime': 'off',
73+
'react/prop-types': 'off',
74+
'react/jsx-uses-react': 'off',
75+
'react/react-in-jsx-scope': 'off',
76+
77+
// React hooks rules - relaxed for now
78+
'react-hooks/rules-of-hooks': 'error',
79+
'react-hooks/exhaustive-deps': 'warn',
80+
81+
// Accessibility rules
82+
'jsx-a11y/alt-text': 'warn',
83+
'jsx-a11y/anchor-has-content': 'warn',
84+
'jsx-a11y/aria-props': 'warn',
85+
'jsx-a11y/aria-role': 'warn',
86+
'jsx-a11y/aria-unsupported-elements': 'warn',
87+
88+
// Sort keys rules - relaxed to avoid circular issues
89+
'sort-keys': 'off',
90+
'sort-keys-fix/sort-keys-fix': 'off',
91+
92+
// Security rules - turned to warnings to avoid breaking changes
93+
'security/detect-object-injection': 'warn',
94+
'security/detect-non-literal-regexp': 'warn',
95+
'security/detect-possible-timing-attacks': 'warn',
96+
97+
// Disable some ESLint rules that might conflict
98+
'no-useless-escape': 'warn',
99+
},
100+
},
101+
102+
// Special configuration for TypeScript files
103+
{
104+
files: ['**/*.ts', '**/*.tsx'],
105+
rules: {
106+
// Disable ESLint rules that TypeScript ESLint handles better
107+
'no-undef': 'off',
108+
'no-unused-vars': 'off',
109+
'@typescript-eslint/no-unused-vars': ['warn', {
110+
argsIgnorePattern: '^_',
111+
varsIgnorePattern: '^_',
112+
}],
113+
'@typescript-eslint/no-explicit-any': 'warn',
114+
'@typescript-eslint/explicit-function-return-type': 'off',
115+
'@typescript-eslint/explicit-module-boundary-types': 'off',
116+
'@typescript-eslint/consistent-type-definitions': 'off', // Disable to avoid breaking changes
117+
'@typescript-eslint/consistent-indexed-object-style': 'off', // Disable to avoid breaking changes
118+
'@typescript-eslint/no-wrapper-object-types': 'off', // Disable to avoid breaking changes
119+
},
120+
},
121+
122+
// Test files
123+
{
124+
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
125+
rules: {
126+
// Relaxed rules for tests
127+
'@typescript-eslint/no-explicit-any': 'off',
128+
'security/detect-object-injection': 'off',
129+
'sort-keys': 'off',
130+
'sort-keys-fix/sort-keys-fix': 'off',
131+
},
132+
}
133+
);

package.json

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"preview": "vite preview",
2020
"format": "pnpm prettier --write ./src/components/*.{ts,tsx}",
2121
"test": "pnpm vitest --config ./vitest.config.ts --coverage",
22-
"lint": "pnpm eslint ./src/components/**/*.{ts,tsx}",
23-
"fix-lint": "pnpm eslint ./src/components/**/*.{ts,tsx} --fix",
22+
"lint": "pnpm eslint \"./src/**/*.{ts,tsx,js,jsx}\"",
23+
"fix-lint": "pnpm eslint \"./src/**/*.{ts,tsx,js,jsx}\" --fix",
2424
"build:dev": "webpack --mode=development",
2525
"build:prod": "webpack --mode=production --node-env=production",
2626
"analyze": "webpack --mode=production --node-env=production --env analyze",
@@ -59,46 +59,14 @@
5959
"pre-commit": "pretty-quick --staged"
6060
}
6161
},
62-
"eslintConfig": {
63-
"env": {
64-
"browser": true,
65-
"commonjs": true,
66-
"es2021": true
67-
},
68-
"extends": [
69-
"plugin:react/recommended",
70-
"standard",
71-
"prettier"
72-
],
73-
"parser": "@typescript-eslint/parser",
74-
"parserOptions": {
75-
"ecmaFeatures": {
76-
"jsx": true
77-
},
78-
"ecmaVersion": 12,
79-
"sourceType": "module"
80-
},
81-
"plugins": [
82-
"react",
83-
"@typescript-eslint"
84-
],
85-
"rules": {
86-
"no-use-before-define": "off",
87-
"react/prop-types": "off"
88-
},
89-
"settings": {
90-
"react": {
91-
"version": "detect"
92-
}
93-
}
94-
},
9562
"main": "dist/react-wizardry.js",
9663
"devDependencies": {
9764
"@babel/core": "^7.19.6",
9865
"@babel/plugin-transform-runtime": "^7.19.6",
9966
"@babel/preset-env": "^7.19.4",
10067
"@babel/preset-react": "^7.18.6",
10168
"@babel/runtime": "^7.20.0",
69+
"@eslint/js": "^9.28.0",
10270
"@swc/core": "^1.11.31",
10371
"@testing-library/jest-dom": "^5.16.5",
10472
"@testing-library/react": "^13.4.0",
@@ -120,16 +88,19 @@
12088
"cssnano": "^7.0.7",
12189
"dotenv-webpack": "^8.1.0",
12290
"esbuild-loader": "^2.20.0",
123-
"eslint": "^8.26.0",
91+
"eslint": "^9.28.0",
12492
"eslint-config-prettier": "^8.5.0",
12593
"eslint-config-standard": "^17.0.0",
126-
"eslint-plugin-import": "^2.25.2",
94+
"eslint-plugin-import": "^2.31.0",
95+
"eslint-plugin-jsx-a11y": "^6.10.2",
12796
"eslint-plugin-n": "^15.4.0",
12897
"eslint-plugin-node": "^11.1.0",
12998
"eslint-plugin-promise": "^6.1.1",
130-
"eslint-plugin-react": "^7.31.10",
131-
"eslint-plugin-security": "^1.5.0",
99+
"eslint-plugin-react": "^7.37.5",
100+
"eslint-plugin-react-hooks": "^5.2.0",
101+
"eslint-plugin-security": "^3.0.1",
132102
"eslint-plugin-sort-keys-fix": "^1.1.2",
103+
"glob": "^11.0.2",
133104
"husky": "^8.0.1",
134105
"jsdom": "^20.0.2",
135106
"mini-css-extract-plugin": "^2.6.1",
@@ -150,6 +121,7 @@
150121
"terser-webpack-plugin": "^5.3.6",
151122
"ts-loader": "^9.4.1",
152123
"typescript": "^4.8.4",
124+
"typescript-eslint": "^8.33.1",
153125
"vite": "^6.3.5",
154126
"vitest": "^3.2.2",
155127
"webpack": "^5.99.9",

0 commit comments

Comments
 (0)