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] #13626

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

[TEST] #13626

wants to merge 2 commits into from

Conversation

fisker
Copy link
Member

@fisker fisker commented Oct 13, 2022

Description

Ref: #13621 (comment)

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker
Copy link
Member Author

fisker commented Oct 13, 2022

@thorn0 This solution seems improved some cases

https://github.com/marmelab/react-admin/blob/5ae855aa958ba54438b144bf0907b1437c5a5d77/packages/ra-ui-materialui/src/list/ListGuesser.tsx#L63-L72

https://github.com/babel/babel/blob/4e0e5f9ad6ca1c8b305dd2bc3aba9a28f1239837/packages/babel-types/scripts/generators/ast-types.js#L52-L54

Prettier pr-13626
Playground link

--parser babel

Input:

{{{{{
                console.log(
                    `Guessed List:
export const ${inflection.capitalize(
                        inflection.singularize(resource)
                    )}List = props => (
    <List {...props}>
${inferredChild.getRepresentation()}
    </List>
);`
                );
  
a = `
export type Node = ${t.TYPES.filter(k => !t.FLIPPED_ALIAS_KEYS[k])
    .sort()
    .join(" | ")};\n\n`;


}}}}}

Output:

{
  {
    {
      {
        {
          console.log(
            `Guessed List:
export const ${inflection.capitalize(
  inflection.singularize(resource),
)}List = props => (
    <List {...props}>
${inferredChild.getRepresentation()}
    </List>
);`,
          );

          a = `
export type Node = ${t.TYPES.filter((k) => !t.FLIPPED_ALIAS_KEYS[k])
  .sort()
  .join(" | ")};\n\n`;
        }
      }
    }
  }
}

@fisker
Copy link
Member Author

fisker commented Oct 13, 2022

But didn't fix the problem you pointed out #13621 (comment), because that case has ${a} between the breaking expression and first quasi, we need to know how to find the right quasi to make the decision.

Prettier pr-13626
Playground link

--parser babel

Input:

{{{{{
a = `
export type Node = ${t.TYPES.filter(k => !t.FLIPPED_ALIAS_KEYS[k])
    .sort()
    .join(" | ")};\n\n`;

a = `
export type ${a} Node = ${t.TYPES.filter(k => !t.FLIPPED_ALIAS_KEYS[k])
    .sort()
    .join(" | ")};\n\n`;

}}}}}

Output:

{
  {
    {
      {
        {
          a = `
export type Node = ${t.TYPES.filter((k) => !t.FLIPPED_ALIAS_KEYS[k])
  .sort()
  .join(" | ")};\n\n`;

          a = `
export type ${a} Node = ${t.TYPES.filter((k) => !t.FLIPPED_ALIAS_KEYS[k])
            .sort()
            .join(" | ")};\n\n`;
        }
      }
    }
  }
}

@fisker fisker changed the base branch from next to main April 23, 2023 01:17
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.

None yet

1 participant