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

Appearance settings

fix(eslint-plugin): [init-declarations] refine report locations #8893

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

Conversation

kirkwaiblinger
Copy link
Member

PR Checklist

Overview

/* eslint @typescript-eslint/init-declarations: ["error", "always"] */
// before
let bar: number | undefined | string;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// after
let bar: number | undefined | string;
    ^^^

Note that the following example is unchanged

/* eslint @typescript-eslint/init-declarations: ["error", "never"] */
let bar: number | undefined | string = 3;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @kirkwaiblinger!

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 on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Apr 10, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 769eddc
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/665fb9afbd2b2000080e6f18
😎 Deploy Preview https://deploy-preview-8893--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: 95 (🔴 down 4 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (🔴 down 8 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 your Netlify site configuration.

Copy link

nx-cloud bot commented Apr 10, 2024

@kirkwaiblinger kirkwaiblinger changed the title fix(eslint-plugin): [init-declarations] refine report loc fix(eslint-plugin): [init-declarations] refine report locations Apr 10, 2024
@kirkwaiblinger kirkwaiblinger force-pushed the init-declarations-refine-report-loc branch from 6b5d7c2 to 06bfce3 Compare April 10, 2024 07:25
@kirkwaiblinger kirkwaiblinger force-pushed the init-declarations-refine-report-loc branch from 06bfce3 to 7ff131d Compare April 10, 2024 07:26
@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review April 10, 2024 07:42
@kirkwaiblinger kirkwaiblinger added the enhancement New feature or request label May 4, 2024
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM, sorry for missing this till now! 🚀

It'd be nice to try to get this fixed more cleanly in ESLint core... but my hunch is we don't have a super high chance of that getting accepted.

Hades from the Disney Hercules movie giving two flaming thumbs up

? reportOverride
: Reflect.get(context, prop, receiver),
});
}
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 a little awkward having to Proxy the base rule. Is there an issue that was ever filed on ESLint about better handling of report locations in this case? I couldn't find one. But even if it's declined as out-of-scope, it'd be good for reference.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure... I basically copied this pattern from

// we can't directly proxy `context` because its `report` property is non-configurable
// and non-writable. So we proxy `customContext` and redirect all
// property access to the original context except for `report`
const proxiedContext = new Proxy<typeof context>(
customContext as typeof context,
{
get(target, path, receiver): unknown {
if (path !== 'report') {
return Reflect.get(context, path, receiver);
}
return Reflect.get(target, path, receiver);
},
},
);

and

// we can't directly proxy `context` because its `report` property is non-configurable
// and non-writable. So we proxy `customContext` and redirect all
// property access to the original context except for `report`
return new Proxy<Context>(customContext as typeof context, {
get(target, path, receiver): unknown {
if (path !== 'report') {
return Reflect.get(context, path, receiver);
}
return Reflect.get(target, path, receiver);
},
});

And modified it with stylistic preferences.

Following the trail through the git history, it doesn't look like any investigation into alternatives or issues with eslint were documented in those.

(breadcrumbs)

Will plan to check for eslint issues on the topic before this PR gets merged

Copy link
Member

Choose a reason for hiding this comment

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

before this PR gets merged

Oh @kirkwaiblinger I was going to merge today for the Monday release and consider this a followup. But in that case I'll just let you merge whenever you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Followup makes sense to me too! 👍
Happy for us to merge for the release

Copy link
Member Author

Choose a reason for hiding this comment

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

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jun 2, 2024
@kirkwaiblinger kirkwaiblinger merged commit fbff4ce into typescript-eslint:main Jun 5, 2024
61 checks passed
@kirkwaiblinger kirkwaiblinger deleted the init-declarations-refine-report-loc branch June 5, 2024 02:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.