Git Product home page Git Product logo

prettier's Introduction

@unts/prettier

GitHub Actions Codecov type-coverage GitHub release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

Opinionated but Incredible Prettier plugins.

Packages

This repository is a monorepo managed by changesets what means we actually publish several packages to npm from same codebase, including:

Package Description Version
prettier-plugin-autocorrect An opinionated copywriting formatter plugin for Prettier npm
prettier-plugin-pkg An opinionated package.json formatter plugin for Prettier npm
prettier-plugin-sh An opinionated shellscript formatter plugin for Prettier, also support simple format of Dockerfile, properties, gitignore, dotenv, hosts, jvmoptions... npm
prettier-plugin-sql An opinionated sql formatter plugin for Prettier npm
prettier-plugin-toml An opinionated toml formatter plugin for Prettier npm

Sponsors

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

prettier's People

Contributors

actions-user avatar brookke avatar ewhauser avatar frozenbonito avatar github-actions[bot] avatar huacnlee avatar jayrave avatar jlarmstrongiv avatar joshuakgoldberg avatar jounqin avatar karlhorky avatar lgtm-com[bot] avatar nene avatar renovate-bot avatar renovate[bot] avatar rmjohnson avatar sequencerr avatar shellscape avatar so1ve avatar tim-watcha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

prettier's Issues

[prettier-plugin-sql] Parser Options in README is out of date

Parser Options does not seem to match the actual options.

