-
Notifications
You must be signed in to change notification settings - Fork 624
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
[discussion] Do not use glob for prettier by default #424
Comments
@kt3k yes. that's great. Are you interested in porting it? |
@axetroy |
@axetroy I would like to work on it, if that's okay with you |
@dshubhadeep expose a new function name export function isGlob (str: string): boolean {
// do the staff
} |
@axetroy in which module should I add the function ? Btw the is-glob module also checks for extglob. Should that be added as well ? |
@dshubhadeep |
Use glob if there should be a wildcard, otherwise, use a normal file path
Otherwise, it is difficult for
Prettier
to format a specific file.eg. in
deno_std
directory.We want to format the
test.ts
file.only this file, no one else.
Does it look right?
No.
It will format all files under
deno_std
directory which match with/test\.ts/g
.It is difficult to specify a file to format.
Solution
This is the solution I think:
Use glob when wildcards appear, Otherwise use path.
Don't walk the entire directory
https://github.com/denoland/deno_std/blob/47134db9f24de802bee560941584bbc32e75a9c3/prettier/main.ts#L245-L253
BREAKING CHANGES
wildcards
, It will select the specified file instead of a matching file.Before
> deno run prettier/main.ts test.ts Formatting test.ts Formatting fs/test.ts Formatting fs/copy_test.ts Formatting fs/empty_test.ts ...
After
> deno run prettier/main.ts test.ts Formatting test.ts
In order to keep the original function unchanged, you should write like this
Please share your thoughts and suggestions
The text was updated successfully, but these errors were encountered: