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

💅 noExcessiveNestedTestSuites rule violated by Zod schema #2599

Closed
1 task done
lukehedger opened this issue Apr 25, 2024 · 5 comments · Fixed by #2793
Closed
1 task done

💅 noExcessiveNestedTestSuites rule violated by Zod schema #2599

lukehedger opened this issue Apr 25, 2024 · 5 comments · Fixed by #2793
Assignees
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

@lukehedger
Copy link

Environment information

CLI:
  Version:                      1.7.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.2.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/9.6.6"

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

Linter:
  Recommended:                  false
  All:                          false
  Rules:                        complexity/useLiteralKeys = "off"
                                complexity/useOptionalChain = "warn"
                                correctness/noUnreachableSuper = "off"
                                correctness/noUnusedVariables = "warn"
                                performance/noDelete = "off"
                                style/noNonNullAssertion = "off"
                                style/useNamingConvention = "off"
                                suspicious/noExplicitAny = "off"
                                suspicious/noRedeclare = "off"
                                suspicious/noShadowRestrictedNames = "off"

Workspace:
  Open Documents:               0

Rule name

noExcessiveNestedTestSuites

Playground link

https://biomejs.dev/playground/?code=egAuAG8AYgBqAGUAYwB0ACgAewB9ACkACgAgACAALgBkAGUAcwBjAHIAaQBiAGUAKAAnACcAKQAKACAAIAAuAGQAZQBzAGMAcgBpAGIAZQAoACcAJwApAAoAIAAgAC4AZABlAHMAYwByAGkAYgBlACgAJwAnACkACgAgACAALgBkAGUAcwBjAHIAaQBiAGUAKAAnACcAKQAKACAAIAAuAGQAZQBzAGMAcgBpAGIAZQAoACcAJwApAAoAIAAgAC4AZABlAHMAYwByAGkAYgBlACgAJwAnACkAOwA%3D

Expected result

A Zod schema definition with multiple .describe() statements should not violate the noExcessiveNestedTestSuites rule

For example:

z.object({})
  .describe('')
  .describe('')
  .describe('')
  .describe('')
  .describe('')
  .describe('');

Currently throws:

Excessive `describe()` nesting detected. biome(lint/complexity/noExcessiveNestedTestSuites)

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 Apr 25, 2024
@dyc3
Copy link
Contributor

dyc3 commented May 9, 2024

I think I can pick this one up.

@Arnagos
Copy link

Arnagos commented Jul 3, 2024

@dyc3 This issues is still present in the current version (1.8.3).
Specifically for deeply nested schemas like this:

import { z } from 'zod';

export const Schema = z
  .object({
    groups: z
      .array(
        z
          .object({
            id: z.string(),
            caption: z.string().describe('Description'),
            items: z
              .array(
                z
                  .object({
                    id: z.string(),
                    caption: z.string().describe('Description'),
                    hasWarning: z.boolean().describe('Description').readonly(),
                    states: z.array(z.string()).describe('Description'),
                    control: z.object({ id: z.string() }).strict().describe('Description')
                  })
                  .strict()
                  .describe('Description')
              )
              .describe('Description')
          })
          .strict()
          .describe('Description')
      )
      .describe('Description')
  })
  .strict()
  .describe('Defines a product.');

@dyc3
Copy link
Contributor

dyc3 commented Jul 3, 2024

I'll take a look.

@Arnagos
Copy link

Arnagos commented Jul 3, 2024

@dyc3 I've updated the schema once again. The error specifically appears when adding the .describe('Defines a product.'); on the last line.

@dyc3
Copy link
Contributor

dyc3 commented Jul 3, 2024

I've submitted a new fix in #3346

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
4 participants