Skip to content
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

feat: feature flag for eslint migration #36543

Merged
merged 15 commits into from
Nov 12, 2024
Merged

Conversation

ayushpahwa
Copy link
Contributor

@ayushpahwa ayushpahwa commented Sep 25, 2024

Description

This PR introduces a feature flag to control the ESLint migration.

Fixes #36542

Automation

/test js sanity

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11795470649
Commit: ac773e1
Cypress dashboard.
Tags: @tag.JS, @tag.Sanity
Spec:


Tue, 12 Nov 2024 11:58:31 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new feature flag, rollout_eslint_enabled, for managing ESLint functionality.
    • Added an enumeration for linter versions, including "JSHINT" and "ESLINT".
    • Implemented a function to dynamically determine the linter version based on the feature flag.
  • Bug Fixes

    • Enhanced linting error handling by updating the linter version dynamically instead of using a hardcoded value.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

The changes introduce a feature flag, rollout_eslint_enabled, allowing for controlled migration to ESLint within the application. This flag is integrated into the FeatureFlag.ts file with a default value of false. Additionally, a new constant enumeration LINTER_VERSION is added to manage linter versions, and a new function, getLinterVersion, is implemented to dynamically select the linter based on the feature flag. This enhances flexibility in linting management.

Changes

Files Change Summary
app/client/src/ce/entities/FeatureFlag.ts Added new feature flag rollout_eslint_enabled with default value false.
app/client/src/plugins/Linting/constants.ts Introduced LINTER_VERSION enum with constants for "JSHINT" and "ESLINT".
app/client/src/plugins/Linting/utils/getLintingErrors.ts Added getLinterVersion() function to determine linter version based on feature flags; updated getLintingErrors to use dynamic linter version.

Assessment against linked issues

Objective Addressed Explanation
Control ESLint migration with a feature flag (#36542)
Enable phased roll-out and rollback capability (#36542)

Possibly related PRs

Suggested labels

Workflows

Suggested reviewers

  • rajatagrawal
  • nidhi-nair
  • dvj1988

Poem

In the code where flags do sway,
ESLint's journey finds its way.
With JSHint's past, we now embrace,
A future bright, a cleaner space.
So raise a cheer for flags anew,
In linting’s dance, we bid adieu! 🎉


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?

❤️ Share
🪧 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>, please review it.
    • 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 @coderabbitai in 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 @coderabbitai in 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@github-actions github-actions bot added Task A simple Todo Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product labels Sep 25, 2024
@ayushpahwa ayushpahwa added the ok-to-test Required label for CI label Sep 25, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Sep 25, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
app/client/src/ce/entities/FeatureFlag.ts (1)

33-33: Pop quiz! What's missing from our new feature flag?

While you've done a great job adding the new feature flag, we're missing an important element – can anyone guess what it is? That's right, a comment!

Let's add a brief explanation about what this flag does. It's like leaving a note for the next person who reads this code. Here's an example of what you could add:

// Controls the rollout of ESLint migration. When true, enables ESLint; when false, uses the previous linting setup.
rollout_eslint_enabled: "rollout_eslint_enabled",

Remember, clear communication is key in coding, just like in the classroom!

app/client/src/plugins/Linting/utils/getLintingErrors.ts (1)

Line range hint 213-225: Let's ensure ESLint is actually being utilized when intended.

Dear student, while you've correctly set up the getLinterVersion function to select between JSHint and ESLint, the current implementation always calls jshint for linting. This means that even when linterVersion is set to LINTER_VERSION.ESLINT, ESLint isn't being invoked. It's important to adjust the code so that the appropriate linter is called based on the feature flag.

Consider modifying the code as follows to conditionally use the selected linter:

profileFn(
  "Linter",
  // Adding metrics to compare performance between linters
  {
    linter: linterVersion,
    linesOfCodeLinted: originalBinding.split("\n").length,
    codeSizeInChars: originalBinding.length,
  },
- () => jshint(script, lintingOptions),
+ () => {
+   if (linterVersion === LINTER_VERSION.JSHINT) {
+     return jshint(script, lintingOptions);
+   } else if (linterVersion === LINTER_VERSION.ESLINT) {
+     return eslint(script, lintingOptions);
+   }
+ },
);

This adjustment ensures that the correct linter is invoked based on the linterVersion.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cdb22f4 and 8c4ad0f.

📒 Files selected for processing (3)
  • app/client/src/ce/entities/FeatureFlag.ts (2 hunks)
  • app/client/src/plugins/Linting/constants.ts (1 hunks)
  • app/client/src/plugins/Linting/utils/getLintingErrors.ts (4 hunks)
🧰 Additional context used
Biome
app/client/src/plugins/Linting/constants.ts

[error] 5-8: The enum declaration should not be const

Const enums are not supported by bundlers and are incompatible with the 'isolatedModules' mode. Their use can lead to import inexistent values.
See TypeScript Docs for more details.
Safe fix: Turn the const enum into a regular enum.

(lint/suspicious/noConstEnum)

🔇 Additional comments not posted (4)
app/client/src/ce/entities/FeatureFlag.ts (2)

33-33: Well done, class! This addition follows our naming convention perfectly.

The new feature flag rollout_eslint_enabled has been added correctly to the FEATURE_FLAG object. It's like you've been paying attention to our lessons on consistency and naming conventions. Keep up the good work!


79-79: Excellent job setting the default value, students!

You've correctly added the default value for rollout_eslint_enabled and set it to false. This is like putting training wheels on a bicycle – it allows us to control the rollout of the ESLint migration carefully. Remember, we want to walk before we run!

Can anyone tell me why setting this to false by default is a good idea? That's right, it allows us to enable the feature gradually and monitor its impact. Good thinking!

app/client/src/plugins/Linting/utils/getLintingErrors.ts (2)

28-28: Ensure 'LINTER_VERSION' is correctly exported from '../constants'.

It's crucial to make sure that LINTER_VERSION is properly defined and exported in your constants file. This prevents any potential import errors and keeps your code functioning smoothly.


50-51: Double-check your feature flag references.

Remember, it's important to verify that the feature flag rollout_eslint_enabled is correctly retrieved and matches the one defined in your configuration. This ensures that the feature flag controls the linter selection as intended.

To confirm the feature flag is correctly defined and used, you can run the following script:

✅ Verification successful

Verify Feature Flag Definition

Please ensure that rollout_eslint_enabled is properly defined in FeatureFlag.ts by running the following script:


Locate Feature Flag Definition

Please run the following script to find where rollout_eslint_enabled is defined in the codebase:


Feature Flag rollout_eslint_enabled is Properly Defined and Referenced

The feature flag rollout_eslint_enabled is correctly defined in FeatureFlag.ts and appropriately referenced in getLintingErrors.ts. This ensures that the feature flag controls the linter selection as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that 'rollout_eslint_enabled' is properly defined and referenced.

# Expected result: The feature flag should be present in 'FeatureFlag.ts' and used in the codebase.
rg 'FEATURE_FLAG\.rollout_eslint_enabled'

Length of output: 156


Script:

#!/bin/bash
# Description: Confirm that 'rollout_eslint_enabled' is defined in FeatureFlag.ts.

# Expected result: The feature flag should be present in 'FeatureFlag.ts'.
rg 'rollout_eslint_enabled' app/client/src/plugins/Linting/utils/FeatureFlag.ts

Length of output: 171


Script:

#!/bin/bash
# Description: Search the entire codebase for the definition of 'rollout_eslint_enabled'

# Expected result: The feature flag should be defined in one or more files.
rg 'rollout_eslint_enabled'

Length of output: 309

app/client/src/plugins/Linting/constants.ts Outdated Show resolved Hide resolved
app/client/src/plugins/Linting/utils/getLintingErrors.ts Outdated Show resolved Hide resolved
@@ -2,6 +2,11 @@ import { ECMA_VERSION } from "@shared/ast";
import type { LintOptions } from "jshint";
import isEntityFunction from "./utils/isEntityFunction";

export enum LINTER_VERSION {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be something self explanatory ? Version suffix seems to be in number or so, Is LINTER_TYPE what you are looking for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
app/client/src/ce/entities/FeatureFlag.ts (1)

33-33: Well done, class! Let's discuss the new feature flag.

I'm pleased to see the addition of the rollout_eslint_enabled feature flag. It's like adding a new tool to our classroom toolkit! This aligns perfectly with our lesson plan of implementing a feature flag for ESLint migration.

Remember, students, it's important to document our work. Have you updated the class notes (documentation) to explain this new feature flag?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 35c9441 and 1298a8f.

📒 Files selected for processing (1)
  • app/client/src/ce/entities/FeatureFlag.ts (2 hunks)
🧰 Additional context used

app/client/src/ce/entities/FeatureFlag.ts Outdated Show resolved Hide resolved
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Oct 23, 2024
Copy link

github-actions bot commented Nov 2, 2024

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Nov 2, 2024
@ayushpahwa ayushpahwa reopened this Nov 6, 2024
@ayushpahwa ayushpahwa merged commit 5af1bbe into release Nov 12, 2024
43 checks passed
@ayushpahwa ayushpahwa deleted the feat/eslint/feature-flag branch November 12, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request ok-to-test Required label for CI Stale Task A simple Todo Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add feature flag for eslint migration
2 participants