Skip to content

Commit 45ad9b2

Browse files
authored
Merge pull request #104 from kazmer97/fix/frontend-lint
linting fixes in the frontend
2 parents 8791f00 + 004943d commit 45ad9b2

File tree

60 files changed

+909
-1379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+909
-1379
lines changed

src/ui/.eslintrc.json

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,39 @@
55
"jest/globals": true
66
},
77
"root": true,
8-
"extends": ["plugin:react/recommended", "airbnb", "plugin:prettier/recommended"],
8+
"extends": ["plugin:react/recommended", "plugin:jsx-a11y/recommended", "plugin:prettier/recommended"],
99
"parserOptions": {
1010
"ecmaFeatures": {
1111
"jsx": true
1212
},
13-
"ecmaVersion": 12,
13+
"ecmaVersion": "latest",
1414
"sourceType": "module"
1515
},
16-
"plugins": ["react", "prettier", "eslint-plugin-jest", "import"],
16+
"plugins": ["react", "react-hooks", "jsx-a11y", "prettier", "eslint-plugin-jest", "import"],
17+
"settings": {
18+
"react": {
19+
"version": "detect"
20+
},
21+
"import/resolver": {
22+
"node": {
23+
"extensions": [".js", ".jsx"]
24+
}
25+
}
26+
},
1727
"rules": {
1828
"no-console": "off",
1929
"no-alert": "off",
20-
"max-len": ["error", { "code": 120, "ignoreUrls": true, "ignoreTemplateLiterals": true, "ignoreComments": true }],
30+
"max-len": [
31+
"error",
32+
{
33+
"code": 140,
34+
"ignoreUrls": true,
35+
"ignoreTemplateLiterals": true,
36+
"ignoreComments": true,
37+
"ignoreStrings": true,
38+
"ignoreRegExpLiterals": true
39+
}
40+
],
2141
"linebreak-style": ["error", "unix"],
2242
"react/jsx-filename-extension": [
2343
"warn",
@@ -28,7 +48,7 @@
2848
"prettier/prettier": [
2949
"error",
3050
{
31-
"printWidth": 120,
51+
"printWidth": 140,
3252
"singleQuote": true,
3353
"trailingComma": "all"
3454
}
@@ -57,6 +77,18 @@
5777
"ignore": ["\\.css$"]
5878
}
5979
],
60-
"react-hooks/exhaustive-deps": "off"
80+
"react-hooks/exhaustive-deps": "off",
81+
"react/require-default-props": "off",
82+
"no-shadow": "warn",
83+
"import/extensions": [
84+
"error",
85+
"ignorePackages",
86+
{
87+
"js": "never",
88+
"jsx": "never"
89+
}
90+
],
91+
"react/no-array-index-key": "warn",
92+
"import/prefer-default-export": "off"
6193
}
6294
}

src/ui/.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 120,
2+
"printWidth": 140,
33
"singleQuote": true,
44
"trailingComma": "all"
55
}

