Skip to content

Commit 470776a

Browse files
committed
Add ESLint configuration and ImageWithContent tests
- Create comprehensive .eslintrc.js with React, testing, and accessibility rules - Add ESLint plugins for React, hooks, testing, and import management - Implement detailed unit tests for ImageWithContent component - Add data-testid attributes to improve test coverage - Update package.json with ESLint and related dev dependencies
1 parent 9de4520 commit 470776a

File tree

5 files changed

+478
-13
lines changed

5 files changed

+478
-13
lines changed

.eslintrc.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true,
6+
es2021: true,
7+
jest: true,
8+
},
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:react/recommended',
12+
'plugin:react/jsx-runtime',
13+
'plugin:react-hooks/recommended',
14+
'plugin:jsx-a11y/recommended',
15+
'plugin:import/recommended',
16+
'plugin:testing-library/react',
17+
'plugin:jest/recommended',
18+
],
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
ecmaFeatures: {
23+
jsx: true,
24+
},
25+
},
26+
settings: {
27+
react: {
28+
version: 'detect',
29+
},
30+
'import/resolver': {
31+
node: {
32+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
33+
},
34+
},
35+
},
36+
plugins: [
37+
'react',
38+
'react-hooks',
39+
'jsx-a11y',
40+
'import',
41+
'testing-library',
42+
'jest',
43+
],
44+
rules: {
45+
// React specific rules
46+
'react/prop-types': 'warn',
47+
'react/jsx-uses-react': 'error',
48+
'react/jsx-uses-vars': 'error',
49+
'react-hooks/rules-of-hooks': 'error',
50+
'react-hooks/exhaustive-deps': 'warn',
51+
52+
// General code quality rules
53+
'no-console': ['warn', { allow: ['warn', 'error'] }],
54+
'no-unused-vars': 'warn',
55+
'prefer-const': 'warn',
56+
'no-var': 'error',
57+
'eqeqeq': ['error', 'always'],
58+
59+
// Import rules
60+
'import/no-unresolved': 'error',
61+
'import/order': ['warn', {
62+
'groups': [
63+
'builtin',
64+
'external',
65+
'internal',
66+
['parent', 'sibling'],
67+
'index',
68+
],
69+
'newlines-between': 'always',
70+
'alphabetize': { 'order': 'asc', 'caseInsensitive': true },
71+
}],
72+
73+
// Accessibility
74+
'jsx-a11y/alt-text': 'error',
75+
'jsx-a11y/anchor-is-valid': 'error',
76+
77+
// Testing
78+
'testing-library/await-async-queries': 'error',
79+
'testing-library/no-await-sync-queries': 'error',
80+
'testing-library/no-dom-import': 'error',
81+
'jest/no-disabled-tests': 'warn',
82+
'jest/no-focused-tests': 'error',
83+
},
84+
overrides: [
85+
{
86+
files: ['**/*.test.js', '**/*.test.jsx', 'src/setupTests.js'],
87+
env: {
88+
jest: true,
89+
},
90+
rules: {
91+
'testing-library/prefer-screen-queries': 'warn',
92+
},
93+
},
94+
],
95+
};

package-lock.json

Lines changed: 214 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
5454
"@testing-library/jest-dom": "^6.6.3",
5555
"@testing-library/react": "^16.2.0",
56+
"eslint": "^8.57.1",
57+
"eslint-plugin-import": "^2.31.0",
58+
"eslint-plugin-jsx-a11y": "^6.10.2",
59+
"eslint-plugin-react": "^7.37.4",
60+
"eslint-plugin-react-hooks": "^5.1.0",
61+
"eslint-plugin-testing-library": "^7.1.1",
5662
"gh-pages": "^6.3.0",
5763
"identity-obj-proxy": "^3.0.0",
5864
"jest": "^27.5.1",

0 commit comments

Comments
 (0)