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

(unsafe) 🐛 Forbidden non-null assertion lint/style/noNonNullAssertion creates a bad fix #1748

Closed
1 task done
nevercast opened this issue Feb 4, 2024 · 0 comments · Fixed by #1757
Closed
1 task done
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@nevercast
Copy link

nevercast commented Feb 4, 2024

Environment information

CLI:
  Version:                      1.5.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v16.20.2"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/8.19.4"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

npx @biomejs/biome check --apply-unsafe .
class LookupComponent {
  model: any;
  otherOptionFieldName: string | null = null;

  getOtherFieldName() {
    if (this.hasOtherOption) {
-      return this.model[this.otherOptionFieldName!];
+      return this.otherOptionFieldName?.[this.otherOptionFieldName];
    }
    return "";
  }
  
}

Expected result

I expect the change to make sense, or to be untouched.

I recognize that this is an unsafe fixer, I am reporting it only to aid the development of the functionality. I do expect unsafe fixers to be unsafe.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants