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

feat: blog: Code review nit to ecosystem improvements #629

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

captbaritone
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

Add a blog post reflecting on how ESLint helped a small nit I noticed in code review grow into a fundamental ecosystem improvement shipping in the newest version of TypeScript.

What changes did you make? (Give an overview)

Added a blog post

Related Issues

I previously submitted a blog post about this rule: https://github.com/eslint/eslint.org/pull/240/files

Is there anything you'd like reviewers to focus on?

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for new-eslint ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/new-eslint/deploys/66eb6b1fecea1100085ee75a
😎 Deploy Preview https://deploy-preview-629--new-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for hi-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/hi-eslint/deploys/66eb6b1f6c4b5100085f27fb
😎 Deploy Preview https://deploy-preview-629--hi-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for ja-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/ja-eslint/deploys/66eb6b1f2373040008c01bd4
😎 Deploy Preview https://deploy-preview-629--ja-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for zh-hans-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/zh-hans-eslint/deploys/66eb6b1f21d9190008101024
😎 Deploy Preview https://deploy-preview-629--zh-hans-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for fr-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/fr-eslint/deploys/66eb6b1fc82a860008fc8739
😎 Deploy Preview https://deploy-preview-629--fr-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for es-eslint ready!

Name Link
🔨 Latest commit ebd4167
🔍 Latest deploy log https://app.netlify.com/sites/es-eslint/deploys/66ea094bc8871e00088e0fe9
😎 Deploy Preview https://deploy-preview-629--es-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for pt-br-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/pt-br-eslint/deploys/66eb6b1f7c07c100086c1cc1
😎 Deploy Preview https://deploy-preview-629--pt-br-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for de-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/de-eslint/deploys/66eb6b1f35e7a90008e7c864
😎 Deploy Preview https://deploy-preview-629--de-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for es-eslint ready!

Name Link
🔨 Latest commit 42718fd
🔍 Latest deploy log https://app.netlify.com/sites/es-eslint/deploys/66eb6b1f1365680008bd0fe6
😎 Deploy Preview https://deploy-preview-629--es-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Member

@nzakas nzakas 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 putting this together. I feel like this is a great story that a lot of folks will enjoy. I left some suggestions for cleaning up grammar and formatting.

I also noted that I think it would be helpful to briefly explain what the rule does and the type of errors it picks up so folks don't have to click a link to get that context.

And I also left a note on the conclusion, which I think can be expanded a bit to review more of the specifics of this story.

@@ -0,0 +1,60 @@
---
layout: post
title: "Code review nit to ecosystem improvements"
Copy link
Member

Choose a reason for hiding this comment

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

Let's be more specific with the title:

Suggested change
title: "Code review nit to ecosystem improvements"
title: "no-unused-binary-expressions: From code review nit to ecosystem improvements"

---
layout: post
title: "Code review nit to ecosystem improvements"
teaser: "Reflecting on the power of lint rules"
Copy link
Member

Choose a reason for hiding this comment

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

A little more oomph:

Suggested change
teaser: "Reflecting on the power of lint rules"
teaser: "How implementing my first ESLint rule led to changes in how people write JavaScript"

---
Four years ago, while doing a code review at work, I was surprised that [Flow](https://flow.org/) had not warned about a null check that had become unnecessary. This month [TypeScript 5.6](https://devblogs.microsoft.com/typescript/announcing-typescript-5-6/#disallowed-nullish-and-truthy-checks1) released with validation rules that disallows nullish and truthy checks which uncovered nearly 100 existing bugs in the top 800 TypeScript repos on GitHub.

The two events are connected, because that moment in code review four years ago led me to write [a lint rule](https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/) which was part of the inspiration for the TypeScript features.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The two events are connected, because that moment in code review four years ago led me to write [a lint rule](https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/) which was part of the inspiration for the TypeScript features.
The two events are connected, because that moment in code review four years ago led me to write [the `no-unused-binary-expressions` rule](https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/) which helped inspire the TypeScript features.


The two events are connected, because that moment in code review four years ago led me to write [a lint rule](https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/) which was part of the inspiration for the TypeScript features.

Given the protracted timeline and the many intermediate steps I thought it would be interesting to reflect on what led to this observation in code review snowballing into what I feel is a significant impact to a large number of developers, and why I think the snowball could continue to grow.
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 a run-on sentence. I've taken a stab at breaking it up while trying to keep the original meaning.

Suggested change
Given the protracted timeline and the many intermediate steps I thought it would be interesting to reflect on what led to this observation in code review snowballing into what I feel is a significant impact to a large number of developers, and why I think the snowball could continue to grow.
Given the protracted timeline and the many intermediate steps, I thought it would be interesting to reflect on how we got here. How did this observation in one code review snowball into a significant positive impact to developers? And why does this snowball continue to grow?


Given the protracted timeline and the many intermediate steps I thought it would be interesting to reflect on what led to this observation in code review snowballing into what I feel is a significant impact to a large number of developers, and why I think the snowball could continue to grow.

First a timeline:
Copy link
Member

Choose a reason for hiding this comment

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

A little more of an intro here would be helpful.

Suggested change
First a timeline:
To answer these questions, it helps to review the timeline of events.

* ESLint’s pluggable architecture empowering me to write my own rule and easily deploy it across the whole company without needing to convince any gate keepers.
* The ESLint team’s openness to, and active support of, a new contributor adding a new core rule despite a [2020 policy](https://eslint.org/docs/latest/contribute/propose-new-rule) of only accepting new rules if they relate to new language features.
* Active communication about the work initiated by me, and amplified by the ESLint team, in the form of a blog post and Tweets. These allowed the TypeScript team to connect the dots between a more specific request they got about disallowing `if (/regex/)`, and the broader idea of detecting constant conditions.
* Having a somewhat obsessive personality which wasn’t satisfied with just pointing out a useless null check in code review, but saw that a fundamental solution to that class of problem was possible and wasn’t satisfied until that solution was enabled not just for me, my team or my company, but for the broader ecosystem.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Having a somewhat obsessive personality which wasn’t satisfied with just pointing out a useless null check in code review, but saw that a fundamental solution to that class of problem was possible and wasn’t satisfied until that solution was enabled not just for me, my team or my company, but for the broader ecosystem.
* My having a somewhat obsessive personality that wasn’t satisfied with just pointing out a useless null check in code review. Instead, I saw that a fundamental solution to that class of problem was possible, and I wasn’t satisfied until that solution was enabled not just for me, my team, or my company, but for the broader ecosystem.

Four years ago, while doing a code review at work, I was surprised that [Flow](https://flow.org/) had not warned about a null check that had become unnecessary. This month [TypeScript 5.6](https://devblogs.microsoft.com/typescript/announcing-typescript-5-6/#disallowed-nullish-and-truthy-checks1) released with validation rules that disallows nullish and truthy checks which uncovered nearly 100 existing bugs in the top 800 TypeScript repos on GitHub.

The two events are connected, because that moment in code review four years ago led me to write [a lint rule](https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/) which was part of the inspiration for the TypeScript features.

Copy link
Member

Choose a reason for hiding this comment

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

Before going into the timeline, I think it would be helpful to introduce the rule and show an example of an error it detects. So maybe a "What does the no-constant-binary-expression rule do?" section.

It’s taken four years for the ripple of Brad’s initial observation on that internal post to reach this point, but I think the ideas here have the potential to resonate even further:

* TypeScript and Flow could internally track types which they happen to know are sound, and opportunistically report errors based on that data, allowing checks like this to be performed in many many more cases.
* Other unsound languages which previously avoided reporting unnecessary checks for the same reason Flow did, could use this same approach to catch logic errors.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Other unsound languages which previously avoided reporting unnecessary checks for the same reason Flow did, could use this same approach to catch logic errors.
* Other unsound languages which previously avoided reporting unnecessary checks for the same reason Flow did could use this same approach to catch logic errors.


---

Thanks to [Brad Zacher](https://zacher.com.au/) for his initial key observation and ongoing encouragement, to [Nicholas C. Zakas](https://humanwhocodes.com/blog/) and [Milos Djermanovic](https://github.com/mdjermanovic) for significant contributions to the rule during code review, and to [Ryan Cavanaugh](https://twitter.com/SeaRyanC) for bringing these same types of validation to the TypeScript ecosystem.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Thanks to [Brad Zacher](https://zacher.com.au/) for his initial key observation and ongoing encouragement, to [Nicholas C. Zakas](https://humanwhocodes.com/blog/) and [Milos Djermanovic](https://github.com/mdjermanovic) for significant contributions to the rule during code review, and to [Ryan Cavanaugh](https://twitter.com/SeaRyanC) for bringing these same types of validation to the TypeScript ecosystem.
Thanks to [Brad Zacher](https://zacher.com.au/) for his initial key observation and ongoing encouragement, to [Nicholas C. Zakas](https://humanwhocodes.com/) and [Milos Djermanovic](https://github.com/mdjermanovic) for significant contributions to the rule during code review, and to [Ryan Cavanaugh](https://twitter.com/SeaRyanC) for bringing these same types of validation to the TypeScript ecosystem.


## Conclusion

Solving problems fundamentally requires the combined insights of many people, the persistence of stubborn individuals, active communication, a community that learns from each other, and often a lot of patience. But if you can make it happen, fundamental solutions scale really well. They apply broadly, can be adapted into other tools and domains, and improve the state of the world not just for developers but to the users those developers serve.
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see this conclusion expanded to talk a bit about the specifics of this story: how a group of developers discovered something that would be generally useful inside a company (for-profit), then used an open source (not-for-profit) project to spread that knowledge independently, ultimately reaching another company (for-profit), that then spread into another open source project (not-for-profit?), to reach an even larger audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Implementing
Development

Successfully merging this pull request may close these issues.

3 participants