src/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"scripts": {
5959
"dev": "vite",
6060
"start": "vite",
61-
"build": "vite build",
61+
"build": "npm run lint && vite build",
6262
"preview": "vite preview",
6363
"test": "vitest",
6464
"lint": "npx eslint \"src/**/*.{js,jsx}\""

src/ui/src/components/common/ConfidenceDisplayTest.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ const ConfidenceDisplayTest = () => {
6060
{scenario.name}
6161
</Box>
6262
<Box>
63-
Field Name:{' '}
64-
<ConfidenceDisplay confidenceInfo={scenario.confidenceInfo} variant="detailed" showThreshold />
63+
Field Name: <ConfidenceDisplay confidenceInfo={scenario.confidenceInfo} variant="detailed" showThreshold />
6564
</Box>
6665
<Box margin={{ top: 'xs' }}>
6766
Inline: <ConfidenceDisplay confidenceInfo={scenario.confidenceInfo} variant="inline" showThreshold />

src/ui/src/components/common/DeleteDocumentModal.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const DeleteDocumentModal = ({ visible, onDismiss, onConfirm, selectedItems }) =
2727
}
2828
>
2929
<p>
30-
Are you sure you want to delete {isMultiple ? `these ${documentCount} documents` : 'this document'}? This action
31-
cannot be undone.
30+
Are you sure you want to delete {isMultiple ? `these ${documentCount} documents` : 'this document'}? This action cannot be undone.
3231
</p>
3332
{isMultiple && (
3433
<ul>

src/ui/src/components/common/ReprocessDocumentModal.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ const ReprocessDocumentModal = ({ visible, onDismiss, onConfirm, selectedItems =
4040
}
4141
>
4242
<p>{message}</p>
43-
<p>
44-
This will trigger workflow reprocessing for the following {selectedItems.length > 1 ? 'documents' : 'document'}:
45-
</p>
43+
<p>This will trigger workflow reprocessing for the following {selectedItems.length > 1 ? 'documents' : 'document'}:</p>
4644
<ul>
4745
{selectedItems.map((item) => (
4846
<li key={item.objectKey}>{item.objectKey}</li>

src/ui/src/components/common/debug-utils.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ export const debugDocumentStructure = (document) => {
6464
}
6565

6666
if (document.mergedConfig && document.mergedConfig.assessment) {
67-
console.log(
68-
'Default confidence threshold from config:',
69-
document.mergedConfig.assessment.default_confidence_threshold,
70-
);
67+
console.log('Default confidence threshold from config:', document.mergedConfig.assessment.default_confidence_threshold);
7168
}
7269

7370
console.log('=== End Document Debug ===');

src/ui/src/components/common/hitl-status-renderer.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ export const renderHitlStatus = (item) => {
1414
}
1515

1616
// Check for failed status first (handle both "Failed" and "FAILED")
17-
if (
18-
item.hitlStatus &&
19-
(item.hitlStatus.toLowerCase() === 'failed' || item.hitlStatus === 'Failed' || item.hitlStatus === 'FAILED')
20-
) {
17+
if (item.hitlStatus && (item.hitlStatus.toLowerCase() === 'failed' || item.hitlStatus === 'Failed' || item.hitlStatus === 'FAILED')) {
2118
return 'A2I Review Failed';
2219
}
2320

src/ui/src/components/common/map-document-attributes.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ const isHitlCompleted = (status) => {
1616
if (!status) return false;
1717
const statusLower = status.toLowerCase();
1818
return (
19-
statusLower === 'completed' ||
20-
statusLower.includes('complete') ||
21-
statusLower.includes('done') ||
22-
statusLower.includes('finished')
19+
statusLower === 'completed' || statusLower.includes('complete') || statusLower.includes('done') || statusLower.includes('finished')
2320
);
2421
};
2522

src/ui/src/components/configuration-layout/ConfigBuilder.jsx

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
Modal,
2020
Tabs,
2121
} from '@cloudscape-design/components';
22-
import Editor from '@monaco-editor/react';
2322
import SchemaBuilder from '../json-schema-builder/SchemaBuilder';
2423

2524
// Add custom styles for compact form layout
@@ -571,9 +570,7 @@ const ConfigBuilder = ({
571570
// Check dependencies FIRST, before any rendering - applies to all field types
572571
if (property.dependsOn) {
573572
const dependencyField = property.dependsOn.field;
574-
const dependencyValues = Array.isArray(property.dependsOn.values)
575-
? property.dependsOn.values
576-
: [property.dependsOn.value];
573+
const dependencyValues = Array.isArray(property.dependsOn.values) ? property.dependsOn.values : [property.dependsOn.value];
577574

578575
let dependencyPath;
579576

@@ -619,8 +616,7 @@ const ConfigBuilder = ({
619616
dependencyValueType: typeof dependencyValue,
620617
dependencyValues,
621618
dependencyValuesTypes: dependencyValues.map((v) => typeof v),
622-
isNestedAttribute:
623-
currentPath.includes('groupAttributes[') || currentPath.includes('listItemTemplate.itemAttributes['),
619+
isNestedAttribute: currentPath.includes('groupAttributes[') || currentPath.includes('listItemTemplate.itemAttributes['),
624620
shouldHide: dependencyValue === undefined || !dependencyValues.includes(dependencyValue),
625621
});
626622

@@ -793,9 +789,7 @@ const ConfigBuilder = ({
793789
<SpaceBetween size="xs">
794790
{getSortedObjectProperties(property.properties).map(({ propKey, propSchema }) => {
795791
const nestedPropSchema =
796-
propSchema.type === 'list' || propSchema.type === 'array'
797-
? { ...propSchema, nestLevel: nestLevel + 1 }
798-
: propSchema;
792+
propSchema.type === 'list' || propSchema.type === 'array' ? { ...propSchema, nestLevel: nestLevel + 1 } : propSchema;
799793
return <Box key={propKey}>{renderField(propKey, nestedPropSchema, fullPath)}</Box>;
800794
})}
801795
</SpaceBetween>
@@ -979,22 +973,18 @@ const ConfigBuilder = ({
979973
// Special handling for nested attributes looking for attributeType
980974
if (
981975
dependencyField === 'attributeType' &&
982-
(fieldPath.includes('groupAttributes[') ||
983-
fieldPath.includes('listItemTemplate.itemAttributes['))
976+
(fieldPath.includes('groupAttributes[') || fieldPath.includes('listItemTemplate.itemAttributes['))
984977
) {
985978
if (fieldPath.includes('groupAttributes[')) {
986979
const attributeMatch = fieldPath.match(/^(.+\.attributes\[\d+\])\.groupAttributes/);
987980
dependencyPath = attributeMatch ? `${attributeMatch[1]}.attributeType` : null;
988981
} else if (fieldPath.includes('listItemTemplate.itemAttributes[')) {
989-
const attributeMatch = fieldPath.match(
990-
/^(.+\.attributes\[\d+\])\.listItemTemplate\.itemAttributes/,
991-
);
982+
const attributeMatch = fieldPath.match(/^(.+\.attributes\[\d+\])\.listItemTemplate\.itemAttributes/);
992983
dependencyPath = attributeMatch ? `${attributeMatch[1]}.attributeType` : null;
993984
}
994985
} else {
995986
const parentPath = fieldPath.substring(0, fieldPath.lastIndexOf('.'));
996-
dependencyPath =
997-
parentPath.length > 0 ? `${parentPath}.${dependencyField}` : dependencyField;
987+
dependencyPath = parentPath.length > 0 ? `${parentPath}.${dependencyField}` : dependencyField;
998988
}
999989

1000990
if (!dependencyPath) return false;
@@ -1081,17 +1071,13 @@ const ConfigBuilder = ({
10811071
// Render the regular fields using HTML table for guaranteed columns
10821072
const renderedRegularFields = (
10831073
<Box padding="0" style={{ margin: 0 }}>
1084-
<table
1085-
style={{ width: '100%', borderCollapse: 'separate', borderSpacing: '4px 0', margin: 0 }}
1086-
>
1074+
<table style={{ width: '100%', borderCollapse: 'separate', borderSpacing: '4px 0', margin: 0 }}>
10871075
<tbody style={{ margin: 0, padding: 0 }}>
10881076
{/* Render description field first if it exists, spanning full width */}
10891077
{descriptionField && (
10901078
<tr key="description-row">
10911079
<td colSpan={actualColumnCount} style={{ verticalAlign: 'top' }}>
1092-
<Box padding="0">
1093-
{renderField(descriptionField.propKey, descriptionField.propSchema, itemPath)}
1094-
</Box>
1080+
<Box padding="0">{renderField(descriptionField.propKey, descriptionField.propSchema, itemPath)}</Box>
10951081
</td>
10961082
</tr>
10971083
)}
@@ -1164,12 +1150,7 @@ const ConfigBuilder = ({
11641150
};
11651151

11661152
return (
1167-
<Box
1168-
key={propKey}
1169-
padding={{ top: '0', bottom: '8px' }}
1170-
width="100%"
1171-
margin={{ bottom: '4px' }}
1172-
>
1153+
<Box key={propKey} padding={{ top: '0', bottom: '8px' }} width="100%" margin={{ bottom: '4px' }}>
11731154
{renderField(propKey, nestedProps, itemPath)}
11741155
</Box>
11751156
);
@@ -1190,9 +1171,7 @@ const ConfigBuilder = ({
11901171
})()
11911172
) : (
11921173
// Simple list item (non-object)
1193-
<Box padding="xs">
1194-
{renderInputField(`${key}[${index}]`, property.items, values[index], itemPath)}
1195-
</Box>
1174+
<Box padding="xs">{renderInputField(`${key}[${index}]`, property.items, values[index], itemPath)}</Box>
11961175
)}
11971176
</Box>
11981177
</Box>
@@ -1347,11 +1326,7 @@ const ConfigBuilder = ({
13471326
options={property.enum.map((opt) => ({ value: opt, label: opt }))}
13481327
/>
13491328
);
1350-
} else if (
1351-
property.format === 'text-area' ||
1352-
path.toLowerCase().includes('prompt') ||
1353-
path.toLowerCase().includes('description')
1354-
) {
1329+
} else if (property.format === 'text-area' || path.toLowerCase().includes('prompt') || path.toLowerCase().includes('description')) {
13551330
input = (
13561331
<Textarea
13571332
value={displayValue !== undefined && displayValue !== null ? String(displayValue) : ''}
@@ -1434,9 +1409,7 @@ const ConfigBuilder = ({
14341409

14351410
// Check if a property needs a container with section header
14361411
const shouldUseContainer = (key, property) => {
1437-
return (
1438-
property.sectionLabel && (property.type === 'object' || property.type === 'list' || property.type === 'array')
1439-
);
1412+
return property.sectionLabel && (property.type === 'object' || property.type === 'list' || property.type === 'array');
14401413
};
14411414

14421415
// Render each top-level property
@@ -1489,11 +1462,7 @@ const ConfigBuilder = ({
14891462
label: 'Document Schema',
14901463
content: (
14911464
<Box style={{ height: 'calc(70vh - 60px)' }}>
1492-
<SchemaBuilder
1493-
initialSchema={extractionSchema}
1494-
onChange={onSchemaChange}
1495-
onValidate={onSchemaValidate}
1496-
/>
1465+
<SchemaBuilder initialSchema={extractionSchema} onChange={onSchemaChange} onValidate={onSchemaValidate} />
14971466
</Box>
14981467
),
14991468
},
@@ -1521,10 +1490,7 @@ const ConfigBuilder = ({
15211490
{activeAddModal && (
15221491
<FormField
15231492
label="Name"
1524-
description={
1525-
getPropertyFromPath(activeAddModal)?.items?.properties?.name?.description ||
1526-
'Enter a unique name for this item'
1527-
}
1493+
description={getPropertyFromPath(activeAddModal)?.items?.properties?.name?.description || 'Enter a unique name for this item'}
15281494
errorText={nameError}
15291495
>
15301496
{showNameAsDropdown ? (
@@ -1544,7 +1510,6 @@ const ConfigBuilder = ({
15441510
label: opt,
15451511
})) || []
15461512
}
1547-
autoFocus
15481513
/>
15491514
) : (
15501515
// Text input for regular string values
@@ -1557,7 +1522,6 @@ const ConfigBuilder = ({
15571522
}
15581523
}}
15591524
placeholder="Enter name"
1560-
autoFocus
15611525
/>
15621526
)}
15631527
</FormField>

0 commit comments

Comments
 (0)