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: Differences between linting and type checking #664

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

Conversation

JoshuaKGoldberg
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

Adds the blog post per #663.

What changes did you make? (Give an overview)

The post explains:

  1. The terminology difference between the two within "static analysis"
  2. Their differences in purpose: "can" vs. "should" 🧑‍🔬
  3. How linters are more granularly extensible with plugin rules
  4. Notes on their areas of overlap, with a suggestion to use linting only instead of TypeScript's noUnusedLocals and noUnusedParameters
  5. How linters and type checkers benefit from each other

In adding myself as an author, I noticed there wasn't yet support for Bluesky URLs. So I added that in too. I can split that out if preferred.

Related Issues

Fixes #663.

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

  • Is this too long a post for its intended purpose of convincing folks that using ESLint with TypeScript is beneficial?
  • This title is not very emphatic - would it be better to go with a more punchy one? I'm drawing a blank.
  • On the other hand, I worry that the phrasing is a bit ... sales-y? for typescript-eslint. My personal biases might be showing 🙂.
  • I also commented some questions inline about whether we can visualize rich code blocks nicely

Copy link

netlify bot commented Nov 26, 2024

Deploy Preview for es-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/es-eslint/deploys/67572cda25dfcc00087e42d0
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for ja-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/ja-eslint/deploys/67572cdafd9ae900072f7ace
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for new-eslint ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/new-eslint/deploys/67572cda50d900000836f031
😎 Deploy Preview https://deploy-preview-664--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.

// ~~~~~~~~~~~~~~~~~~~~~~~~~
// eslint(jsx-a11y/alt-text):
// img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Question] Is there a preferred strategy for showing ESLint rule reports in code blocks within blog posts?

Copy link

netlify bot commented Nov 26, 2024

Deploy Preview for hi-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/hi-eslint/deploys/67572cdaf883170008d3c188
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for zh-hans-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/zh-hans-eslint/deploys/67572cdabb38500008eb0836
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for fr-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/fr-eslint/deploys/67572cdad32e4b00082a8cb8
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for de-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/de-eslint/deploys/67572cda6df1e60008ab2ade
😎 Deploy Preview https://deploy-preview-664--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 Nov 26, 2024

Deploy Preview for pt-br-eslint ready!

Name Link
🔨 Latest commit cec8a69
🔍 Latest deploy log https://app.netlify.com/sites/pt-br-eslint/deploys/67572cda0ee8f90008e3606d
😎 Deploy Preview https://deploy-preview-664--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.

console.log("🍌");

// eslint(no-fallthrough):
// Expected a 'break' statement before 'case'.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't love this first example:

  • It's pretty verbose
  • It doesn't show something that's clearly, definitely a valuable report ("what if I want to break through, that's too opinionated!")

...but I couldn't find a better lint rule that:

  • Produces clear valuable report on a likely bug
  • Is in js.configs.recommended
  • Isn't superseded by TypeScript

Seeking inputs on a better example to show!

Copy link
Member

Choose a reason for hiding this comment

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

no-unused-vars? Although I guess TypeScript is now flagging that, too.

no-unexpected-multiline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, and no-unexpected-multiline is pretty much made unnecessary by formatters... sigh

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.

Ran out of time so just left some comments on the first bits. Overall, I think we need to work on clearing up the language and the message. I'll continue looking tomorrow.

I'd also like to pull out adding support Bluesky social links into a separate PR as it's not really related to the article.

2. **Linters**: execute individually configurable checks known as "lint rules"
3. **Type checkers**: collect all files into a full understanding of the project

We'll focus in this blog post on *linters*, namely ESLint, and *type checkers*, namely [TypeScript](https://typescriptlang.org).
Copy link
Member

Choose a reason for hiding this comment

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

I think we might want to expand this section a bit because both ESLint and TypeScript do more than one type of static analysis. For instance, ESLint also does scope analysis and code path analysis, while TypeScript does linting, scope analysis, and type checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 what would the benefit of that be? Now that the following section reports examples of each, what's the new info we'd want readers to know going in?

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.

After taking another look at this, I see two areas of improvement for this post:

  1. You need to decide whether you are talking about linters and type checkers generically, or ESLint and TypeScript, specifically. My recommendation is update the intro to talk about ESLint and TypeScript, take a step back to talk about what static analysis is generically, then explain which types ESLint and TypeScript use, and then continue on the rest of the blog post specifically talking about ESLint and TypeScript.
  2. Make sure to include examples when you're describing abstract concepts. A lot of the verbiage around static analysis will be unfamiliar to most readers (including "type-safe"), so grounding those descriptions with concrete examples is important.

console.log("🍌");

// eslint(no-fallthrough):
// Expected a 'break' statement before 'case'.
Copy link
Member

Choose a reason for hiding this comment

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

no-unused-vars? Although I guess TypeScript is now flagging that, too.

no-unexpected-multiline?

logUppercase(9001);
// ~~~~
// Argument of type 'number' is not assignable to parameter of type 'string'.
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Question] Is there a preferred strategy for showing TypeScript reports in code blocks within blog posts? (similar to the question about ESLint rule reports later on)

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.

This is looking a lot better. There is still some ambiguity over when we're talking about linters vs. ESLint itself, and I think we need to be careful about making claims about TypeScript does because it does more than just type checking.

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.

Blog post on why to use ESLint with TypeScript
3 participants