Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(utils): add defaultOptions to meta in rule#10339

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 18 commits intotypescript-eslint:mainfromLuisUrrutia:main
Nov 17, 2024

Conversation

LuisUrrutia
Copy link
Contributor

@LuisUrrutiaLuisUrrutia commentedNov 16, 2024
edited
Loading

PR Checklist

Overview

ESLint v9.15.0 introduces default options using themeta.defaultOptions property. This PR updates the rules to adddefaultOptions property tometa object, and retains the previousdefaultOptions placement to ensure backward compatibility.

azat-io, aditya-arcot, Fish1, and viceice reacted with thumbs up emojikirkwaiblinger, kirillgroshkov, Fish1, viceice, and sigerello reacted with heart emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@LuisUrrutia!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedNov 16, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit0537ef6
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/673965bc1e8ea90008217d3a
😎 Deploy Previewhttps://deploy-preview-10339--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedNov 16, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit0537ef6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 fromNxCloud.

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

thanks for doing this!
a few comments but it's looking good so far!

Comment on lines 72 to 73

defaultOptions?: Options;
Copy link
Member

Choose a reason for hiding this comment

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

All properties need JSDoc!

Suggested change
defaultOptions?:Options;
/**
*Specifiesdefaultoptionsfortherule.Ifpresent, anyuser-providedoptionsintheirconfigwillbemergedontopofthemrecursively.
*Thismergingwillbeapplieddirectlyto`context.options`.
*Ifyouwantbackwards-compatiblesupportforearlierESLintversion;consider usingthetop-level`defaultOptions`instead.
*
* @sinceESLint9.15.0
*/
defaultOptions?:Options;

aryaemami59 reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Added, but@since can't be used withESLint word.

bradzacher reacted with thumbs up emoji
Comment on lines 65 to 76
defaultOptions,
meta,
name,
...rule
}: Readonly<
RuleWithMetaAndName<Options, MessageIds, PluginDocs>
>): RuleModule<MessageIds, Options, PluginDocs> {
return createRule<Options, MessageIds, PluginDocs>({
defaultOptions,
meta: {
...meta,
defaultOptions,
Copy link
Member

Choose a reason for hiding this comment

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

It's worth noting that adding this to this function will fix the bug with base rule extensions because our codebase uses theRuleCreator function -- but it might leave the broader ecosystem in a weird state.
This will cause all rules to have a differentcontext.options value when run under ESLint v9.15.0 -- which could cause breakages in the ecosystem.

For reference -- currently we do not modify thecontext.options value -- meaning it exactly mirrors the value that a user sets in their config file and we instead pass the "merged options" in via a second argument --create(context, mergedOptions).
So if you passmeta.defaultOptions automatically then the first part of this behaviour no longer holds true and insteadcontext.options will represent the "merged options".

For now we should leave this function as-is, and instead update our extension rule implementation to passdefaultOptions both in the top-level location (for our current rule logic) and in themeta.defaultOptions location (for ESLint base rule logic).

LuisUrrutia reacted with eyes emoji
@@ -13,10 +13,11 @@ export type NamedCreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;

export type NamedCreateRuleMeta<
MessageIds extends string,
Options extends readonly unknown[],
Copy link
Member

Choose a reason for hiding this comment

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

Adding this new generic in this location is a breaking change.
It changes the meaning of existing code and could introduce type errors.
Instead it must be added after all type parameters AND it must be given a default value of[]

@bradzacherbradzacher added bugSomething isn't working awaiting responseIssues waiting for a reply from the OP or another party labelsNov 16, 2024
@LuisUrrutiaLuisUrrutia changed the titlefix(utils): add defaultOptions to metafix(utils): add defaultOptions to meta in ruleNov 16, 2024
@codecovCodecov
Copy link

codecovbot commentedNov 16, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.69%. Comparing base(57d343b) to head(0537ef6).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main   #10339      +/-   ##==========================================+ Coverage   86.63%   86.69%   +0.06%==========================================  Files         433      434       +1       Lines       15202    15227      +25       Branches     4439     4445       +6     ==========================================+ Hits        13170    13201      +31+ Misses       1675     1670       -5+ Partials      357      356       -1
FlagCoverage Δ
unittest86.69% <100.00%> (+0.06%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Files with missing linesCoverage Δ
...kages/eslint-plugin/src/rules/consistent-return.ts93.75% <100.00%> (+0.13%)⬆️
packages/eslint-plugin/src/rules/dot-notation.ts96.66% <100.00%> (+0.11%)⬆️
...kages/eslint-plugin/src/rules/init-declarations.ts100.00% <ø> (ø)
packages/eslint-plugin/src/rules/max-params.ts94.44% <ø> (ø)
...s/eslint-plugin/src/rules/no-dupe-class-members.ts100.00% <ø> (ø)
...kages/eslint-plugin/src/rules/no-empty-function.ts91.42% <100.00%> (+0.25%)⬆️
...ackages/eslint-plugin/src/rules/no-invalid-this.ts100.00% <100.00%> (ø)
packages/eslint-plugin/src/rules/no-loop-func.ts93.93% <ø> (ø)
...es/eslint-plugin/src/rules/no-loss-of-precision.ts100.00% <ø> (ø)
...ckages/eslint-plugin/src/rules/no-magic-numbers.ts84.72% <ø> (ø)
... and5 more

... and11 files with indirect coverage changes

@LuisUrrutia
Copy link
ContributorAuthor

@bradzacher I made the requested changes, but now I will add thedefaultOptions to other rules.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelNov 16, 2024
@bradzacher
Copy link
Member

bradzacher commentedNov 17, 2024
edited by kirkwaiblinger
Loading

Sorry about the commit spam.
I tested your PR against 9.15 and found that it introduced some unexpected breakages.
You had applied thedefaultOptions refactoring to every extension rule.
But this broke certain rules (egprefer-destructuring) due to their more complex schemas!

I just reverted some of the changes you made to limit them to exactly the rules touched ineslint/eslint#17656

kirkwaiblinger reacted with thumbs up emoji

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

thanks for doing this!
I have tested this against 9.15 and this looks good!

kirkwaiblinger reacted with thumbs up emoji
@bradzacherbradzacher merged commitf5e23e2 intotypescript-eslint:mainNov 17, 2024
62 checks passed
EduardoAC added a commit to EduardoAC/snap-components that referenced this pull requestNov 17, 2024
EduardoAC added a commit to EduardoAC/snap-components that referenced this pull requestNov 17, 2024
* Setup GitHub Actions for Pull request and main branch* Fix regression caused by typescript-eslint in combination with eslint@9.15.0Details on:typescript-eslint/typescript-eslint#10339* Resolve linter issues after updating packages
@pavelkornev
Copy link

When do you plan to release this fix?

yakobe and jlozovei reacted with thumbs up emoji

@bradzacher
Copy link
Member

Please see the issue linked in the OP

@typescript-eslinttypescript-eslint locked and limited conversation to collaboratorsNov 18, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
bugSomething isn't working
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug: [no-unused-expressions, no-empty-functions, possibly others...] extension rules crash with eslint v9.15.0
3 participants
@LuisUrrutia@bradzacher@pavelkornev

[8]ページ先頭

©2009-2025 Movatter.jp