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

chore(website): fixed most no-unnecessary-condition complaints #7836

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Makes progress on fixing existing @typescript-eslint/no-unnecessary-condition violations under packages/website. Part of a series of PRs that split this up, as there are many of them.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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.

@netlify
Copy link

netlify bot commented Oct 25, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 9310882
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/656625e9a4b8170008abc630
😎 Deploy Preview https://deploy-preview-7836--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: 99 (🟢 up 11 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 your Netlify site configuration.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review October 25, 2023 12:34
@bradzacher bradzacher added the repo maintenance things to do with maintenance of the repo, and not with code/docs label Nov 10, 2023
bradzacher
bradzacher previously approved these changes Nov 10, 2023
@bradzacher bradzacher added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Nov 10, 2023
@@ -267,7 +267,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
return debounce(() => editor.layout(), 1);
}, [editor]);

const container = editor.getContainerDomNode?.() ?? editor.getDomNode();
const container = editor.getContainerDomNode();
Copy link
Member

Choose a reason for hiding this comment

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

this is not correct, as this part of code is neccesary for some older versions of playground (older version of ts)

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 confused, where are those types defined? The editor.api.d.ts I see has getContainerDomNode(): HTMLElement; - and I thought we're settled on just one editor version?

@@ -50,7 +50,7 @@ export function getRuleJsonSchemaWithErrorLevel(
};
}
// example: naming-convention rule
if (typeof ruleSchema.items === 'object' && ruleSchema.items) {
if (typeof ruleSchema.items === 'object') {
Copy link
Member

@armano2 armano2 Nov 10, 2023

Choose a reason for hiding this comment

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

typeof null === 'object' // true

Copy link
Member

@bradzacher bradzacher Nov 11, 2023

Choose a reason for hiding this comment

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

I think in the context of the types it's probably defined as items?: T[] - hence the typeof is enough to refine the types correctly?
This was a strictness change we added in v6.

We could probably even change this check to be "cleaner" but it'll do fine like this I think

Copy link
Member Author

@JoshuaKGoldberg JoshuaKGoldberg Nov 13, 2023

Choose a reason for hiding this comment

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

Yeah I don't see any null values for items in any ESLint or typescript-eslint rule. Is there a reason to support it?

@@ -67,7 +67,7 @@ export function TypeInfo({
onHoverNode,
}: TypeInfoProps): React.JSX.Element {
const computed = useMemo(() => {
if (!typeChecker || !value) {
if (!typeChecker) {
Copy link
Member

Choose a reason for hiding this comment

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

this is not correct

Copy link
Member

Choose a reason for hiding this comment

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

@armano2 according to the types it is - the property value is defined as readonly value: Node and it's never reassigned in the component body

@@ -48,15 +48,13 @@ export function TypesDetails({
value={value}
/>
</div>
{selectedNode && (
Copy link
Member

Choose a reason for hiding this comment

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

selectedNode may be undefined

Copy link
Member

@bradzacher bradzacher Nov 11, 2023

Choose a reason for hiding this comment

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

@armano2 based on the types it can't be.
the initial value passed to useState is typed as readonly value: Node.
Then the only call to setSelectedNode is guarded by if (item.node) { setSelectedNode(item.node) }

unless, of course, SimplifiedTreeView can make it undefined? But based on its types it can't do that I believe (or else there would be a type error on its onSelect prop with this change)

@JoshuaKGoldberg JoshuaKGoldberg changed the title chore(website): fixed no-unnecessary-condition complaints chore(website): fixed most no-unnecessary-condition complaints Nov 28, 2023
@JoshuaKGoldberg JoshuaKGoldberg merged commit b872154 into typescript-eslint:main Nov 28, 2023
59 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the lint-enable-no-unnecessary-condition-website branch November 28, 2023 22:36
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2023
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 repo maintenance things to do with maintenance of the repo, and not with code/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants