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

refactor: extend eslint #11934

Merged
merged 57 commits into from
Jun 25, 2024
Merged

Conversation

TylerAPfledderer
Copy link
Contributor

@TylerAPfledderer TylerAPfledderer commented Jan 16, 2024

Originally in the NextJS forked repo as ethereum#267

Description

This PR introduces the following packages for the Eslint configuration:

  • @typescript-eslint/eslint-plugin: extends a recommended set of rules for Typescript and supersedes some existing eslint rules for improved checks.
  • @typescript-eslint/parser: required parser for all sourced files
  • eslint-plugin-unused-imports: plugin to allow for auto fixing unused imports

See typescript-eslint docs to view the recommended rules configuration and other possible configurations available.

See the eslint-plugin-unused-imports repo for an overview of this plugin.

In addition, add the next configuration along with next/core-web-vitals to ensure the framework's recommended rules are being accounted for.

Additional Information

In the eslint config, extending @typescript-eslint:recommended-type-checked instead of *:recommended catches unsafe types, unsafe type overrides, unnecessary type assertions, etc. that can bleed into the project. i.e. JSON.parse() will always return any, and adding a type assertion to it would be beneficial if using the resulting object later.

This will add a lot of errors and warnings about any in this project!

Related Issue

Copy link

netlify bot commented Jan 16, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit b256102
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/6678858054e1920008f3b1cc
😎 Deploy Preview https://deploy-preview-11934--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 42 (🔴 down 5 from production)
Accessibility: 92 (no change from production)
Best Practices: 83 (🔴 down 9 from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies internal 🏠 tooling 🔧 Changes related to tooling of the project labels Jan 16, 2024
@TylerAPfledderer
Copy link
Contributor Author

Throwing back into draft to address type errors caught after running yarn tsc.

@TylerAPfledderer TylerAPfledderer marked this pull request as draft January 16, 2024 06:03
@@ -1,11 +1,20 @@
{
"extends": [
"eslint:recommended",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this configuration. Each line does the following:


import type { Lang } from "../lib/types"

type Summary = Record<string, string[]>

const argv = require("minimist")(process.argv.slice(2))
const argv = minimist(process.argv.slice(2))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the require statement was left, there would be the following error:

 Error: Require statement not part of import statement.  @typescript-eslint/no-var-requires

@wackerow wackerow added config ⚙️ Changes to configuration files and removed internal 🏠 labels May 22, 2024
Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

Looking good overall!
cc @pettinarip if you have thoughts, but this looks almost ready

src/lib/rehype/remarkInferToc.ts Outdated Show resolved Hide resolved
src/components/UpcomingEventsList.tsx Show resolved Hide resolved
"simple-import-sort/exports": "error"
"simple-import-sort/exports": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
Copy link
Member

Choose a reason for hiding this comment

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

Can we just modify to use "^_$" so the _ must be the first/only/last character for it to match? Then we can make that an error, without it being triggered by the _ placeholder variables

@wackerow wackerow requested a review from pettinarip June 18, 2024 22:58
"simple-import-sort/exports": "error"
"simple-import-sort/exports": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to not allow an arg like _variable, just want to make sure we can still use _ as an unused placeholder var. Sounds like this is good where it's at.

@wackerow wackerow merged commit 439edc3 into ethereum:dev Jun 25, 2024
10 checks passed
@TylerAPfledderer TylerAPfledderer deleted the refactor/extend-eslint branch June 25, 2024 03:31
This was referenced Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config ⚙️ Changes to configuration files content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Add additional ESLint configurations
3 participants