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

infra(typescript-eslint): prefer-regexp-exec #2466

Merged
merged 6 commits into from
Oct 17, 2023

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Oct 10, 2023

Companion PR for #2435. This applies the changes from #2108 to newer code and ensures future code abides to the same rules.


Enables the @typescript-eslint/prefer-regexp-exec lint rule.


Reasoning: Regexp.exec behaves the same as string.match(RegExp) without /g flag, with the main difference being that exec gurantees the index to be present:

interface RegExpMatchArray extends Array<string> {
    /**
     * The index of the search at which the result was found.
     */
    index?: number;
    [...]
}

interface RegExpExecArray extends Array<string> {
    /**
     * The index of the search at which the result was found.
     */
    index: number;
    [...]
}

string.match(RegExp) without /g flag, also returns the index, but requires the not null assertion qualifier!.

@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: infra Changes to our infrastructure or project setup labels Oct 10, 2023
@ST-DDT ST-DDT added this to the vAnytime milestone Oct 10, 2023
@ST-DDT ST-DDT requested review from a team October 10, 2023 20:06
@ST-DDT ST-DDT self-assigned this Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #2466 (a29d2aa) into next (c033044) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2466   +/-   ##
=======================================
  Coverage   99.58%   99.59%           
=======================================
  Files        2823     2823           
  Lines      255517   255517           
  Branches     1103     1105    +2     
=======================================
+ Hits       254466   254474    +8     
+ Misses       1023     1015    -8     
  Partials       28       28           
Files Coverage Δ
src/modules/helpers/index.ts 98.98% <100.00%> (ø)

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: infra Changes to our infrastructure or project setup p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants