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

📝 Empty line with no indentation between strings in comment: .graphql files #3924

Closed
1 task done
danielkaxis opened this issue Sep 16, 2024 · 5 comments · Fixed by #3993 or WomB0ComB0/portfolio#159 · May be fixed by WomB0ComB0/portfolio#157
Closed
1 task done
Assignees
Labels
A-Parser Area: parser L-GraphQL Language GraphQL S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@danielkaxis
Copy link

Environment information

CLI:
  Version:                      1.9.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.20.4"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/3.8.4"

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

Formatter:
  Format with errors:           false
  Indent style:                 Space
  Indent width:                 2
  Line ending:                  Lf
  Line width:                   80
  Attribute position:           Auto
  Bracket spacing:              BracketSpacing(true)
  Ignore:                       []
  Include:                      []

JavaScript Formatter:
  Enabled:                      false
  JSX quote style:              Single
  Quote properties:             Preserve
  Trailing commas:              Es5
  Semicolons:                   AsNeeded
  Arrow parentheses:            Always
  Bracket spacing:              unset
  Bracket same line:            false
  Quote style:                  Single
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Attribute position:           unset

JSON Formatter:
  Enabled:                      true
  Indent style:                 Space
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Trailing Commas:              unset

CSS Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Quote style:                  Double

GraphQL Formatter:
  Enabled:                      false
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Bracket spacing:              unset
  Quote style:                  unset

Workspace:
  Open Documents:               0

Configuration

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "organizeImports": {
    "enabled": true
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentWidth": 2
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": {
        "useAltText": "off",
        "useKeyWithClickEvents": "off",
        "noSvgWithoutTitle": "off",
        "noAriaUnsupportedElements": "off",
        "noNoninteractiveTabindex": "off",
        "useHeadingContent": "off",
        "useValidAriaRole": "off",
        "noLabelWithoutControl": "off",
        "useSemanticElements": "off"
      },
      "complexity": {
        "noForEach": "off",
        "useLiteralKeys": "off",
        "useSimpleNumberKeys": "off",
        "useArrowFunction": "off",
        "noUselessTernary": "off",
        "useRegexLiterals": "off"
      },
      "correctness": {
        "useIsNan": "off",
        "useHookAtTopLevel": "error",
        "noUnusedImports": "error"
      },
      "performance": {
        "noAccumulatingSpread": "off"
      },
      "style": {
        "useExponentiationOperator": "off",
        "noParameterAssign": "off",
        "useEnumInitializers": "off",
        "useFragmentSyntax": "error",
        "useLiteralEnumMembers": "off",
        "useNamingConvention": "off",
        "useImportType": "off",
        "useNumberNamespace": "off",
        "noUselessElse": "off",
        "useExportType": "off"
      },
      "suspicious": {
        "noArrayIndexKey": "off",
        "noConsoleLog": "off",
        "noImplicitAnyLet": "off",
        "noThenProperty": "off",
        "noExportsInTest": "off"
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "jsxQuoteStyle": "single",
      "semicolons": "asNeeded",
      "trailingCommas": "es5",
      "quoteProperties": "preserve"
    }
  },
  "json": {
    "formatter": {
      "enabled": true,
      "indentStyle": "space"
    },
    "parser": {
      "allowComments": true
    }
  }
}

Playground link

https://github.com/danielkaxis/biome-graphql-issue

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico
Copy link
Member

Any chance you can use the playground?

@Tigge
Copy link

Tigge commented Sep 17, 2024

Any chance you can use the playground?

https://biomejs.dev/playground/?files.main.graphql=dAB5AHAAZQAgAEYAbwBvACAAewAKACAAIAAiACIAIgAKACAAIABJACcAbQAgAGEAbgAgAGkAbgBkAGUAbgB0AGUAZAAgAGwAbwBuAGcAIABzAHQAcgBpAG4AZwAuAAoACgAgACAAVwBpAHQAaAAgAHQAdwBvACAAZQBtAHAAdAB5ACAAbABpAG4AZQBzAC4ACgAgACAAIgAiACIACgAgACAAYgBhAHIAOgAgAEkAbgB0AAoAfQA%3D

Here is a playground. Doesn't show any Biome output since it encounters this error:

Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: crates/biome_graphql_formatter/src/graphql/value/string_value.rs:45:51
Thread Name: biome::worker_5
Message: byte index 2 is out of bounds of ``

@ematipico
Copy link
Member

Awesome, thank you. It seems there's a parsing error

@Conaclos Conaclos added S-Bug-confirmed Status: report has been confirmed as a valid bug L-GraphQL Language GraphQL A-Parser Area: parser labels Sep 17, 2024
@ematipico
Copy link
Member

cc @vohoanglong0107

@vohoanglong0107 vohoanglong0107 self-assigned this Sep 17, 2024
@vohoanglong0107
Copy link
Contributor

I think I've found out the cause. In this line

join.entry(&dynamic_text(&line[min_indent..], start));

It's trying to remove the indentation from the comment by the minimum indent level of the entire block comment.

But at the same time, in this line

.filter(|line| !line.trim().is_empty()) // Ignore empty lines

The formatter explicitly ignores empty lines, so min_indent does not factor in empty lines in its calculation.
So when the formatter encounters an empty line, it still tries to extract min_indent from that line, which causes it to panic.

I will push a fix for this sometime tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser L-GraphQL Language GraphQL S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
5 participants