appsmith
appsmith copied to clipboard
fix: Added lint error for appsmith store mutations
Description
The interface we have for storing local variables using appsmith.store is immutable, meaning if we want to add variables to this, we have to use storeValue method to add or remove values from appsmith.store. If we use appsmith.store.value = "", we already get a linting error that says Use storeValue() method to modify store. Now if we are in a situation where we have stored an array inside appsmith store and we are mutating this array using push or any other array method, we should be able to see the same linting error. This Pr fixes that problem and shows error any time any function call is made on store object.
Note: removed ImperativeStoreUpdate_spec cypress test case as I have added unit test case which covers this case.
Fixes #29969
or
Fixes Issue URL
[!WARNING]
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags="@tag.All"
:mag: Cypress test results
[!CAUTION] 🔴 🔴 🔴 Some tests have failed. Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9094973253 Commit: d7e1608c4fdaecf895995f16de274451741031cc Cypress dashboard: Click here! The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here
- cypress/e2e/Regression/ClientSide/ProductRamps/PrivateEmbedRamp_spec.ts
Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
Walkthrough
The changes introduce a new interface MemberCallExpressionData to handle call expressions where the callee is a member node, such as obj.func(). The modifications ensure that the extractExpressionsFromCode function and linting utilities can detect and handle mutations on immutable objects, particularly in the Appsmith store, by providing appropriate lint errors.
Changes
| Files/Paths | Change Summary |
|---|---|
app/client/packages/ast/index.ts |
Added MemberCallExpressionData to imports and exports for type definitions related to call expressions. |
app/client/packages/ast/src/index.ts |
Introduced MemberCallExpressionData interface and updated extractExpressionsFromCode to handle this new data structure alongside existing ones. |
app/client/src/plugins/Linting/tests/... |
Added tests to verify lint errors for mutations on immutable objects, including Appsmith store variables and input widget properties. |
app/client/src/plugins/Linting/utils/... |
Renamed parameters and variables to reflect handling of MemberCallExpressionData, updated getInvalidAppsmithStoreSetterErrors to use these new data structures, and modified getCustomErrorsFromScript. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Show lint error when Appsmith store is reassigned or mutated (#29969) | ✅ | |
| Detect mutations using member function calls on objects in the store (#29969) | ✅ | |
| Ensure tests cover new linting rules for immutable object mutations (#29969) | ✅ |
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?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
/build-deploy-preview skip-tests=true
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9111180273.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33484.
recreate: .
Deploy-Preview-URL: https://ce-33484.dp.appsmith.com
Changes look good on DP.