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

🐛 Some ignore pattern generate ignored file error #1471

Closed
1 task done
Conaclos opened this issue Jan 8, 2024 · 18 comments · Fixed by #1489
Closed
1 task done

🐛 Some ignore pattern generate ignored file error #1471

Conaclos opened this issue Jan 8, 2024 · 18 comments · Fixed by #1489
Labels
A-CLI Area: CLI S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@Conaclos
Copy link
Member

Conaclos commented Jan 8, 2024

Environment information

CLI:
  Version:                      1.5.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v21.5.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.2.5"

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

Workspace:
  Open Documents:               0

What happened?

Execute the following script and observe the error:

$ git clone https://github.com/bare-ts/bare.git
$ cd bare
$ npm ci
$ npx biome format --verbose --error-on-warnings --diagnostic-level=warn .
./tests-corpus/index.test.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ The file ./tests-corpus/index.test.js was ignored.
  

Compared 20 file(s) in 7ms
Skipped 1 file(s)

The configuration is:

{
  "files": {
    "ignoreUnknown": true
  },
  "formatter": {
    "indentStyle": "space",
    "ignore": ["./tests-corpus/*"]
  },
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "
  }
}

If I change formatter.ignore from ./tests-corpus/* to ./tests-corpus the bug seems fixed.

Expected result

No error should be thrown.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added the S-Bug-confirmed Status: report has been confirmed as a valid bug label Jan 8, 2024
@Yovach
Copy link

Yovach commented Jan 8, 2024

As requested, I'm encountering the same issue with the following configuration :

// biome.json
{
  "$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
  "files": {
    "ignoreUnknown": true,
    "ignore": [".next", "node_modules/**", "**/*.json", "**/dist", "**/out", "public/**/*.js"]
  },
  "organizeImports": {
    "enabled": true
  },
  "javascript": {
    "formatter": {
      "semicolons": "always",
      "quoteStyle": "double",
      "trailingComma": "all"
    }
  },
  "formatter": {
    "enabled": true,
    "indentWidth": 2,
    "indentStyle": "space",
    "lineWidth": 100
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "style": {
        "noParameterAssign": "off",
        "noNonNullAssertion": "warn"
      },
      "correctness": {
        "noUnusedVariables": "error"
      }
    }
  }
}

My project is basically a monorepo with ./apps/ with a website in apps/website and a Node.js API under apps/server.

Here is the logs :

./apps/website/.eslintrc.json lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ The file ./apps/website/.eslintrc.json was ignored.

./.devcontainer/devcontainer.json lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ The file ./.devcontainer/devcontainer.json was ignored.

@blutorange
Copy link

With version 1.4.1 I had

  "files": {
    "ignore": ["localization.ts"]
  }

After updating to version 1.5.0, it did not ignore the file anymore, reporting lint errors in that file. After I changed the ignore pattern to **/localization.ts, it ignores the file again, but now prints

[widget-common]: src/js/localization.ts lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[widget-common]: 
[widget-common]:   × The file src/js/localization.ts was ignored.

The exit code is still 0, so the lint is successful.

@notramo
Copy link

notramo commented Jan 8, 2024

This is very confusing for junior devs. In a rare case when setting up a linter can decrease productivity instead of increasing it.

Seriously, what is the logic behind these huge warnings? These are not accidental ignores, the paths are explicitly ignored in the config. Imagine if Git was printing after every pull/push/merge/commit/etc this:

Warning: node_modules/ is ignored.
Warning: .svelte-kit/ is ignored.
Warning: .vite.config.ts-timestamp-xyz is ignored.
...

Also, the lint now fails on one of our projects. Simply because the amount of "xy is ignored" and "xy is protected. Won't format..." kind of output (and no errors) exceed the max diagnostic amount.

@ematipico
Copy link
Member

@notramo

The reason why you see more diagnostics than before is because we had reports where users didn't understand why certain files weren't checked.

Even though we document that on our website, the reports were still coming.

Given the previous statement, and given that now you see too many diagnostics, what do you think we should do? What do you suggest?

@blutorange
Copy link

blutorange commented Jan 9, 2024

Hmm, I there is a valid use case for these warning. For example, when you try to format a specific file

yarn run biome format packages/common/src/js/constants.ts

Then biome won't process that file if it is ignored. Since I specifically asked for that file to be processed, it makes sense that biome tells me why it could not process that file.

