Problem/Motivation

In the Drupal core JavaScript, some of string comparison checks that starting with a specific text or ending with a specific text. I think these comparisons are suitable to use String.prototype.startsWith() or String.prototype.endsWith().

Ref: https://github.com/typescript-eslint/typescript-eslint/issues/285

Proposed resolution

Use String.prototype.startsWith() or String.prototype.endsWith().

https://git.drupalcode.org/project/drupal/-/merge_requests/7411

Remaining tasks

User interface changes

No.

API changes

No.

Data model changes

No.

CommentFileSizeAuthor
#6 3439646-nr-bot.txt90 bytesneeds-review-queue-bot

Issue fork drupal-3439646

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Tom Konda created an issue. See original summary.

tom konda’s picture

Issue summary: View changes
Status: Active » Needs work

Some of PHPUnit Functional Javascript tests and Nightwatch tests are failed.
Need to resolve failed tests.

nod_’s picture

is there an associated eslint rule to enforce this?

nod_’s picture

Status: Needs work » Needs review

tests are green, changes looks good

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

tom konda’s picture

@nod_ No, I think no rule is found in ESLint plugins for vanilla JavaScript at this point.
"typescript-eslint" plugin has ESLint rule but this rule is for TypeScript.

sakthi_dev made their first commit to this issue’s fork.

sakthi_dev’s picture

Rebased with the latest changes in 11.x. Please review.

tom konda’s picture

@sakthi_dev After commit id 135e3ba1 original script size is changed, so need to recalculate script size.

tom konda’s picture

Status: Needs work » Needs review

All tests are passed. Please review.

tom konda’s picture

Status: Needs review » Needs work

MR has conflict because of testing file changing at commit 05e4d1a8. Need to resolve this conflict.

tom konda’s picture

Status: Needs work » Needs review

Merge test file changing at commit 05e4d1a8 to the MR and all tests are passed.
Please review.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Left some comments on the MR.

tom konda’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback appears to be addressed

  • nod_ committed 270f95ac on 10.3.x
    Issue #3439646 by Tom Konda, smustgrave: Some of string comparisons...

  • nod_ committed 05b6144b on 10.4.x
    Issue #3439646 by Tom Konda, smustgrave: Some of string comparisons...

  • nod_ committed cc355625 on 11.0.x
    Issue #3439646 by Tom Konda, smustgrave: Some of string comparisons...

  • nod_ committed f5cc6545 on 11.x
    Issue #3439646 by Tom Konda, smustgrave: Some of string comparisons...
nod_’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed f5cc65456a to 11.x and cc355625ad to 11.0.x and 05b6144bd0 to 10.4.x and 270f95ac48 to 10.3.x. Thanks!

smustgrave’s picture

Can't tell but this one may be causing random failures on 11.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.