un-ts / prettier Goto Github PK
View Code? Open in Web Editor NEW:package: Opinionated but Incredible Prettier plugins.
Home Page: https://prettier.vercel.app
License: MIT License
:package: Opinionated but Incredible Prettier plugins.
Home Page: https://prettier.vercel.app
License: MIT License
Here is an example of valid ini entry which makes the formatter choke https://github.com/ansible-community/ansible-lint/blob/main/pytest.ini#L33
These quotes are causing it to work and I am 100% that is the expected format for these entries.
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]
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
@types/react
, @types/react-dom
, react
, react-dom
)@vitest/coverage-istanbul
, vitest
)node
, @types/node
)@vitest/coverage-istanbul
, vitest
).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
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.7
@mdx-js/rollup ^3.0.1
@types/lodash ^4.17.7
@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.152
@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.3
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
.nvmrc
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.
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.
From https://prettier.io/docs/en/ignore.html :
Use “prettier-ignore” comments to ignore parts of files.
So, I expected a comment like this
#!/usr/bin/env bash
# prettier-ignore
die() { echo "$*" 1>&2 ; exit 1; }
# .. rest of script
to cause the die
function to not be formatted, but, it still does get formatted.
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"
}
This seems possible according to this comment: prettier/prettier#4774 (comment). This will make extensionless shell programs work out of the box with prettier.
It looks like adding an interpreters
entry to the languages
objects (reference https://github.com/prettier/prettier/blob/ba500e22f9001107dd9150629687df878e02b1f4/src/main/options.js#L185-L190). Also the languages would require a new since
property to pass the previous filter.
It would be super cool to see this support prettier
's embed
API, so it could format SQL strings in JS/TS: https://prettier.io/docs/en/plugins.html#optional-embed (unless it's the TS/JS code that actually needs to support embed
in order to invoke prettier-plugin-sql
?)
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.
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?
Parser Options does not seem to match the actual options.
prettier/packages/sql/src/index.ts
Lines 45 to 370 in 7d49275
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.
in package.json, sql-formatter's version is too low
"sql-formatter": "^10.5.1",
so I couldn't use 'bigquery' as language.
please update it
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
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:
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.
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.
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
@flex-development/exceptions
and @flex-development/tutils
from dependencies
yarn
in the project rootyarn check:format
or yarn fix:format
There should be no warnings in the console.
Screenshot of logs after running prettier --check .
prettier
version: v2.3.1
prettier-plugin-sh
version: v0.6.1
Unsure of a possible solutions.
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 -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
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
After updated prettier-plugin-sh
to 0.8.0 it not works anymore.
Dies with the error Couldn't resolve parser sh
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]"
🌲 This module requires an LTS Node version (v8.0.0+).
This should be modified to reflect that.
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
formats files without final newline, but it conflicts with editorconfig etc.
It would be nice to have an option to insert a newline at the end of the file.
It is still buggy in some cases
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!
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.
Could support to run in browerser enviroment?
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:
When formatting a file that checks if a command exists with command -v the formatting fails.
#!/bin/sh
echo "Starting setup of this project"
if [[ ! command -v npm > /dev/null 2>&1 ]] ; then
echo "Missing npm, stopping script"
exit
fi
$ 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
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.
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
}
Hello and thanks for this awesome plugin.
I am trying to configure the paramTypes
option as defined in sql-formatter, but when I do:
{
"prettier": {
"paramTypes": {
"named": [
":"
]
}
}
}
I get the following error when running prettier:
[error] Invalid paramTypes value. Expected , but received { named: [":"] }.
I am not sure why or how to fix it.
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.
Can we pass custom options to plugins? For example, we can allow passing options.keyOrder
which if preset it will be used instead of the primary
I keep getting Ignored unknown option
when I run prettier. My shell files are still being formatted, so I have the extension installed.
My config file:
...
keepComments: true
indent: 4
binaryNextLine: true
switchCaseIndent: true
spaceRedirects: true
keepPadding: false
minify: false
functionNextLine: true
...
setup.cfg
is an ini file where you MUST be allowed to use parentheses. Here is a perfectly fine snipped that causes an error https://github.com/ansible-community/ansible-lint/blob/main/setup.cfg#L36
I found the same kind of error being raised from tox.ini files:
[error] > 153 | description = Perform ecosystem impact (downstream testing) https://github.com/ansible-community/ansible-lint/discussions/14
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?
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.
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`...`)?
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 )
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.
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 echo
s).
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)
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)
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)
I'm getting:
.env.development.local[error] No parser could be inferred for file: .env.development.local
Just .env
works fine.
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;
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.