Skip to content

Commit

Permalink
Relax no-use-before-define rule for TS/React files
Browse files Browse the repository at this point in the history
Reasoning in comments.

For TypeScript files, it's not clear to me why
@typescript-eslint/no-use-before-define defaults to `typedefs: true`:
<https://typescript-eslint.io/rules/no-use-before-define#typedefs>
  • Loading branch information
victorlin committed Nov 15, 2024
1 parent 1bbf263 commit 95b0ec0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions static-site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ ignorePatterns:
- public/

rules:
# The TypeScript compiler is able to handle usage of type definitions before
# they are defined.
no-use-before-define: off
"@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false, "typedefs": false }]

react/prop-types: off # Remove this override once all props have been typed using PropTypes or TypeScript.
'@next/next/no-img-element': off # Remove this if we use next.js optimisations for <img>
'@next/next/no-html-link-for-pages': off
Expand All @@ -35,6 +40,16 @@ overrides:
rules:
'@typescript-eslint/no-var-requires': off

# React components can use variables before they are defined.
# This isn't great, as jsx/tsx doesn't imply React usage, but it avoids
# unnecessary workarounds such as:
# https://github.com/nextstrain/auspice/commit/af4c742f3855fa90ea292b4882293ebc66ace853
- files:
- '**.[jt]sx'
rules:
no-use-before-define: off
"@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false, "variables": false }]

parserOptions:
sourceType: module
ecmaVersion: 2022
Expand Down

0 comments on commit 95b0ec0

Please sign in to comment.