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

🐛 Override behavior with multiple matches #3176

Closed
Conaclos opened this issue Jun 11, 2024 Discussed in #3166 · 1 comment · Fixed by #3183
Closed

🐛 Override behavior with multiple matches #3176

Conaclos opened this issue Jun 11, 2024 Discussed in #3166 · 1 comment · Fixed by #3183
Assignees
Labels
A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@Conaclos
Copy link
Member

Discussed in #3166

Originally posted by redbmk June 10, 2024
I'm not sure if this is a bug so starting it out as a discussion.

I expected to be able to add multiple blocks of "overrides" and have items that have multiple matches pick up all of the overrides.

Here's a simplified example of my setup:

{
  "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "correctness": { "all": true, "noUndeclaredVariables": "error" },
      "suspicious": { "noConsoleLog": "warn" }
    }
  },
  "overrides": [
    { "include": ["scripts/k6.js"], "javascript": { "globals": ["__ENV", "__VU"] } },
    {
      "include": ["scripts"],
      "linter": { "rules": { "suspicious": { "noConsoleLog": "off" } } }
    }
  ]
}

and lets say somewhere in scripts/k6.js I have console.log({ __ENV, __VU })

If I have it set up like this, then scripts/k6.js throws errors that __ENV and __VU are undeclared. If I swap the order of the two override sections, it picks up on the globals but then throws warnings that I'm using console.log.

I'm having trouble finding documentation on how exactly the overrides work.

Is there a way I can update the overrides so that scripts/k6.js has both those overrides without having to repeat the noConsoleLog override?

@Conaclos Conaclos added A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug labels Jun 11, 2024
@Conaclos
Copy link
Member Author

It seems that we propagate the base settings to every override item.
Thus, the following config:

{
  "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
  "linter": {
    "rules": {
      "suspicious": { "noConsoleLog": "warn" }
    }
  },
  "overrides": [
    {
      "include": ["index.js"], 
        "javascript": { "globals": ["__ENV", "__VU"] }
    }, {
      "include": ["index.js"],
      "linter": { "rules": { "suspicious": { "noConsoleLog": "off" } } },
    }
  ]
}

is resolved to:

{
  "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
  "linter": {
    "rules": {
      "suspicious": { "noConsoleLog": "warn" }
    }
  },
  "overrides": [
    {
      "include": ["index.js"], 
      "linter": {
        "rules": {
          "suspicious": { "noConsoleLog": "warn" }
        },
        "javascript": { "globals": ["__ENV", "__VU"] }
    }, {
      "include": ["index.js"],
      "linter": { "rules": { "suspicious": { "noConsoleLog": "off" } } },
      "javascript": { "globals": [] } },
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Project Area: project 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.

1 participant