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

Config + Code Examples in Readme #20

Closed
karlhorky opened this issue Oct 26, 2023 · 1 comment · Fixed by #47
Closed

Config + Code Examples in Readme #20

karlhorky opened this issue Oct 26, 2023 · 1 comment · Fixed by #47
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Oct 26, 2023

Hi @Sec-ant , thanks for the great Prettier plugin! (and thanks @JounQin for prettier-plugin-sql, which also enables the formatting of SQL tagged template literals!)

Would be great to see a few complete config examples like the config code examples in comments in #16

Either:

A) full interactive examples (eg. CodeSandbox) or "recipes"
B) including configuration and code as in below

prettier.config.js

/** @type {import('prettier').Config} */
const prettierConfig = {
  plugins: ['prettier-plugin-embed', 'prettier-plugin-sql'],
};

/** @type {import('prettier-plugin-embed').PrettierPluginEmbedOptions} */
const prettierPluginEmbedConfig = {
  embeddedSqlIdentifiers: ['sql'],
}

/** @type {import('prettier-plugin-sql').SqlBaseOptions} */
const prettierPluginSqlConfig = {
  language: 'postgresql',
  keywordCase: 'upper',
}

const config = {
  ...prettierConfig,
  ...prettierPluginEmbedConfig,
  ...prettierPluginSqlConfig,
};

export default config;

index.ts (before)

const animals = await sql`
      SELECT
*                 
                       FROM
       animals
`;

index.ts (after)

const animals = await sql`
  SELECT
    *                 
  FROM
    animals
`;
@karlhorky
Copy link
Contributor Author

If there are any further dependencies for prettier-plugin-sql such as @xml-tools/parser, as mentioned in my bug report about the plugin crash below, then maybe that would also be a good thing to add to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants