Allow non-null assertions in tests; refactor two production hotspots to drop them

- eslint.config.js: disable no-non-null-assertion for *.test.ts/tsx and
  tests/** (fixture-driven tests routinely use arr[0]! after a length
  check — signal there is low).
- closestFlight.ts: replace flights.legs[0]! / flights[flights.length-1]!
  with explicit null checks.
- FlightDetailsAccordion.tsx: refactor transition + meal/service
  branches to use local consts narrowed by a preceding truthy check,
  dropping the `leg.transition!.registration!` patterns.

Warning count: 190 → 65. Remaining warnings are pre-existing production-code
non-null assertions spread across the codebase.
This commit is contained in:
2026-04-20 08:24:01 +03:00
parent a982d9a669
commit 5c47498472
3 changed files with 46 additions and 23 deletions
+12
View File
@@ -177,4 +177,16 @@ export default [
],
},
},
// Test files get a looser ruleset: non-null assertions are idiomatic
// when fixtures guarantee presence (`arr[0]!` after an explicit length
// check). Production code keeps the warning; tests don't.
{
files: [
"src/**/*.test.{ts,tsx}",
"tests/**/*.{ts,tsx}",
],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
},
},
];