Add linting for non-null-assertion #2297

Closed
opened 2026-04-05 16:57:25 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @chibuike-okpara on 5/17/2022

Add linting for non-null-assertion

This would restrict us from writing codes like:

const foo: { bar: number } | null = null;
const bar = foo!!!.bar;

Correct way is

function foo(bar?: { n: number }) {
  return bar?.n;
}

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Assign yourself to the PR
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Label it as "needs-review"
  • Have you lint your code locally before submission?
  • Did you write tests where appropiate?

closes #88

Screenshots (if appropriate):

*Originally created by @chibuike-okpara on 5/17/2022* ### Add linting for non-null-assertion ### This would restrict us from writing codes like: ``` const foo: { bar: number } | null = null; const bar = foo!!!.bar; ``` ### Correct way is ``` function foo(bar?: { n: number }) { return bar?.n; } ``` ### Pull Request Checklist: - [x] Please make sure all jobs pass before requesting a review. - [x] Assign yourself to the PR - [x] Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). - [x] Label it as "needs-review" - [x] Have you lint your code locally before submission? - [ ] Did you write tests where appropiate? ### Related Issue? closes #88 ### Screenshots (if appropriate):
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#2297