On the other hand, my usual use case is that I want to run biome on all my files, i.e. on all files in a certain folder. That folder may contain some files that should be ignored, which I specified via the ignore options. In this scenario, I want to ask biome to process all files in a folder except for some files. Since I did not ask for the ignored files to be processed, I would not expect a warning.

So my question would be, what's the intended configuration / command-line prompt for the latter use case -- formatting all files in a folder, ignoring some files?

@ematipico ematipico added the A-CLI Area: CLI label Jan 9, 2024
@notramo
Copy link

notramo commented Jan 9, 2024

If the assets/do-not-modify.json is ignored, and Biome receives assets/do-not-modify.json explicitly, then show the warning, but if receives assets/, then do not.
But even in this case, it can be useful, so I'm not sure if it should be implemented.

However, there is an use case where the current behavior is problematic. When used with lefthook, it's simpler to not copy the entire ignore list from biome.json to lefthook.yml.

biome:
    glob: 'assets/js/**.{ts,json,js}'
    run: bun run biome check --apply {staged_files}

For this use case I would recommend adding --no-ignored-file-warning.

@gunta
Copy link

gunta commented Jan 9, 2024

So how do we ignore those warnings?

@ematipico
Copy link
Member

They are harmless. Use --diagnostic-level=error to show only the ones with error severity

@jschaf
Copy link

jschaf commented Jan 10, 2024

They are harmless. Use --diagnostic-level=error to show only the ones with error severity

I'm unable to silence these warnings. The format command doesn't support --no-ignored-file-warning

# *.pb.ts is ignored
biome format --diagnostic-level=error .     
./google/type/money.pb.ts format ━━━━━━━━━━━━

   The file ./google/type/money.pb.ts was ignored.

The reason why you see more diagnostics than before is because we had reports where users didn't understand why certain files weren't checked.

Given the previous statement, and given that now you see too many diagnostics, what do you think we should do? What do you suggest?

I expect linters to output nothing or a short success message if there are no errors. If I wanted to figure out why biome was ignoring files, I'd first look to increase the log level to DEBUG.

I think emitting warnings is a short-term solution. Most folks will turn them off because it's too noisy. Once the warnings are disabled, we're at the same starting point. In the long term, users still won't understand why biome is ignoring files since they'll have the warnings disabled.

Since the problem is that users don't understand why biome ignores files (and then open support tickets), maybe this can be solved in the ticket template by requiring debug logs?

@Conaclos
Copy link
Member Author

This should be fixed in the last patch release (v1.5.1). Could anyone confirm that they no longer get errors?

@notramo
Copy link

notramo commented Jan 10, 2024

Tested on 1 project, it's fixed for our use case.

@przemyslawzalewski
Copy link

I can confirm the latest patch resolves the issue for us, thanks! ❤️

@Sec-ant
Copy link
Member

Sec-ant commented Jun 26, 2024

Sorry, I configured as below and when I run yarn biome lint, files and subfolders in src/common are not ignored? Is anyone having the same problem?

"scr/common/**" -> "src/common/**"

@leo-longtran
Copy link

@Sec-ant Oh thanks you so much

@leo-longtran
Copy link

@Sec-ant Any way, I don't want to ignore the file in biome.json, but I want to comment right in that file, but currently I only know the comment // biome-ignore lint/suspicious/noExplicitAny: <explanation> to ignore a line, how do can I ignore biome check in the entire file by commenting. Many thanks

@ematipico
Copy link
Member

ematipico commented Jun 26, 2024

how do can I ignore biome check in the entire file by commenting.

That's a feature we don't have yet

@leo-longtran
Copy link

Here is my problem
Currently I am configuring as below in the biome.json file

  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    },
    "include": ["src/**", "tests/**"],
    "ignore": ["src/common/**"]
  }

If I run the command yarn biome lint on the terminal there is no problem. But I want to set up a pre-commit with husky, I will run the command yarn biome lint to make sure what I commit is valid, however if I edit any file outside the src folder or tests it will lead to an error. The path was not found because the yarn biome lint command ignored it. Do you have any suggestions to solve this problem?

@ematipico
Copy link
Member

You can use --no-errors-on-unmatched.

Next time you can consult the CLI reference page: https://biomejs.dev/reference/cli/#biome-lint

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

10 participants