options: {
formatter: {
since: '0.1.0',
category: 'Config',
type: 'choice',
default: SQL_FORMATTER,
description: 'Choose which formatter to be used',
choices: [
{
value: SQL_FORMATTER,
description: 'use `sql-formatter` as formatter',
},
{
value: NODE_SQL_PARSER,
description: 'use `node-sql-parser` as formatter',
},
],
},
language: {
since: '0.1.0',
category: 'Config',
type: 'choice',
default: 'sql',
description: 'SQL Formatter dialect for `sql-formatter`',
choices: [
{
value: 'sql',
description: 'Standard SQL: https://en.wikipedia.org/wiki/SQL:2011',
},
{
value: 'mariadb',
description: 'MariaDB: https://mariadb.com',
},
{
value: 'mysql',
description: 'MySQL: https://www.mysql.com',
},
{
value: 'postgresql',
description: 'PostgreSQL: https://www.postgresql.org',
},
{
value: 'db2',
description: 'IBM DB2: https://www.ibm.com/analytics/db2',
},
{
value: 'plsql',
description:
'Oracle PL/SQL: https://www.oracle.com/database/technologies/appdev/plsql.html',
},
{
value: 'n1ql',
description:
'Couchbase N1QL: https://www.couchbase.com/products/n1ql',
},
{
value: 'redshift',
description:
'Amazon Redshift: https://docs.aws.amazon.com/redshift/latest/dg/cm_chap_SQLCommandRef.html',
},
{
value: 'spark',
description: 'Spark: https://spark.apache.org',
},
{
value: 'tsql',
description:
'SQL Server Transact-SQL: https://docs.microsoft.com/en-us/sql/sql-server/',
},
],
},
keywordCase: {
since: '0.7.0',
category: 'Output',
type: 'choice',
default: 'preserve',
description:
'Converts reserved keywords and builtin function names to upper or lowercase for `sql-formatter`',
choices: [
{
value: 'preserve',
description: 'preserves the original case',
},
{
value: 'upper',
description: 'converts to uppercase',
},
{
value: 'lower',
description: 'converts to lowercase',
},
],
},
uppercase: {
since: '0.1.0',
category: 'Output',
type: 'boolean',
deprecated: '0.7.0',
description: 'Use `keywordCase` option instead',
},
indentStyle: {
since: '0.7.0',
category: 'Format',
type: 'choice',
default: 'standard',
description: `Switches between different indentation styles for \`sql-formatter\`.
Caveats of using \`"tabularLeft"\` and \`"tabularRight"\`:
- \`tabWidth\` option is ignored. Indentation will always be 10 spaces, regardless of what is specified by \`tabWidth\``,
choices: [
{
value: 'standard',
description:
'indents code by the amount specified by `tabWidth` option',
},
{
value: 'tabularLeft',
description:
'indents in tabular style with 10 spaces, aligning keywords to left',
},
{
value: 'tabularRight',
description:
'indents in tabular style with 10 spaces, aligning keywords to right',
},
],
},
logicalOperatorNewline: {
since: '0.7.0',
category: 'Format',
type: 'choice',
default: 'before',
description:
'Decides newline placement before or after logical operators (AND, OR, XOR)',
choices: [
{
value: 'before',
description: 'adds newline before the operator',
},
{
value: 'after',
description: 'adds newline after the operator',
},
],
},
aliasAs: {
since: '0.7.0',
category: 'Format',
type: 'choice',
default: 'preserve',
description:
'Enforces consistent use of `AS` keywords in alias declarations for `sql-formatter`',
choices: [
{
value: 'preserve',
description: 'does nothing',
},
{
value: 'always',
description: 'enforces `AS` usage for all aliases',
},
{
value: 'never',
description: 'forbids `AS` usage for all aliases',
},
{
value: 'select',
description:
'enforces `AS` usage in column aliases of `SELECT` and forbids it for table name aliases',
},
],
},
tabulateAlias: {
since: '0.7.0',
category: 'Format',
type: 'boolean',
default: false,
description:
'Aligns column aliases into a single column for `sql-formatter`. Does not effect table name aliases.',
},
commaPosition: {
since: '0.7.0',
category: 'Format',
type: 'choice',
default: 'after',
description:
'Defines where to place commas in lists of columns for `sql-formatter`',
choices: [
{
value: 'after',
description: 'places comma at the end of line',
},
{
value: 'before',
description: 'places comma at the start of line',
},
{
value: 'tabular',
description: 'aligns commas in a column at the end of line',
},
],
},
expressionWidth: {
since: '0.7.0',
category: 'Format',
type: 'int',
default: 50,
description:
'Determines maximum length of parenthesized expressions for `sql-formatter`',
},
linesBetweenQueries: {
since: '0.1.0',
category: 'Format',
type: 'int',
default: 1,
description:
'Decides how many empty lines to leave between SQL statements for `sql-formatter`',
},
denseOperators: {
since: '0.7.0',
category: 'Format',
type: 'boolean',
default: false,
description:
'Decides whitespace around operators for `sql-formatter`. Does not apply to logical operators (AND, OR, XOR).',
},
newlineBeforeSemicolon: {
since: '0.7.0',
category: 'Format',
type: 'boolean',
default: false,
description:
'Whether to place query separator (`;`) on a separate line for `sql-formatter`',
},
params: {
since: '0.7.0',
category: 'Format',
type: 'choice',
description:
'Specifies parameter values to fill in for placeholders inside SQL for `sql-formatter`. This option is designed to be used through API (though nothing really prevents usage from command line).',
choices: [
{
value: Array,
description:
'`Array` of strings and/or numbers for position placeholders',
},
{
value: Object,
description:
'`Object` of name-value pairs for named (and indexed) placeholders',
},
],
// @ts-expect-error
exception(value: unknown) {
return (
value == null ||
(Array.isArray(value)
? value.every(
(v: unknown) => typeof v === 'string' || typeof v === 'number',
)
: typeof value === 'object')
)
},
},
type: {
since: '0.1.0',
category: 'Config',
type: 'choice',
default: 'table',
description: 'Check the SQL with Authority List for `node-sql-parser`',
choices: [
{
value: 'table',
description: '`table` mode',
},
{
value: 'column',
description: '`column` mode',
},
],
},
database: {
since: '0.1.0',
category: 'Config',
type: 'choice',
default: 'mysql',
description: 'SQL dialect for `node-sql-parser`',
choices: [
{
value: 'bigquery',
description: 'BigQuery: https://cloud.google.com/bigquery',
},
{
value: 'db2',
description: 'IBM DB2: https://www.ibm.com/analytics/db2',
},
{
value: 'hive',
description: 'Hive: https://hive.apache.org',
},
{
value: 'mariadb',
description: 'MariaDB: https://mariadb.com',
},
{
value: 'mysql',
description: 'MySQL: https://www.mysql.com',
},
{
value: 'postgresql',
description: 'PostgreSQL: https://www.postgresql.org',
},
{
value: 'transactsql',
description:
'TransactSQL: https://docs.microsoft.com/en-us/sql/t-sql',
},
{
value: 'flinksql',
description:
'FlinkSQL: https://ci.apache.org/projects/flink/flink-docs-stable',
},
],
},
},

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @changesets/cli to ^2.27.7
  • chore(deps): update dependency @types/web to ^0.0.151
  • fix(deps): update dependency tslib to ^2.6.3
  • chore(deps): update dependency @types/lodash to ^4.17.7
  • chore(deps): update dependency @vitejs/plugin-react-swc to ^3.7.0
  • chore(deps): update dependency eslint-plugin-prettier to ^5.2.1
  • chore(deps): update dependency github-markdown-css to ^5.6.1
  • chore(deps): update dependency prettier to ^3.3.3
  • chore(deps): update dependency react-router-dom to ^6.25.1
  • chore(deps): update dependency rollup to ^4.18.1
  • chore(deps): update dependency sass to ^1.77.8
  • chore(deps): update dependency size-limit to ^11.1.4
  • chore(deps): update dependency tsx to ^4.16.2
  • chore(deps): update dependency type-coverage to ^2.29.1
  • chore(deps): update dependency typescript to ^5.5.3
  • chore(deps): update dependency unplugin-auto-import to ^0.18.0
  • chore(deps): update dependency vite to ^5.3.4
  • chore(deps): update node.js to >=16.20.2
  • chore(deps): update pnpm to v8.15.9
  • chore(deps): update react monorepo (@types/react, @types/react-dom, react, react-dom)
  • chore(deps): update vitest monorepo to ^1.6.0 (@vitest/coverage-istanbul, vitest)
  • fix(deps): update dependency @taplo/lib to ^0.5.0
  • fix(deps): update dependency autocorrect-node to ^2.11.1
  • fix(deps): update dependency node-sql-parser to ^4.18.0
  • fix(deps): update dependency sql-formatter to ^15.3.2
  • chore(deps): update codecov/codecov-action action to v4
  • chore(deps): update dependency @1stg/app-config to v10
  • chore(deps): update dependency @1stg/lib-config to v13
  • chore(deps): update github/codeql-action action to v3
  • chore(deps): update node.js to v20 (node, @types/node)
  • chore(deps): update pnpm to v9
  • chore(deps): update vitest monorepo to v2 (major) (@vitest/coverage-istanbul, vitest)
  • fix(deps): update dependency node-sql-parser to v5

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • codecov/codecov-action v3
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/size-limit.yml
  • actions/checkout v4
  • actions/setup-node v4
  • andresz1/size-limit-action v1
.github/workflows/vercel.yml
  • actions/checkout v4
  • amondnet/vercel-action v25
npm
docs/package.json
package.json
  • @1stg/app-config ^9.0.1
  • @1stg/lib-config ^12.0.1
  • @changesets/changelog-github ^0.5.0
  • @changesets/cli ^2.27.6
  • @mdx-js/rollup ^3.0.1
  • @types/lodash ^4.14.202
  • @types/mvdan-sh ^0.10.9
  • @types/node ^20.10.4
  • @types/react ^18.2.73
  • @types/react-dom ^18.2.23
  • @types/web ^0.0.150
  • @vitejs/plugin-react-swc ^3.5.0
  • @vitest/coverage-istanbul ^1.0.4
  • github-markdown-css ^5.4.0
  • linguist-languages ^7.27.0
  • lodash ^4.17.21
  • prettier ^3.2.4
  • react ^18.2.0
  • react-dom ^18.2.0
  • react-router-dom ^6.20.1
  • remark-gfm ^4.0.0
  • sass ^1.69.6
  • sirv-cli ^2.0.2
  • size-limit ^11.0.2
  • size-limit-preset-node-lib ^0.3.0
  • tsx ^4.6.2
  • type-coverage ^2.27.2
  • typescript ^5.3.3
  • unplugin-auto-import ^0.17.6
  • vite ^5.0.7
  • vitest ^1.0.4
  • eslint-plugin-prettier ^5.0.1
  • prettier ^3.1.1
  • rollup ^4.8.0
  • pnpm 8.12.0
packages/autocorrect/package.json
  • autocorrect-node ^2.9.0
  • prettier ^3.0.3
  • node ^14.18.0 || >=16.0.0
packages/pkg/package.json
  • prettier ^3.0.3
  • node ^14.18.0 || >=16.0.0
packages/sh/package.json
  • mvdan-sh ^0.10.1
  • sh-syntax ^0.4.2
  • prettier ^3.0.3
  • node >=16.0.0
packages/sql/package.json
  • jsox ^1.2.119
  • node-sql-parser ^4.12.0
  • sql-formatter ^15.0.2
  • tslib ^2.6.2
  • prettier ^3.0.3
  • node ^14.18.0 || >=16.0.0
packages/toml/package.json
  • @taplo/lib ^0.4.0-alpha.2
  • prettier ^3.0.3
  • node >=16.0.0
nvm
.nvmrc

  • Check this box to trigger a request for Renovate to run again on this repository

[prettier-plugin-sh] Fails on if statement that checks command exists

When formatting a file that checks if a command exists with command -v the formatting fails.

Reproducer

#!/bin/sh

echo "Starting setup of this project"

if [[ ! command -v npm > /dev/null 2>&1 ]] ; then
    echo "Missing npm, stopping script"
    exit
fi

Logs

Terminal (oh-my-zsh with power10k)

$ npx prettier --write setup.sh
setup.sh
[error] setup.sh: SyntaxError: not a valid test operator: npm
[error]    5 | echo "Starting setup of this project"
[error]    6 |
[error] >  7 | if [[ ! command npm > /dev/null 2>&1 ]] ; then
[error]      |                 ^
[error]    8 |     echo "Missing npm, stopping script"
[error]    9 |     exit
[error]   10 | fi

VSCode

Plugin:

Name: Prettier - Code formatter
Id: esbenp.prettier-vscode
Description: Code formatter using prettier
Version: 9.10.4
Publisher: Prettier
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

VSCode version

Version: 1.74.3 (user setup)
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T16:59:02.252Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No

Log from plugin

["INFO" - 3:25:30 PM] Formatting file:///home/eriase/repos/all-prettier-java-project/setup.sh
["INFO" - 3:25:30 PM] Using config file at '/home/eriase/repos/all-prettier-java-project/.prettierrc'
["INFO" - 3:25:30 PM] Using ignore file (if present) at /home/eriase/repos/all-prettier-java-project/.prettierignore
["INFO" - 3:25:30 PM] File Info:
{
  "ignored": false,
  "inferredParser": "sh"
}
["INFO" - 3:25:30 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 3:25:30 PM] Prettier Options:
{
  "filepath": "/home/eriase/repos/all-prettier-java-project/setup.sh",
  "parser": "sh",
  "tabWidth": 4,
  "useTabs": false,
  "endOfLine": "lf",
  "printWidth": 120,
  "trailingComma": "none",
  "semi": true,
  "xmlWhitespaceSensitivity": "ignore",
  "htmlWhitespaceSensitivity": "ignore",
  "bracketSameLine": false,
  "singleAttributePerLine": true
}
["ERROR" - 3:25:30 PM] Error formatting document.
["ERROR" - 3:25:30 PM] not a valid test operator: -v
  3 | echo "Starting setup of this project"
  4 |
> 5 | if [[ ! command -v npm > /dev/null 2>&1 ]] ; then
    |                 ^
  6 |     echo "Missing npm, stopping script"
  7 |     exit
  8 | fi
SyntaxError: not a valid test operator: -v
  3 | echo "Starting setup of this project"
  4 |
> 5 | if [[ ! command -v npm > /dev/null 2>&1 ]] ; then
    |                 ^
  6 |     echo "Missing npm, stopping script"
  7 |     exit
  8 | fi
	at Object.parse (/home/eriase/repos/all-prettier-java-project/node_modules/prettier-plugin-sh/lib/index.cjs:442:17)
	at Object.parse (/home/eriase/repos/all-prettier-java-project/node_modules/prettier/index.js:7515:23)
	at coreFormat (/home/eriase/repos/all-prettier-java-project/node_modules/prettier/index.js:8829:18)
	at formatWithCursor2 (/home/eriase/repos/all-prettier-java-project/node_modules/prettier/index.js:9021:18)
	at /home/eriase/repos/all-prettier-java-project/node_modules/prettier/index.js:38168:12
	at Object.format (/home/eriase/repos/all-prettier-java-project/node_modules/prettier/index.js:38182:12)
	at t.default.format (/home/eriase/.vscode-server/extensions/esbenp.prettier-vscode-9.10.4/dist/extension.js:1:14669)
	at async t.PrettierEditProvider.provideEdits (/home/eriase/.vscode-server/extensions/esbenp.prettier-vscode-9.10.4/dist/extension.js:1:11355)
	at async B.provideDocumentFormattingEdits (/home/eriase/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/out/vs/workbench/api/node/extensionHostProcess.js:96:39719)
["INFO" - 3:25:30 PM] Formatting completed in 9ms.

Config

Package.json

{
    "lint-staged": {
        "*.{html,sql,xml,sh,yaml,json,md,java}": "prettier --write"
    },
    "devDependencies": {
        "@prettier/plugin-xml": "^2.2.0",
        "husky": "^8.0.3",
        "lint-staged": "^13.1.0",
        "prettier": "^2.8.3",
        "prettier-plugin-java": "^2.0.0",
        "prettier-plugin-properties": "^0.2.0",
        "prettier-plugin-sh": "^0.12.8",
        "prettier-plugin-sql": "^0.12.1",
        "pretty-quick": "^3.1.3"
    }
}

.prettierrc

{
    "tabWidth": 4,
    "useTabs": false,
    "endOfLine": "lf",
    "printWidth": 120,
    "trailingComma": "none",
    "semi": true,
    "xmlWhitespaceSensitivity": "ignore",
    "htmlWhitespaceSensitivity": "ignore",
    "bracketSameLine": false,
    "singleAttributePerLine": true
}

[prettier-plugin-sh] Migrate to Prettier v3

Hi, I am a maintainer at Prettier.

The Prettier team is currently working on v3(still alpha).
v3 will include breaking changes to the plugin interface.
Please see https://github.com/prettier/prettier/releases/tag/3.0.0-alpha.2 for more information.

I created this issue to help major plugins migrate to Prettier v3.

Myself and @fisker have created a migration guide which you can see here:

https://github.com/prettier/prettier/wiki/How-to-migrate-my-plugin-to-support-Prettier-v3%3F

If you have any questions, feel free to mention us. We can help you.

If you have already migrated to Prettier v3, sorry but please close this issue.

Publish full list of file type for plugin-sh

I tried to find this myself by browsing through mvdan-sh, but I wasn't able to. I would really appreciate it if some link could be published to a full list of supported file formats.

I'm using this plugin mainly through lint-staged, where it is applied to staged files, matching a given file extension. So I need to supply a list of file extensions prettier and this plugin would be responsible for.

Sorry if I missed something obvious.

Docker-Compose Plugin

I'm wondering about writing docker-compose plugin which will work in a similar way, how your pkg plugin works, I think building a next repository for a plugin is a bit no sense thing, you have cool monorepo to which I could actually contribute. @rx-ts what do you think?

Please read the MPL-2.0 LICENSE

Hey there. The MPL is not MIT - one cannot silently fork or copy and create derived content without notification - and it's for that reason that I chose MPL-2.0 for prettier-plugin-package.

Here's a great summary of MPL and how derived works have to be handled: https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)

All modified files containing MPL'd code must be disclosed under the MPL.

Of note:

3.4. Notices

You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.

What's a real bummer here is that you've taken my source code, removed all of the licenses, retained most of the code structure, and simply converted it to TypeScript (in many cases, not modifying the code at all).

I welcome derived works and wholesale modification to my work, but I do ask that you retain my copyright notices in files that still retain my code. Given that the README still shares original elements of my package and that the commit log references my package as the basis for your new package, I would also greatly appreciate an attribution section in the README that points back to my package. It's the right thing to do.

Breaks with prettier --list-different in ci

Harder to debug than expected, and might be a bug with prettier itself instead prettier/prettier#4144 (comment)

Anyway, all you get is the error Process completed with exit code 1. without a list of files that are different.

The workaround is to use the --check flag instead.

That makes bugs more difficult to track down, as the plugin ended up crashing on transitory shell scripts generated by husky, and I could not reproduce the error locally.

SQL: Cannot read property 'slice' of undefined

It seems the SQL parser is choking on some table definitions I have for Postgres:

CREATE TABLE "test" (
    "id" uuid NOT NULL
) WITH (oids = false);

It is entirely dependent on this WITH clause -- without it, the plugin works as expected.

Here's a traceback:

[error] src\test\resources\database-migrate-setup.sql: TypeError: Cannot read property 'slice' of undefined
[error]     at parseKey (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2460:20)
[error]     at Tokenizer.getPlaceholderTokenWithKey (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2504:21)
[error]     at Tokenizer.getIdentNamedPlaceholderToken (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2456:19)
[error]     at Tokenizer.getPlaceholderToken (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2451:19)
[error]     at Tokenizer.getNextToken (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2396:147)
[error]     at Tokenizer.tokenize (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:2376:24)
[error]     at StandardSqlFormatter.format (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:1958:38)
[error]     at format (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:3541:29)
[error]     at Object.print (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier-plugin-sql\lib\cjs.js:3708:44)
[error]     at callPluginPrintFunction (C:\Users\ncovercash\AppData\Roaming\npm\node_modules\prettier\index.js:13787:21)

And my prettier config:

{
  "printWidth": 100,
  "useTabs": false,
  "tabWidth": 2,
  "semi": true,
  "proseWrap": "always",
  "trailingComma": "all",
  "quoteProps": "consistent",
  "bracketSameLine": false,
  "xmlWhitespaceSensitivity": "ignore"
}

0.8.0: Cannot find module 'tslib'

$ prettier -v


internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'tslib'
Require stack:
- C:\Users\Borgo\AppData\Roaming\npm\node_modules\prettier-plugin-sh\lib\index.js

plugin-sh: Ignored unknown option

I keep getting Ignored unknown option when I run prettier. My shell files are still being formatted, so I have the extension installed.

image

My config file:

...

keepComments: true
indent: 4
binaryNextLine: true
switchCaseIndent: true
spaceRedirects: true
keepPadding: false
minify: false
functionNextLine: true

...

sh - false postive on closing quote

Hello, prettier-plugin-sh seems to be giving me a false positive:

lolaus.sh
[error] lolaus.sh: SyntaxError: reached EOF without closing quote "
[error]   186 | }
[error]   187 |
[error] > 188 | main "$@"
[error]       |         ^
[error]   189 |

Here is a gist of the script. I can not found a missing quote or bracket. The script runs fine and passes shellcheck, maybe there is still an error in the script but it seems there is potential it is in the plug-in.

Any pointers? And thanks.

[prettier-plugin-sql] Adds extra space and beginning of files

Test file:

 -- migrate:up
 create table users (
   id integer,
   name varchar(255)
 );
 insert into users (id, name) values (1, 'alice');

 -- migrate:down
 drop table users;
$ npm install prettier
$ npm install prettier-sql-format
$ prettier migration.sql # Note leading space in first line
 -- migrate:up
create table
  users (id integer, name varchar(255));

insert into
  users (id, name)
values
  (1, 'alice');

-- migrate:down
drop table
$ sql-formatter migration.sql # No leading space in first line
-- migrate:up
create table
  users (id integer, name varchar(255));

insert into
  users (id, name)
values
  (1, 'alice');

-- migrate:down
drop table
  users;

Can’t prettify .gitignore file

Thank you for creating this awesome plugin! Works for the most part, but fails when a .gitignore file contains parenthesis:

## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync

Errors:

