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

💅 noMisplacedAssertion - allow expect inside waitFor #2474

Closed
1 task done
ipanasenko opened this issue Apr 15, 2024 · 0 comments · Fixed by #2521
Closed
1 task done

💅 noMisplacedAssertion - allow expect inside waitFor #2474

ipanasenko opened this issue Apr 15, 2024 · 0 comments · Fixed by #2521
Assignees
Labels
A-Linter Area: linter S-Enhancement Status: Improve an existing feature

Comments

@ipanasenko
Copy link
Contributor

Environment information

CLI:
  Version:                      1.7.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.19.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.2.4"

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

Linter:
  Recommended:                  true
  All:                          false
  Rules:                        a11y/noSvgWithoutTitle = "off"
                                a11y/useKeyWithClickEvents = "off"
                                a11y/useKeyWithMouseEvents = "off"
                                a11y/useValidAnchor = "off"
                                complexity/noExcessiveNestedTestSuites = "error"
                                complexity/noUselessLoneBlockStatements = "error"
                                complexity/noUselessTernary = "error"
                                correctness/noInvalidUseBeforeDeclaration = "off"
                                correctness/noNewSymbol = "error"
                                correctness/noUnusedImports = "error"
                                correctness/noUnusedPrivateClassMembers = "error"
                                correctness/noUnusedVariables = "error"
                                correctness/useExhaustiveDependencies = "off"
                                correctness/useHookAtTopLevel = "error"
                                nursery/noConstantMathMinMaxClamp = "error"
                                nursery/noEvolvingAny = "error"
                                nursery/noFlatMapIdentity = "error"
                                nursery/noMisplacedAssertion = "error"
                                nursery/noUndeclaredDependencies = "off"
                                performance/noDelete = "off"
                                style/noNegationElse = "error"
                                style/noNonNullAssertion = "off"
                                style/noRestrictedGlobals = "error"
                                style/noShoutyConstants = "error"
                                style/noUnusedTemplateLiteral = "off"
                                style/useBlockStatements = "error"
                                style/useCollapsedElseIf = "error"
                                style/useForOf = "error"
                                style/useImportType = "error"
                                style/useNodejsImportProtocol = "error"
                                style/useNumberNamespace = "error"
                                style/useShorthandAssign = "error"
                                style/useShorthandFunctionType = "error"
                                style/useSingleCaseStatement = "error"
                                suspicious/noConsoleLog = "error"
                                suspicious/noRedeclare = "off"
                                suspicious/noSkippedTests = "off"

Workspace:
  Open Documents:               0

Rule name

noMisplacedAssertion

Playground link

https://biomejs.dev/playground/?lintRules=all&code=aQBtAHAAbwByAHQAIAB7ACAAdwBhAGkAdABGAG8AcgAgAH0AIABmAHIAbwBtACAAJwBAAHQAZQBzAHQAaQBuAGcALQBsAGkAYgByAGEAcgB5AC8AcgBlAGEAYwB0ACcAOwAKAAoAYQB3AGEAaQB0ACAAdwBhAGkAdABGAG8AcgAoACgAKQAgAD0APgAgAHsACgAgACAAZQB4AHAAZQBjAHQAKAAxADEAMQApAC4AdABvAEIAZQAoADIAMgAyACkAOwAKAH0AKQA7AA%3D%3D

Expected result

Testing Library officially suggests to use expect inside waitFor to wait for something. I think noMisplacedAssertion should allow this.

Also, sometimes it's handy to create own helper expect function, e.g. const expectSomeStuffToMatch = (stuff) => expect(stuff).toMatch(). Would be handy to allow using expect inside other functions which names start with expect as well.

Maybe a config for this rule with additional allowed function names?

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico ematipico added A-Linter Area: linter S-Enhancement Status: Improve an existing feature labels Apr 19, 2024
@ematipico ematipico self-assigned this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter S-Enhancement Status: Improve an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants