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

test: migrate infer-plugins-ext-dir test cases #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Feb 3, 2025

Pulls the infer-plugins-ext-dir tests from prettier.

Pulls the `infer-plugins-ext-dir` tests from prettier.
{
// TODO (43081j): in prettier, this was `*.foo` and would successfully
// match `src/*.foo`. In prettier CLI, this is not the case
files: ["**/*.foo"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiospampinato this one seems like something we should discuss/decide before we merge these tests

it seems prettier treats *.foo as if it was **/*.foo, whereas we treat it as ./*.foo

i think we're correct, but this means a whole bunch of prettier configs may fail with our CLI. maybe we should do a special case that transforms "*.ext" into "**/*.ext"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so, no need to break the world here. The problem is that this is a bit tricky, what is the actual logic that we want? Worth checking what v3 is actually doing, because there are many potential ways to implement something like this.

I imagine we should try to explode the glob and do something with that in some cases 🤔

I think we can skip this test for now and fix it later if it's the only blocker for this test suite.

Is everything else basically just copy/pasted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much, just the paths changed to the mock/fixture extensions. The rest should be the same

@fabiospampinato
Copy link
Collaborator

What's the blocker for this PR, interpreting *.foo as if it was **/*.foo?

@43081j
Copy link
Contributor Author

43081j commented Feb 23, 2025

it should be good to merge and we can track the *.foo stuff separately

basically globs with no path are treated like **/{glob}. e.g. *.* is **/*.* in prettier. and *.js is **/*.js

@fabiospampinato
Copy link
Collaborator

So in order to select files actually matching *.js one has to write ./*.js?

@fisker
Copy link
Member

fisker commented Feb 23, 2025

I think treating *.js as **/*.foo idea comes from ESLint, but the link https://github.com/prettier/prettier/blob/de30788d30990b35534832ca554f5d5add2d4221/src/config/resolve-config.js#L105 is broken, so I'm not really sure.

@fabiospampinato
Copy link
Collaborator

@fisker presumably it isn't worth changing this, right? 🤔 how it works currently just seems incorrect to me, if I'm understanding it right.

@fabiospampinato fabiospampinato force-pushed the main branch 4 times, most recently from 34e0257 to f8dc396 Compare March 6, 2025 00:45
@fabiospampinato
Copy link
Collaborator

@fisker random question, but if *.js is interpreted as **/*.js, how do we actually pick only the js files in the current directory? is ./*.js the answer?

@fisker
Copy link
Member

fisker commented Mar 6, 2025

I don't understand "pick", are we talking about files in overrides?

@43081j
Copy link
Contributor Author

43081j commented Mar 6, 2025

Basically I think a non relative wildcard would be assumed to mean ./.

So internally:

  • * becomes ./**/*
  • *.js becomes ./**/*.js
  • foo becomes ./**/foo
  • ./* is left as is
  • **/*.js is left as is (isn't a standalone single *)

That would be like prettier right now I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants