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

Bug: No matching configuration found warning for code block matched only by non-universal patterns #18493

Closed
1 task done
mdjermanovic opened this issue May 24, 2024 · 2 comments · Fixed by #18507
Closed
1 task done
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features repro:yes

Comments

@mdjermanovic
Copy link
Member

mdjermanovic commented May 24, 2024

Environment

Node version: v20.12.0
npm version: 10.5.0
Local ESLint version: v9.3.0
Global ESLint version: no
Operating System: windows

What parser are you using?

Default (Espree)

What did you do?

I wanted to make a repro with eslint-plugin-markdown, but since this warning has line: 0 (which might be another bug), eslint-plugin-markdown filters it out as out-of-range. So I made a simple processor that assumes that the entire markdown file is one ```ts code block.

// eslint.config.js
export default [
  {
      plugins: {
          "my-plugin": {
              processors: {
                  "my-processor": {

                      // dummy processor that assumes that the whole content of a file is a single ```ts code block 
                      preprocess(text) {
                          const lines = text.split("\n");
                          return [{
                              filename: "foo.ts",
                              text: lines.slice(1, -1).join("\n")
                          }]
                      },

                      // just increment lines to adjust for the first ```ts line
                      postprocess(messages) {
                          const retv = messages[0]; // there's always exactly 1 code block

                          retv.forEach(message => {
                              message.line++
                              message.endLine++; 
                          });

                          return retv;
                      }
                  }
              }
          }
      }
  },
  {
      files: ["**/*.md"],
      processor: "my-plugin/my-processor"
  },
  {
      files: ["**/*"],
      rules: {
          "no-undef": 2
      }
  }
];

test.md:

```ts
foo
```

What did you expect to happen?

Since the .ts virtual file doesn't have an explicit match in the config, I'd expect it to be silently ignored, so at the end I'd expect no lint errors or warnings.

What actually happened?

C:\projects\tmp\tmp\test.md
  1:0  warning  No matching configuration found for C:\projects\tmp\tmp\test.md\0_foo.ts

✖ 1 problem (0 errors, 1 warning)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-hqxgng?file=eslint.config.js

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

We found this problem while discussing eslint/rewrite#7.

I think we could just replace the following line with return configs.getConfig(blockFilename) !== void 0;

return configs.isExplicitMatch(blockFilename);

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly repro:needed core Relates to ESLint's core APIs and features labels May 24, 2024
@fasttime fasttime added accepted There is consensus among the team that this change meets the criteria for inclusion repro:yes and removed repro:needed labels May 25, 2024
@fasttime
Copy link
Member

Thanks for the issue and the repro. Marked as accepted.

@mdjermanovic
Copy link
Member Author

I'm working on this.

@mdjermanovic mdjermanovic changed the title Bug: No matching configuration found warning for code block matched only by non-specific patterns Bug: No matching configuration found warning for code block matched only by non-universal patterns May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features repro:yes
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants