Ban the null literal via ESLint and replace existing usages with undefined or truthiness checks (#4401)

This commit is contained in:
Keavon Chambers
2026-08-03 23:47:29 -07:00
committed by GitHub
parent 79136c95be
commit 049b9dbc4d
4 changed files with 17 additions and 11 deletions

View File

@@ -73,6 +73,13 @@ export default defineConfig([
],
},
],
"no-restricted-syntax": [
"error",
{
selector: "Literal[raw='null']",
message: "Use `undefined` instead of `null`.",
},
],
// TypeScript plugin config (for TS-specific linting)
"@typescript-eslint/indent": "off",
@@ -96,7 +103,7 @@ export default defineConfig([
"@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }],
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
"@typescript-eslint/no-restricted-types": ["error", { types: { null: "Use `undefined` instead." } }],
"@typescript-eslint/no-restricted-types": ["error", { types: { null: "Use `undefined` instead of `null`." } }],
// Prettier plugin config (for validating and fixing formatting)
"prettier/prettier": "error",