-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HLM-6172 changed how microplan nameing error is shown, rule logic correction #821
Conversation
WalkthroughWalkthroughThe changes involve updates to styling rules, component logic, and state management across various files in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant MicroplanDetails
participant InfoCard
participant Upload
participant RuleEngine
User->>UI: Interacts with UI
UI->>MicroplanDetails: Fetches microplan details
MicroplanDetails->>InfoCard: Displays naming conventions
UI->>Upload: Initiates file upload
Upload->>UI: Shows upload status
UI->>RuleEngine: Configures rule engine
RuleEngine->>UI: Updates rule configurations
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Outside diff range and nitpick comments (29)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/SelectCampaign.js (1)
Line range hint
213-221
: JSX elements without children should be self-closing.- <InboxSearchComposerV2 configs={configs} browserSession={SelectCampaignSession} additionalConfig={{ resultsTable: { onClickRow, } }}></InboxSearchComposerV2> + <InboxSearchComposerV2 configs={configs} browserSession={SelectCampaignSession} additionalConfig={{ resultsTable: { onClickRow, } }} />This change makes the code cleaner and follows best practices for JSX where elements without children should be self-closing.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanDetails.js (1)
Line range hint
229-229
: Correct usage of keys in JSX lists.- <div key={index} className="microplan-naming-convention-instruction-list number"> + <div key={`number-${index}`} className="microplan-naming-convention-instruction-list number"> - <div key={index} className="microplan-naming-convention-instruction-list text"> + <div key={`text-${index}`} className="microplan-naming-convention-instruction-list text">Using indices as keys in React is an anti-pattern unless the list is static and does not change order. It's better to use unique and stable identifiers.
Also applies to: 279-279, 280-280, 283-283
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (4)
Line range hint
152-154
: Refactor to use an arrow function for consistency and improved readability.- const computeGeojsonWithMappedProperties = function({ campaignType, fileType, templateIdentifier, validationSchemas }) { + const computeGeojsonWithMappedProperties = ({ campaignType, fileType, templateIdentifier, validationSchemas }) => {Tools
Biome
[error] 212-212: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Line range hint
163-163
: Use optional chaining to simplify the code and enhance safety.- if (schemaData?.schema?.["Properties"]) schemaKeys = hierarchy.concat(Object.keys(schemaData.schema["Properties"])); + schemaKeys = hierarchy.concat(Object.keys(schemaData?.schema?.["Properties"] || {}));Apply similar changes to other lines where optional chaining is suggested by the static analysis.
Also applies to: 212-212, 308-308
Tools
Biome
[error] 212-212: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Line range hint
366-366
: Use strict equality checks to avoid potential bugs due to type coercion.- if (inputValue == undefined || inputValue === null) return null; + if (inputValue === undefined || inputValue === null) return null;Also applies to: 368-368
Tools
Biome
[error] 212-212: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Line range hint
379-379
: Remove unnecessary else clause to simplify the control flow.- else return rowData[inputIndex];
Tools
Biome
[error] 212-212: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (3)
Line range hint
477-477
: Ensure that all buttons have an explicittype
attribute to prevent unexpected form submissions.- <button className="delete-button invisible" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button"> + <button type="button" className="delete-button invisible" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button"> - <button className="delete-button" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button"> + <button type="button" className="delete-button" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button">Also applies to: 561-561
Line range hint
488-495
: Add keyboard event handlers to complement mouse events for accessibility.- <button className="delete-button" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button"> + <button type="button" className="delete-button" onClick={() => deleteHandler(item)} aria-label={t("DELETE")} role="button" onKeyPress={() => deleteHandler(item)}>
Line range hint
489-489
: Avoid using array indices as keys in React lists to prevent issues with component state and performance.Consider using a unique identifier or a combination of properties as keys.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (4)
Line range hint
363-363
: Correct duplicate object keys in modal styles.You have duplicate keys for
padding
in your object which can lead to unexpected behavior. Consider removing or merging them.- popupModuleActionBarStyles={{ - display: "flex", - flex: 1, - justifyContent: "flex-start", - padding: 0, - width: "100%", - padding: "1rem", - }} + popupModuleActionBarStyles={{ + display: "flex", + flex: 1, + justifyContent: "flex-start", + padding: "1rem", + width: "100%", + }}
Line range hint
578-578
: Use self-closing tags for stateless JSX components.For JSX elements without children, use self-closing tags to improve readability and maintain consistency.
- <div className="api-data-loader"> - <Loader /> - </div> + <div className="api-data-loader"> + <Loader /> + </div>
Line range hint
661-663
: Remove unnecessary else clause.The
else
clause is redundant here as the previous branches break early. Removing it can simplify the control flow.- if (condition) { - // code - } else { - // code that can be omitted - } + if (condition) { + // code + }
Line range hint
440-440
: Avoid using array indices as keys in React lists.Using array indices as keys in React can lead to performance issues and bugs during re-renders. Use unique identifiers instead.
- <div key={index} className="hierarchy-selection-element"> + <div key={item.uniqueId} className="hierarchy-selection-element">Also applies to: 487-487, 556-556, 567-567
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (7)
Line range hint
38-38
: ReplacehasOwnProperty
withObject.hasOwn
for better safety and future-proofing.- if (obj.hasOwnProperty(key)) { + if (Object.hasOwn(obj, key)) {
Line range hint
266-266
: Simplify the conditional expression by removing unnecessary boolean literals.- return obj[key] && !(Array.isArray(obj[key]) && obj[key].length === 0) ? true : false; + return obj[key] && !(Array.isArray(obj[key]) && obj[key].length === 0);
Line range hint
484-484
: Ensure accessibility by pairing mouse events with corresponding keyboard events.+ onKeyUp={handleKeyUp}
Add
onKeyUp
handlers similar toonClick
handlers to ensure keyboard accessibility.Also applies to: 519-519, 572-572, 573-573, 709-716, 794-794, 804-810
Line range hint
524-524
: RemovetabIndex
from non-interactive elements to improve accessibility.- tabIndex={0}
Line range hint
562-562
: Avoid assignments within expressions to enhance code clarity.- let check = filterSelections.includes(item) ? (tempFilterSelections = tempFilterSelections.filter((element) => element !== item)) : tempFilterSelections.push(item); + if (filterSelections.includes(item)) { + tempFilterSelections = tempFilterSelections.filter((element) => element !== item); + } else { + tempFilterSelections.push(item); + }
Line range hint
803-803
: Use strict equality checks to avoid potential bugs due to type coercion.- if (name == selectedBaseMapName) { + if (name === selectedBaseMapName) {Also applies to: 939-939
Line range hint
885-885
: Use optional chaining to simplify accessing properties on objects that might be null or undefined.- if (feature && feature.properties && feature.properties.addOn) { + if (feature?.properties?.addOn) {Apply similar changes to other instances where properties are accessed in a nested manner.
Also applies to: 894-894, 895-895, 924-925, 1025-1025, 1026-1026, 1028-1028
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js (9)
Line range hint
439-439
: Use strict equality comparison.- if (response.check == false && response.stopUpload) { + if (response.check === false && response.stopUpload) {
Line range hint
1115-1115
: Ensure keyboard accessibility for clickable elements.For accessibility, it's important that actions triggered by mouse clicks can also be triggered by keyboard events. Consider adding
onKeyUp
,onKeyDown
, oronKeyPress
events to these elements.Also applies to: 1138-1138
Line range hint
1217-1217
: Use self-closing tags for JSX elements without children.- <div className="browse-text-wrapper"> + <div className="browse-text-wrapper" />
Line range hint
1374-1374
: Avoid usinghasOwnProperty
directly from objects.It's safer to use
Object.hasOwn()
instead ofObject.prototype.hasOwnProperty.call()
to check for properties on objects to avoid issues with properties that may be inherited from the prototype chain.- if (jsonObject.hasOwnProperty(key)) { + if (Object.hasOwn(jsonObject, key)) {
Line range hint
1354-1356
: Convert function expressions to arrow functions.Using arrow functions can make the code cleaner and ensure that
this
is bound lexically.- const trimJSON = function(jsonObject) { + const trimJSON = (jsonObject) => {
Line range hint
1228-1228
: Specify thetype
attribute for button elements.To prevent unexpected form submissions, it's a good practice to explicitly set the
type
attribute of button elements.- <button className={selectedFileType && selectedFileType.id === item.id ? "selected-button" : "select-button"} + <button type="button" className={selectedFileType && selectedFileType.id === item.id ? "selected-button" : "select-button"}
Line range hint
158-172
: Remove unnecessaryelse
clauses.The
else
clauses here are redundant since the precedingif
blocks containreturn
statements. Removing these can simplify the control flow.- else { + // Removed unnecessary else clauseAlso applies to: 700-705, 1451-1453, 1577-1579
Line range hint
227-227
: Use optional chaining to simplify expressions.Optional chaining (
?.
) can simplify your code and prevent runtime errors due tonull
orundefined
values.- if (selectedSection && selectedSection.UploadFileTypes) { + if (selectedSection?.UploadFileTypes) {Also applies to: 290-290, 558-558, 1206-1209, 1798-1798
Line range hint
707-707
: Avoid reassigning catch parameters.Reassigning catch parameters can lead to confusion and errors. Use a separate variable inside the catch block.
- catch (error) { + catch (error) { + let localError = error;
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
micro-ui/web/micro-ui-internals/packages/css/package.json
is excluded by!**/*.json
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json
is excluded by!**/*.json
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/UIConfiguration.json
is excluded by!**/*.json
Files selected for processing (12)
- micro-ui/web/micro-ui-internals/packages/css/src/components/coreOverride.scss (1 hunks)
- micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss (9 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (2 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanDetails.js (5 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (4 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (16 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js (5 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/hooks/useNumberFormatter.js (1 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/SelectCampaign.js (2 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js (3 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (3 hunks)
- micro-ui/web/public/index.html (1 hunks)
Files skipped from review due to trivial changes (2)
- micro-ui/web/micro-ui-internals/packages/css/src/components/coreOverride.scss
- micro-ui/web/public/index.html
Additional context used
Path-based instructions (9)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/hooks/useNumberFormatter.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/SelectCampaign.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanDetails.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js (1)
Pattern
**/*.js
: check
Learnings (5)
Common learnings
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js:55-57 Timestamp: 2024-05-27T04:08:38.193Z Learning: The logic for the data change save check in the `RuleEngine.js` file has been shifted elsewhere for more global checks.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (1)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js:55-57 Timestamp: 2024-05-27T04:08:38.193Z Learning: The logic for the data change save check in the `RuleEngine.js` file has been shifted elsewhere for more global checks.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (1)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js:55-57 Timestamp: 2024-05-27T04:08:38.193Z Learning: The logic for the data change save check in the `RuleEngine.js` file has been shifted elsewhere for more global checks.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (2)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js:1-1 Timestamp: 2024-05-27T04:09:43.769Z Learning: The imports in `MicroplanPreview.js` are from different libraries: `@egovernments/digit-ui-components` and `@egovernments/digit-ui-react-components`.
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#675 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js:4-10 Timestamp: 2024-05-23T05:09:21.739Z Learning: Imports in `MicroplanPreview.js` are either already grouped appropriately or come from different directories, as clarified by the user.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js (2)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#204 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Upload.js:468-481 Timestamp: 2024-03-13T07:33:45.211Z Learning: The error message in the `checkForErrorInUploadedFile` function within `Upload.js` is being localized and improved for better user experience, as clarified by the user.
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#204 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Upload.js:0-0 Timestamp: 2024-03-13T05:11:36.400Z Learning: A more detailed message for file parsing errors in the `Upload.js` file is displayed elsewhere in the code, as clarified by the user.
Biome
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js
[error] 39-39: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
[error] 43-43: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
[error] 47-47: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression withmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/SelectCampaign.js
[error] 213-221: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanDetails.js
[error] 115-115: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 144-148: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 229-229: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 277-277: Missing key property for this element in iterable. (lint/correctness/useJsxKeyInIterable)
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
[error] 279-279: Missing key property for this element in iterable. (lint/correctness/useJsxKeyInIterable)
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
[error] 280-280: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 283-283: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js
[error] 152-154: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 163-163: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 212-212: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 308-308: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 366-366: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 368-368: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 379-379: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js
[error] 138-138: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 150-150: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 171-171: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 488-495: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 678-678: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 699-699: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 851-856: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 477-477: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
[error] 489-489: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 561-561: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or resetmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js
[error] 129-129: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 264-264: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 339-339: Use !== instead of !=.
!= is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)!= is only allowed when comparing against null
Using != may be unsafe if you are relying on type coercion
Unsafe fix: Use !==
[error] 363-363: This property value named padding is later overwritten by an object member with the same name. (lint/suspicious/noDuplicateObjectKeys)
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named padding
[error] 578-578: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
[error] 661-663: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 758-758: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 805-805: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 987-989: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1003-1003: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1035-1035: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1035-1035: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 1038-1047: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1049-1049: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1061-1061: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 1069-1069: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 440-440: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 487-487: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 556-556: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 567-567: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js
[error] 38-38: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 266-266: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
[error] 484-484: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 519-519: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 524-524: The HTML element div is non-interactive. Do not use tabIndex. (lint/a11y/noNoninteractiveTabindex)
Adding non-interactive elements to the keyboard navigation flow can confuse users.
Unsafe fix: Remove the tabIndex attribute.
[error] 562-562: The assignment should not be in an expression. (lint/suspicious/noAssignInExpressions)
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
[error] 572-572: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 573-573: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 709-716: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 794-794: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 803-803: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 804-810: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 885-885: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 894-894: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 895-895: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 924-925: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 939-939: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 1025-1025: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 1026-1026: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1028-1028: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js
[error] 158-172: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 227-227: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 290-290: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 439-439: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 558-558: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 700-705: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1115-1115: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 1138-1138: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 1206-1209: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1217-1217: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
[error] 1354-1356: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 1374-1374: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 1384-1437: Promise executor functions should not be
async
. (lint/suspicious/noAsyncPromiseExecutor)
[error] 1451-1453: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1577-1579: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1689-1689: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 1798-1798: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 707-707: Reassigning a catch parameter is confusing. (lint/suspicious/noCatchAssign)
The catch parameter is declared here:
Use a local variable instead.
[error] 1136-1136: Missing key property for this element in iterable. (lint/correctness/useJsxKeyInIterable)
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
[error] 1228-1228: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
Additional comments not posted (15)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/hooks/useNumberFormatter.js (1)
8-10
: Enhanced locale determination for number formatting.This change improves the robustness of the locale determination by considering the current language, fallback language, and defaulting to an empty string if no valid locale is found. This should help in cases where the current language or fallback options are not available in the
FormatMapping
.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js (1)
12-12
: Import ofUIConfiguration
JSON.This import is necessary for accessing configuration settings within the app, which seems to be used later in the code to manage UI states and settings.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanDetails.js (1)
16-16
: Enhancements to microplan details management.The addition of
InfoCard
for naming conventions, new states for UI control, and improved validation logic significantly enhance the user interface and functionality of the microplan details management.Also applies to: 39-39, 157-157, 194-194, 273-290
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (4)
Line range hint
156-200
: The addition ofpureInputList
and its integration into the rule filtering logic is a significant change. Ensure that all dependent components and functions correctly handle this new state.
214-216
: The refactoring ofdeleteAssumptionHandler
to includepureInputList
is a good practice as it ensures that all relevant data is considered when deleting an assumption.
241-241
: PassingpureInputList
to theInterractableSection
component is crucial for maintaining consistency in how data is handled across different sections of the application.
40-40
: Consider using optional chaining for safer access to nested properties.- const tourData = tourSteps(t)?.[page] || {}; + const tourData = tourSteps(t)?.[page] ?? {};Likely invalid or redundant comment.
micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss (7)
166-195
: Added styles for.microplan-naming-conventions
to enhance UI presentation.This addition aligns with the PR's objective to enhance UI components and modify logic and state management. The styles are well-structured and use consistent formatting.
253-257
: Adjusted positioning for.end
class within.upload-section
.The change in positioning ensures better alignment and visual consistency across different screen sizes. Good use of absolute positioning for UI elements that need precise placement.
787-787
: Standardized vertical alignment for table headers.Ensuring that the vertical alignment of table headers is consistent improves readability and maintains a clean layout across the application.
Also applies to: 2243-2243
Line range hint
2069-2130
: Enhanced the.hypothesis-container
with additional padding and margin adjustments.These changes improve the spacing and overall aesthetics of the hypothesis section, making it more user-friendly and visually appealing.
2127-2130
: Added.scrollable
class with specific padding and margin.The addition of padding and margin to the
.scrollable
class enhances the usability and visual appeal of scrollable elements, ensuring a better user experience.
2148-2148
: Adjusted margin for.hypothesis-controllers
button.This margin adjustment ensures that the buttons within the hypothesis controllers are evenly spaced, contributing to a more organized and visually appealing interface.
2444-2449
: Introduced.guide-line-heading
for better heading management in guidelines sections.This new class provides a consistent styling approach for headings within the guidelines section, enhancing the readability and visual hierarchy of the content.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js (1)
1136-1136
: Add akey
prop to elements in a list.React requires a unique
key
prop on elements in a list to manage re-rendering efficiently.- <p key={index} className="instruction-list number"> + <p key={`instruction-list-number-${index}`} className="instruction-...Likely invalid or redundant comment.
Tools
Biome
[error] 1136-1136: Missing key property for this element in iterable. (lint/correctness/useJsxKeyInIterable)
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js
Outdated
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js
Show resolved
Hide resolved
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js
Show resolved
Hide resolved
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js
Show resolved
Hide resolved
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js
Show resolved
Hide resolved
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Outside diff range and nitpick comments (19)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/processHierarchyAndData.js (3)
Line range hint
68-68
: Consider replacing thedelete
operator with setting the property toundefined
for better performance.- delete country.children[null]; + country.children[null] = undefined;
Line range hint
142-142
: Optimize the use of spread syntax in accumulators to improve performance.- tempData = { - ...accumulator, - ...hierarchy.reduce((data, item) => { - if (parents.includes(item?.name) && item?.children) data = { ...data, ...item?.children }; - return data; - }, {}), - }; + hierarchy.forEach((item) => { + if (parents.includes(item?.name) && item?.children) { + Object.assign(accumulator, item.children); + } + }); + tempData = accumulator;Also applies to: 148-148
Line range hint
223-224
: Remove unnecessaryelse
clauses to simplify the control flow.- else { - return []; - }Also applies to: 224-224
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (3)
Line range hint
174-176
: Convert function expressions to arrow functions for consistency and to avoidthis
binding issues.- const findResult = function (inputValue, assumptionValue, operator) { + const findResult = (inputValue, assumptionValue, operator) => {
Line range hint
185-185
: Use optional chaining to safely access nested properties.- if (oldTree[name].children) { + if (oldTree[name]?.children) {Also applies to: 234-234, 330-330
Line range hint
401-401
: Remove unnecessaryelse
clause to simplify the control flow.- else { - return []; - }micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (2)
Line range hint
156-200
: The logic for filtering rules as per constraints is complex and could benefit from further optimization or simplification to improve maintainability.Consider breaking down this large block into smaller, more manageable functions that handle specific parts of the logic. This can improve readability and maintainability.
Line range hint
827-882
: The functionfilterRulesAsPerConstrains
is crucial for the functionality of the rule engine. It appears to handle the logic of filtering and updating rules based on various conditions. However, the complexity of this function could be reduced.Consider simplifying this function or breaking it into smaller functions. This can make the code easier to understand and maintain.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (11)
Line range hint
274-274
: Declare variables at the root of the enclosing function for better clarity and to avoid potential hoisting issues.Consider moving the declaration of
tempBoundarySelection
to the top of the function to avoid confusion and potential bugs related to JavaScript variable hoisting.
Line range hint
373-373
: Remove duplicate object key to avoid overwriting values unintentionally.- popupModuleActionBarStyles={{ - display: "flex", - flex: 1, - justifyContent: "flex-start", - padding: 0, - width: "100%", - padding: "1rem", - }} + popupModuleActionBarStyles={{ + display: "flex", + flex: 1, + justifyContent: "flex-start", + padding: "1rem", + width: "100%", + }}This change ensures that the
padding
property is not set twice, which could lead to unexpected behavior.
Line range hint
618-618
: JSX elements without children should be self-closing for better readability and performance.- <div className="api-data-loader"> - <Loader /> - </div> + <div className="api-data-loader" />This change makes the code cleaner and more concise by using a self-closing tag for the
div
element.
Line range hint
701-703
: Thiselse
clause is unnecessary as the previous branches terminate early.Consider removing the
else
clause to simplify the control flow and improve code readability.
Line range hint
720-729
: ReplaceflatMap
withflat
where the callback is an identity function for better performance and simplicity.- tempdata = filteredSchemas - ?.map((item) => - Object.entries(item?.schema?.Properties || {}).reduce((acc, [key, value]) => { - if (value?.isRuleConfigureInputs && value?.toShowInMicroplanPreview) { - acc.push(key); - } - return acc; - }, []) - ) - .flatMap((item) => item) - .filter((item) => !!item); + tempdata = filteredSchemas + ?.flatMap((item) => + Object.entries(item?.schema?.Properties || {}).reduce((acc, [key, value]) => { + if (value?.isRuleConfigureInputs && value?.toShowInMicroplanPreview) { + acc.push(key); + } + return acc; + }, []) + ) + .filter((item) => !!item);This change optimizes the array processing by removing unnecessary callbacks.
Also applies to: 733-740, 1059-1059
Line range hint
798-798
: Use optional chaining to safely access nested properties.- if (!boundarySelections && !resources) return; + if (!boundarySelections?.length && !resources?.length) return;This change prevents potential runtime errors by checking for the existence of
boundarySelections
andresources
before accessing their properties.
Line range hint
845-845
: Remove unnecessaryelse
clause to simplify the control flow.Consider removing the
else
clause to make the code cleaner and easier to understand, as the previous branches already terminate early.
Line range hint
1027-1029
: Omit unnecessaryelse
clause for cleaner and more efficient code.Removing this
else
clause simplifies the control flow and improves the readability of the code.
Line range hint
1043-1043
: Implement optional chaining for safer property access.- if (!Digit.Utils.microplan.planConfigRequestBodyValidator(body, state, campaignType)) { + if (!Digit.Utils.microplan.planConfigRequestBodyValidator?.(body, state, campaignType)) {This change ensures that the function is called safely, even if it is not defined, preventing potential runtime errors.
Line range hint
1075-1075
: Wrap declarations in a block to restrict their scope within the switch case.- var keys = Object.keys(fileData?.data.features[0].properties); + { + var keys = Object.keys(fileData?.data.features[0].properties); + }This change confines the scope of the variable
keys
to the switch case where it is defined, preventing accidental access from other cases.Also applies to: 1078-1087, 1089-1089
Line range hint
450-450
: Avoid using array indices as keys in React components to prevent issues with component state and performance.Consider using unique identifiers or properties from your data objects as keys instead of array indices to ensure stable identities for components and optimize performance.
Also applies to: 499-499, 596-596, 607-607
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss (10 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (6 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (7 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (16 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js (3 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (7 hunks)
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/processHierarchyAndData.js (4 hunks)
Files skipped from review as they are similar to previous changes (2)
- micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss
- micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js
Additional context used
Path-based instructions (5)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/processHierarchyAndData.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (1)
Pattern
**/*.js
: checkmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (1)
Pattern
**/*.js
: check
Learnings (3)
Common learnings
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js:55-57 Timestamp: 2024-05-27T04:08:38.193Z Learning: The logic for the data change save check in the `RuleEngine.js` file has been shifted elsewhere for more global checks.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (1)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js:55-57 Timestamp: 2024-05-27T04:08:38.193Z Learning: The logic for the data change save check in the `RuleEngine.js` file has been shifted elsewhere for more global checks.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js (2)
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#698 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js:1-1 Timestamp: 2024-05-27T04:09:43.769Z Learning: The imports in `MicroplanPreview.js` are from different libraries: `@egovernments/digit-ui-components` and `@egovernments/digit-ui-react-components`.
User: siddhant-nawale-egov PR: egovernments/DIGIT-Frontend#675 File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js:4-10 Timestamp: 2024-05-23T05:09:21.739Z Learning: Imports in `MicroplanPreview.js` are either already grouped appropriately or come from different directories, as clarified by the user.
Biome
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/processHierarchyAndData.js
[error] 68-68: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 223-224: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 224-224: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
[error] 142-142: Avoid the use of spread (
...
) syntax on accumulators. (lint/performance/noAccumulatingSpread)Spread syntax should be avoided on accumulators (like those in
.reduce
) because it causes a time complexity ofO(n^2)
.
Consider methods such as .splice or .push instead.
[error] 148-148: Avoid the use of spread (
...
) syntax on accumulators. (lint/performance/noAccumulatingSpread)Spread syntax should be avoided on accumulators (like those in
.reduce
) because it causes a time complexity ofO(n^2)
.
Consider methods such as .splice or .push instead.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js
[error] 110-110: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 123-123: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 160-160: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 174-176: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 185-185: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 211-211: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 234-234: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 330-330: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 401-401: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js
[error] 138-138: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 150-150: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 171-171: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 488-495: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 678-678: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 699-699: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 812-821: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 852-857: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 477-477: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
[error] 489-489: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 561-561: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or resetmicro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanPreview.js
[error] 129-129: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 274-274: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 373-373: This property value named padding is later overwritten by an object member with the same name. (lint/suspicious/noDuplicateObjectKeys)
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named padding
[error] 618-618: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
[error] 701-703: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 720-729: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 733-740: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 798-798: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 845-845: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1027-1029: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 1043-1043: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1059-1059: Avoid unnecessary callback in flatMap call. (lint/correctness/noFlatMapIdentity)
You can just use flat to flatten the array.
Safe fix: Replace unnecessary flatMap call to flat instead.
[error] 1075-1075: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1075-1075: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 1078-1087: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1089-1089: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 450-450: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 499-499: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 596-596: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
[error] 607-607: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js
[error] 38-38: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 266-266: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
[error] 519-519: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 524-524: The HTML element div is non-interactive. Do not use tabIndex. (lint/a11y/noNoninteractiveTabindex)
Adding non-interactive elements to the keyboard navigation flow can confuse users.
Unsafe fix: Remove the tabIndex attribute.
[error] 562-562: The assignment should not be in an expression. (lint/suspicious/noAssignInExpressions)
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
[error] 572-572: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 573-573: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 711-718: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 826-826: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 836-842: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 917-917: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 926-926: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 927-927: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 956-957: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1057-1057: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 1058-1058: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1060-1060: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 1068-1068: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
[error] 1068-1068: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 1072-1082: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
Additional comments not posted (5)
micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/RuleEngine.js (3)
40-40
: Introducing a new state variablepureInputList
is a good addition for managing state more effectively.
214-216
: The callback functiondeleteAssumptionHandlerCallback
is well-implemented to handle the deletion of assumptions. Ensure that all dependencies are correctly managed in the useCallback hook to avoid unnecessary re-renders.
241-241
: PassingpureInputList
as a prop toInterractableSection
is a good practice for ensuring that the component has all the data it needs to function properly.micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Mapping.js (2)
630-630
: The introduction of the new state variablechangedBoundaryType
is a significant change. Ensure that this state is properly managed and updated only where necessary to avoid unnecessary re-renders.
213-213
: Remove commented-out code to clean up the codebase.- // let bounds = findBounds(Boundary);
Likely invalid or redundant comment.
No description provided.