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

💅 noDuplicateJsonKeys always marks the first key in object #2366

Closed
1 task done
luckydye opened this issue Apr 8, 2024 · 4 comments · Fixed by #2525
Closed
1 task done

💅 noDuplicateJsonKeys always marks the first key in object #2366

luckydye opened this issue Apr 8, 2024 · 4 comments · Fixed by #2525
Assignees
Labels
A-Linter Area: linter L-JSON Language: JSON and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@luckydye
Copy link

luckydye commented Apr 8, 2024

Environment information

CLI:
  Version:                      1.6.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "screen-256color"
  JS_RUNTIME_VERSION:           "v21.6.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.1.1"

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

Linter:
  Recommended:                  false
  All:                          false
  Rules:                        a11y/useKeyWithClickEvents = "off"
                                complexity/noForEach = "warn"
                                complexity/noStaticOnlyClass = "off"
                                nursery/noDuplicateJsonKeys = "error"
                                nursery/useSortedClasses = {"level":"warn","options":{"attributes":["class","className","classList"],"functions":["clsx","cva","twMerge","tw"]}}
                                style/noDefaultExport = "warn"
                                suspicious/noArrayIndexKey = "off"
                                suspicious/noConsoleLog = "warn"
                                suspicious/noExplicitAny = "warn"

Workspace:
  Open Documents:               0

Rule name

noDuplicateJsonKeys

Playground link

https://biomejs.dev/playground/?indentStyle=space&indentWidth=8&lintRules=all&files.main.json=ewAKACAAIAAiAG8AcAB0AGkAbwBuADEAIgA6ACAAIgBPAHAAdABpAG8AbgAgADEAIgAsAAoAIAAgACIAbwB0AGgAZQByAE8AcAB0AGkAbwBuACIAOgAgACIATwB0AGgAZQByACAAbwBwAHQAaQBvAG4AIgAsAAoAIAAgACIAZAB1AHAAbABpAGMAYQB0AGUASwBlAHkAIgA6ACAAIgBEAHUAcABsAGkAYwBhAHQAZQAgAGsAZQB5ACIALAAKACAAIAAiAGQAdQBwAGwAaQBjAGEAdABlAEsAZQB5ACIAOgAgACIARAB1AHAAbABpAGMAYQB0AGUAIABrAGUAeQAiACwACgAgACAAIgBsAGEAcwB0AE8AcAB0AGkAbwBuACIAOgAgACIATABhAHMAdAAgAG8AcAB0AGkAbwBuACIACgB9AA%3D%3D

Expected result

The lint error should be at the key that is actually a duplicate.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ah-yu ah-yu added A-Linter Area: linter L-JSON Language: JSON and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Apr 9, 2024
@arendjr
Copy link
Contributor

arendjr commented Apr 9, 2024

I think our diagnostics have the ability to highlight them both. I agree it might make more sense to display the main error on the second occurrence, and then we can add an additional info with something like “key already occurred here”.

@arendjr
Copy link
Contributor

arendjr commented Apr 9, 2024

Do we have the same problem with JS object literals, btw? Might be good to use the same approach for both.

@Sec-ant
Copy link
Contributor

Sec-ant commented Apr 9, 2024

@arendjr you may misunderstand the issue, the rule currently always marks the first key, even if it's not a duplicate key.

@arendjr
Copy link
Contributor

arendjr commented Apr 9, 2024

Oh, haha. Yeah, that's definitely an issue :D

@luckydye luckydye changed the title 💅 noDuplicateJsonKeys always marks the first key 💅 noDuplicateJsonKeys always marks the first key in object Apr 9, 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 L-JSON Language: JSON 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.

5 participants