[error] .gitignore: SyntaxError: "foo(" must be followed by )
[error]   353 | *.fdb_latexmk
[error]   354 | *.synctex
[error] > 355 | *.synctex(busy)
[error]       | ^
[error]   356 | *.synctex.gz
[error]   357 | *.synctex.gz(busy)
[error]   358 | *.pdfsync
[error] .gitignore: SyntaxError: a command can only contain words and redirects; encountered )
[error]   353 | *.fdb_latexmk
[error]   354 | *.synctex
[error] > 355 | *.synctex*busy)
[error]       |               ^
[error]   356 | *.synctex.gz
[error]   357 | *.synctex.gz*busy)
[error]   358 | *.pdfsync

Related #175

Error: Parse error: Unexpected ""

I am trying to Prettify .sql files and some of them contain functions such as this one:

CREATE FUNCTION test(character varying) RETURNS boolean
    LANGUAGE sql
    AS $_$
select exists (select 1 from "test2" where value = $1 and type = 'testType');
$_$;

Unfortunately, this seems to crash the plugin with the following stack trace:

["ERROR" - 2:35:00 p.m.] Error formatting document.
["ERROR" - 2:35:00 p.m.] Parse error: Unexpected "$_$
select exists (s"
Error: Parse error: Unexpected "$_$
select exists (s"
    at TokenizerEngine.tokenize (/test-app/node_modules/sql-formatter/src/lexer/TokenizerEngine.ts:48:17)
    at Tokenizer.tokenize (/test-app/node_modules/sql-formatter/src/lexer/Tokenizer.ts:26:47)
    at LexerAdapter.tokenize (/test-app/node_modules/sql-formatter/src/parser/createParser.ts:21:37)
    at LexerAdapter.reset (/test-app/node_modules/sql-formatter/src/parser/LexerAdapter.ts:15:24)
    at Parser.feed (/test-app/node_modules/nearley/lib/nearley.js:281:15)
    at Object.parse (/test-app/node_modules/sql-formatter/src/parser/createParser.ts:31:34)
    at SqlFormatter.parse (/test-app/node_modules/sql-formatter/src/formatter/Formatter.ts:57:49)
    at SqlFormatter.format (/test-app/node_modules/sql-formatter/src/formatter/Formatter.ts:49:22)
    at Object.format (/test-app/node_modules/sql-formatter/src/sqlFormatter.ts:76:36)
    at Object.print (/test-app/node_modules/prettier-plugin-sql/lib/index.cjs:183:66)
    at callPluginPrintFunction (/test-app/node_modules/prettier/index.js:8420:26)
    at mainPrintInternal (/test-app/node_modules/prettier/index.js:8369:22)
    at mainPrint (/test-app/node_modules/prettier/index.js:8356:18)
    at printAstToDoc (/test-app/node_modules/prettier/index.js:8348:18)
    at coreFormat (/test-app/node_modules/prettier/index.js:8653:20)
    at formatWithCursor2 (/test-app/node_modules/prettier/index.js:8837:18)
    at /test-app/node_modules/prettier/index.js:37229:12
    at Object.format (/test-app/node_modules/prettier/index.js:37243:12)
    at t.default.format (/test-app/.vscode/extensions/esbenp.prettier-vscode-9.9.0/dist/extension.js:1:14565)
    at t.PrettierEditProvider.provideEdits (/test-app/.vscode/extensions/esbenp.prettier-vscode-9.9.0/dist/extension.js:1:11259)
    at B.provideDocumentFormattingEdits (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:94:45902)
["INFO" - 2:35:00 p.m.] Formatting completed in 8ms.

[prettier-plugin-sh]: TypeError [Error]: Cannot set property crypto of #<Object> which has only a getter

Setting NODE_OPTIONS="--experimental-global-webcrypto" causes a crash:

TypeError [Error]: Cannot set property crypto of #<Object> which has only a getter

The --experimental-global-webcrypto enables the Web Crypto API from the browser in NodeJS as the global crypto property.

While I’ve disabled experimental NODE_OPTIONS while running prettier, this issue will likely occur in NodeJS v18.x, which become the LTS version in October 2022.

plugin-sh: Ignored unknown option warning

Bug Description

After running either of the following commands: prettier --write . or prettier --check ., my logs are filled with Ignored unknown option warnings. My shell files (and a .gitconfig file) are still being formatted, however.

Sample output from running prettier --write .

[warn] Ignored unknown option { functionNextLine: true }.
[warn] Ignored unknown option { indent: 4 }.
[warn] Ignored unknown option { keepComments: true }.
[warn] Ignored unknown option { keepPadding: false }.
[warn] Ignored unknown option { spaceRedirects: true }.
[warn] Ignored unknown option { switchCaseIndent: true }.
[warn] Ignored unknown option { variant: 0 }.
scripts/prepublish.sh 31ms
scripts/ts/debug.ts 26ms
scripts/ts/fix-node-module-paths.ts 69ms
scripts/ts/release.ts 258ms
[warn] Ignored unknown option { functionNextLine: true }.
[warn] Ignored unknown option { indent: 4 }.
[warn] Ignored unknown option { keepComments: true }.
[warn] Ignored unknown option { keepPadding: false }.
[warn] Ignored unknown option { spaceRedirects: true }.
[warn] Ignored unknown option { switchCaseIndent: true }.
[warn] Ignored unknown option { variant: 0 }.
scripts/zsh-install.sh 79ms

Steps to reproduce

  1. Clone the repro repository
  2. Remove @flex-development/exceptions and @flex-development/tutils from dependencies
  3. Run yarn in the project root
  4. Run yarn check:format or yarn fix:format
  5. See error (extraneous warning logs)

Expected behavior

There should be no warnings in the console.

Relevant screenshots

Screenshot of logs after running prettier --check .

Screen Shot 2021-06-09 at 10 05 05 PM

Environment

  • prettier version: v2.3.1
  • prettier-plugin-sh version: v0.6.1

Possible solution

Unsure of a possible solutions.

Additional context

  • Another user had this issue, but their problem seemed to disappear. See issue #106

  • In the screenshot above, you can see the second Prettier configuration I tried. The first looked like this:

    module.exports = {
      arrowParens: 'avoid',
      bracketSpacing: true,
      functionNextLine: true,
      htmlWhitespaceSensitivity: 'css',
      indent: 4,
      jsxBracketSameLine: false,
      jsxSingleQuote: true,
      keepComments: true,
      keepPadding: false,
      parser: 'sh',
      printWidth: 80,
      proseWrap: 'always',
      quoteProps: 'as-needed',
      semi: false,
      singleQuote: true,
      spaceRedirects: true,
      switchCaseIndent: true,
      tabWidth: 2,
      trailingComma: 'none',
      variant: 0
    }

[prettier-plugin-sh] v0.12.0 crashes

0.11.0 runs just fine

Error running prettier update on mac:

96841 Bus error: 10

Error running prettier check on mac:

97549 Bus error: 10

Error running check in linux CI:

> [email protected] turbo:prettier:check
> bin/prettier/check
[warn] bin/deepl/check
Error:  bin/docker/run: TypeError: Cannot read properties of undefined (reading 'Col')
Error:      at new ShParseError (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:426:25)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:445:17)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:7334:23)
Error:      at coreFormat (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8645:18)
Error:      at formatWithCursor2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8837:18)
Error:      at Object.formatWithCursor (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:37229:12)
Error:      at format (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14748:24)
Error:      at formatFiles2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14860:22)
Error:      at async main (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15077:5)
Error:      at async Object.run (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15024:5)
Error:  bin/git/ensure_repository: TypeError: Cannot read properties of undefined (reading 'Col')
Error:      at new ShParseError (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:426:25)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:445:17)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:7334:23)
Error:      at coreFormat (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8645:18)
Error:      at formatWithCursor2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8837:18)
Error:      at Object.formatWithCursor (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:37229:12)
Error:      at format (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14748:24)
Error:      at formatFiles2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14860:22)
Error:      at async main (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15077:5)
Error:      at async Object.run (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15024:5)
Error:  bin/globals/branch: TypeError: Cannot read properties of undefined (reading 'Col')
Error:      at new ShParseError (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:426:25)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:445:17)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:7334:23)
Error:      at coreFormat (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8645:18)
Error:      at formatWithCursor2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8837:18)
Error:      at Object.formatWithCursor (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:37229:12)
Error:      at format (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14748:24)
Error:      at formatFiles2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14860:22)
Error:      at async main (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15077:5)
Error:      at async Object.run (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15024:5)
Error:  bin/globals/os: TypeError: Cannot read properties of undefined (reading 'Col')
Error:      at new ShParseError (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:426:25)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:445:17)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:7334:23)
Error:      at coreFormat (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8645:18)
Error:      at formatWithCursor2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8837:18)
Error:      at Object.formatWithCursor (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:37229:12)
Error:      at format (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14748:24)
Error:      at formatFiles2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14860:22)
Error:      at async main (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15077:5)
Error:      at async Object.run (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15024:5)
Error:  bin/globals/stage: TypeError: Cannot read properties of undefined (reading 'Col')
Error:      at new ShParseError (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:426:25)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier-plugin-sh/lib/index.cjs:445:17)
Error:      at Object.parse (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:7334:23)
Error:      at coreFormat (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8645:18)
Error:      at formatWithCursor2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:8837:18)
Error:      at Object.formatWithCursor (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/index.js:37229:12)
Error:      at format (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14748:24)
Error:      at formatFiles2 (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:14860:22)
Error:      at async main (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15077:5)
Error:      at async Object.run (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/prettier/cli.js:15024:5)
[warn] bin/third-party/turbo_install
Error:  bin/third-party/ubuntu-22/packages/autotrace: RuntimeError: memory access out of bounds
Error:      at (runtime.gcBlock).state (wasm://wasm/002c9a4a:wasm-function[161]:0x16d3d)
Error:      at (runtime.gcBlock).findHead (wasm://wasm/002c9a4a:wasm-function[171]:0x172d6)
Error:      at runtime.markRoots (wasm://wasm/002c9a4a:wasm-function[160]:0x16ca4)
Error:      at runtime.alloc (wasm://wasm/002c9a4a:wasm-function[24]:0x166b)
Error:      at github.com/rx-ts/sh-syntax/processor.Parse (wasm://wasm/002c9a4a:wasm-function[641]:0x8c4ee)
Error:      at process (wasm://wasm/002c9a4a:wasm-function[652]:0x90706)
Error:      at process.command_export (wasm://wasm/002c9a4a:wasm-function[670]:0x95e4e)
Error:      at file:///home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/sh-syntax/lib/processor.js:48:35
Error:      at Generator.next (<anonymous>)
Error:      at fulfilled (/home/ubuntu/actions-runner/_work/turbo-monorepo/turbo-monorepo/node_modules/tslib/tslib.js:115:62)
[warn] Code style issues found in 2 files. Forgot to run Prettier?
Error: Process completed with exit code 2.

[prettier-plugin-sql] Incorrect use of MIT license when depending on a GPL-licensed library

The node-sql-parser library (used by prettier-plugin-sql) is licensed under GPLv2.

The prettier-plugin-sql plugin uses this library, but is not licensed under GPLv2 or later as the GPL license requires. Instead it uses the permissive MIT license.

I assume that this is not intentional, but simply an oversight by the author, as JavaScript libraries nowadays seem to mostly come with very permissive licenses.

Suggested fix:

  • Change the license of prettier-plugin-sql to GPLv2

`prettier-plugin-sql` uppercase broken

I'm running prettier on SQL files and in the past that would have nicely uppercased the query as well. at some point that stopped working though.
My config:
image

test-sql:

Select
    f.Id as ContactId,
    f.EndDate,
    f.StartDate,
    SecondReminder,
    f.Enabled,
    f.CustomerSegment
from
    test f
    inner join test2 s on f.Seller = s.Seller

the above is one out of many I tried - haven't seen it working anywhere.

i tried playing with the uppercase value, setting it as a string for instance, but that lead to an error.

prettier-plugin-sh fails when run from pre-commit.

When I run prettier-plugin-sh from pre-commit it fails with a message like the one below.

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'node:path'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
  [... elided for brevity - see attached log ... ] 
    at Object.<anonymous> (/home/mikedlr/.cache/pre-commit/repoggidmgun/node_env-system/lib/node_modules/prettier-plugin-sh/lib/index.cjs:3:12)
  [... elided for brevity - see attached log ... ] 
internal/modules/cjs/loader.js:638
    throw err;

I have run prettier-plugin-sh with what I believe are the correct magic incantations

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: "v3.0.0-alpha.0" # Use the sha / tag you want to point at
    hooks:
      - id: prettier
        additional_dependencies:
          - [email protected]
          - "@prettier/[email protected]"
          - "[email protected]"
          - "[email protected]"

prettier-sh broken

Prettier Version: 2.4.1
Running Prettier via: CLI
Runtime: NodeJS v12.22.5
Operating System: Debian 11
Prettier plugins (if any): SH
Steps to reproduce:

prettier -w file.sh

Expected behavior:

Formatting file

Actual behavior:

[error] No parser could be inferred for file: file.sh

prettier-plugin-sh installed.

sql plugin files types question

Hi. Does this plugin works only for *.sql files or is it also capable of formatting inline sql in javascript/typescript string, literal tag (i.e. sql`...`)?

[prettier-plugin-sh] Fail with error since 0.9 and 0.10 on specific shell script

Running prettier with write or check on one of my shell scripts started to fail since 0.9 and 0.10 ; was ok with 0.8.2.

prettier --write given-script.sh
prettier --check given-script.sh

... this script has 215 lines, some blank, and trying to remove few random lines seems to get back to no error (6 or more, it depends on the lines, even basic echos).

It is still fine with all my other scripts and Dockerfiles.

I can not share this file as it is close source.

(Windows 10, Node 17.8.0, npm 8.5.5)

with 0.10.0 and 0.9.1
given-script.sh[error] given-script.sh: Error: total length of command line and environment variables exceeds limit
[error]     at globalThis.Go.run (file:///C:/Users/myuser/AppData/Roaming/npm/node_modules/prettier-plugin-sh/node_modules/sh-syntax/vendors/wasm_exec.js:524:11)
[error]     at file:///C:/Users/myuser/AppData/Roaming/npm/node_modules/prettier-plugin-sh/node_modules/sh-syntax/lib/processor.js:60:22
[error]     at Generator.next ()
[error]     at fulfilled (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier-plugin-sh\node_modules\tslib\tslib.js:114:62)
with 0.9.0
given-script.sh[error] given-script.sh: TypeError: Cannot read properties of undefined (reading 'col')
[error]     at Object.print (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier-plugin-sh\lib\index.cjs:473:35)
[error]     at callPluginPrintFunction (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8447:26)
[error]     at mainPrintInternal (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8396:22)
[error]     at mainPrint (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8383:18)
[error]     at printAstToDoc (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8375:18)
[error]     at coreFormat (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8680:20)
[error]     at formatWithCursor2 (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:8864:18)
[error]     at Object.formatWithCursor (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\index.js:39174:12)
[error]     at format (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\cli.js:12043:24)
[error]     at formatFiles2 (C:\Users\myuser\AppData\Roaming\npm\node_modules\prettier\cli.js:12122:20)

Visual Studio Code Support?

I keep getting
image
this error, and i cant select prettier as a formatter for shell scripts even though it works in the cli. Not sure waht to do here.

`prettier-plugin-sh`: using plugin with pnpm

Just want to leave this here for info, could help others.

If you use pnpm and you keep your prettier config in external sharable package, then you can run into an issue that prettier does not load plugin in your project where you consume your config. This is due to the fact that pnpm does not hoist modules to the root node_modules directory like other package managers, so prettier can't find them.

The workaround is to manually resolve plugins in a js prettier config:

module.exports = {
    plugins: [require.resolve("prettier-plugin-sh")],
};

Maybe it's worth mentioning it in docs?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: author, Invalid configuration option: commitlint, Invalid configuration option: jest, Invalid configuration option: license, Invalid configuration option: name, Invalid configuration option: packageRules[0].@1stg/lib-config, Invalid configuration option: packageRules[0].@1stg/tslint-config, Invalid configuration option: packageRules[0].@babel/types, Invalid configuration option: packageRules[0].@pkgr/imagemin, Invalid configuration option: packageRules[0].@types/jest, Invalid configuration option: packageRules[0].@types/js-yaml, Invalid configuration option: packageRules[0].@types/lodash, Invalid configuration option: packageRules[0].@types/mvdan-sh, Invalid configuration option: packageRules[0].@types/prettier, Invalid configuration option: packageRules[0].core-js, Invalid configuration option: packageRules[0].https-proxy-agent, Invalid configuration option: packageRules[0].js-yaml, Invalid configuration option: packageRules[0].lerna, Invalid configuration option: packageRules[0].lodash, Invalid configuration option: packageRules[0].mvdan-sh, Invalid configuration option: packageRules[0].node-sql-parser, Invalid configuration option: packageRules[0].npm-run-all, Invalid configuration option: packageRules[0].prettier-plugin-pkg, Invalid configuration option: packageRules[0].prettier-plugin-sh, Invalid configuration option: packageRules[0].prettier-plugin-sql, Invalid configuration option: packageRules[0].react, Invalid configuration option: packageRules[0].sql-formatter, Invalid configuration option: packageRules[0].ts-jest, Invalid configuration option: packageRules[0].ts-node, Invalid configuration option: packageRules[0].tslint, Invalid configuration option: packageRules[0].type-coverage, Invalid configuration option: packageRules[0].typescript, Invalid configuration option: packageRules[0].yarn-deduplicate, Invalid configuration option: private, Invalid configuration option: renovate, Invalid configuration option: resolutions, Invalid configuration option: scripts, Invalid configuration option: typeCoverage, Invalid configuration option: version, Invalid configuration option: workspaces

Can't prettify Dockerfile

Dockerfile:

RUN npm install -g [email protected]
RUN ( pnpm install --frozen-lockfile && sed -i.bak "s/\"dependencies\":/\"exports\":{\".\":{\"node\":\".\/main.cjs\",\"default\":\".\/index.js\"},\".\/cache\":{\"node\":\".\/cache\/cache.cjs\",\"default\":\".\/cache\/index.js\"},\".\/core\":{\"node\":\".\/core\/core.cjs\",\"default\":\".\/core\/index.js\"},\".\/utilities\":{\"node\":\".\/utilities\/utilities.cjs\",\"default\":\".\/utilities\/index.js\"},\".\/link\/schema\":{\"node\":\".\/link\/schema\/schema.cjs\",\"default\":\".\/link\/schema\/index.js\"},\".\/link\/context\":{\"node\":\".\/link\/context\/context.cjs\",\"default\":\".\/link\/context\/index.js\"},\".\/link\/http\":{\"node\":\".\/link\/http\/http.cjs\",\"default\":\".\/link\/http\/index.js\"},\".\/link\/ws\":{\"node\":\".\/link\/ws\/ws.cjs\",\"default\":\".\/link\/ws\/index.js\"},\".\/link\/core\":{\"node\":\".\/link\/core\/core.cjs\",\"default\":\".\/link\/core\/index.js\"},\".\/link\/error\":{\"node\":\".\/link\/error\/error.cjs\",\"default\":\".\/link\/error\/index.js\"}},\n\"dependencies\":/" ./node_modules/@apollo/client/package.json && pnpm run fetch:i18n && pnpm run build)

RUN npm install -g @sentry/[email protected] --unsafe-perm
RUN ( if [ -z "$SENTRY_AUTH_TOKEN" ] || [ -z "$SENTRY_ORG" ] || [ -z "$SENTRY_PROJECT" ]; then echo Sourcemaps will not be sent to sentry && find . -type f -name '*.map' -delete ;else sentry-cli releases new "$COMMIT_SHA" && sentry-cli releases set-commits "$COMMIT_SHA" --auto && sentry-cli releases files "$COMMIT_SHA" upload-sourcemaps ./build -x .js -x .map --validate --strip-common-prefix && sentry-cli releases finalize "$COMMIT_SHA" && find . -type f -name '*.map' -delete ;fi )

Output:

Checking formatting...
Dockerfile[error] Dockerfile: SyntaxError: "foo(" must be followed by )
[error]   18 |
[error]   19 | RUN npm install -g [email protected]
[error] > 20 | RUN ( pnpm install --frozen-lockfile && sed -i.bak "s/\"dependencies\":/\"exports\":{\".\":{\"node\":\".\/main.cjs\",\"default\":\".\/index.js\"},\".\/cache\":{\"node\":\".\/cache\/cache.cjs\",\"default\":\".\/cache\/index.js\"},\".\/core\":{\"node\":\".\/core\/core.cjs\",\"default\":\".\/core\/index.js\"},\".\/utilities\":{\"node\":\".\/utilities\/utilities.cjs\",\"default\":\".\/utilities\/index.js\"},\".\/link\/schema\":{\"node\":\".\/link\/schema\/schema.cjs\",\"default\":\".\/link\/schema\/index.js\"},\".\/link\/context\":{\"node\":\".\/link\/context\/context.cjs\",\"default\":\".\/link\/context\/index.js\"},\".\/link\/http\":{\"node\":\".\/link\/http\/http.cjs\",\"default\":\".\/link\/http\/index.js\"},\".\/link\/ws\":{\"node\":\".\/link\/ws\/ws.cjs\",\"default\":\".\/link\/ws\/index.js\"},\".\/link\/core\":{\"node\":\".\/link\/core\/core.cjs\",\"default\":\".\/link\/core\/index.js\"},\".\/link\/error\":{\"node\":\".\/link\/error\/error.cjs\",\"default\":\".\/link\/error\/index.js\"}},\n\"dependencies\":/" ./node_modules/@apollo/client/package.json && pnpm run fetch:i18n && pnpm run build)
[error]      | ^
[error]   21 |
[error]   22 | RUN npm install -g @sentry/[email protected] --unsafe-perm
[error]   23 | RUN ( if [ -z "$SENTRY_AUTH_TOKEN" ] || [ -z "$SENTRY_ORG" ] || [ -z "$SENTRY_PROJECT" ]; then echo Sourcemaps will not be sent to sentry && find . -type f -name '*.map' -delete ;else sentry-cli releases new "$COMMIT_SHA" && sentry-cli releases set-commits "$COMMIT_SHA" --auto && sentry-cli releases files "$COMMIT_SHA" upload-sourcemaps ./build -x .js -x .map --validate --strip-common-prefix && sentry-cli releases finalize "$COMMIT_SHA" && find . -type f -name '*.map' -delete ;fi )

Copyright Issue

Hey. The code here https://github.com/rx-ts/prettier/tree/master/packages/pkg is a clear and obvious derivation of my work here https://github.com/shellscape/prettier-plugin-package.

The MPL-2.0 License clearly states you must retain copyright notice, and you must notify the author (me) of any derivations. Additionally, this clause appears in all source files:

 Copyright © 2019 Andrew Powell
  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of this Source Code Form.

That means, even though you've refactored the code, you still need to include that header.

[prettier-plugin-sql] How to configure options

Hi,

I just found this library, and it seems a great addition to the Prettier ecosystem!

I am having trouble using it, though, because the default configuration is meant for MySQL, and I am not sure how to pass the options to the plugin. It does not seem to be reading them from .prettierrc.yml.

Thanks!

add prettier-plugin topic to the repository

At this moment this plugin is missing any github topics, preventing from making it discoverable on https://github.com/topics/prettier-plugin

Just go to repository home, and use the right sidebar to add prettier-plugin topic to it.

That is more important as there is another https://github.com/azz/prettier-plugin-bash which has that topic, but seems to have considerably less stars.

While this repository seems to be more popular and recently updated, I found that its main page is offline... https://prettier.vercel.app/ returning [object Object]

ini: false error on ; comments

Ini files do also support ; comments and some of them may even prefer them (editors may also add them automatically when using commenting shortcuts).

I observed the this caused errors with mypy.ini files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.