You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
see the below log. Note the rangeEnd and rangeStart, that can probably be used to detect when a range is being formatted and skip the plugin processing, as a first-pass fix.
I verified that this plugin is the issue by removing the plugin from the config; it works as expected when I do so.
Error log
vscode error log
["INFO" - 6:23:40 PM] Formatting file:///Users/forivall/code/sandbox/prettier-sort-imports-repro/repro.js
["INFO" - 6:23:40 PM] Using config file at /Users/forivall/code/sandbox/prettier-sort-imports-repro/.prettierrc
["INFO" - 6:23:40 PM] PrettierInstance:
{
"modulePath": "/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/prettier",
"messageResolvers": {},
"version": "3.3.3"
}
["INFO" - 6:23:40 PM] Using ignore file (if present) at /Users/forivall/code/sandbox/prettier-sort-imports-repro/.prettierignore
["INFO" - 6:23:40 PM] File Info:
{
"ignored": false,
"inferredParser": "babel"
}
["INFO" - 6:23:40 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 6:23:40 PM] Prettier Options:
{
"filepath": "/Users/forivall/code/sandbox/prettier-sort-imports-repro/repro.js",
"parser": "babel",
"rangeEnd": 61,
"rangeStart": 21,
"useTabs": false,
"tabWidth": 2,
"endOfLine": "lf",
"bracketSpacing": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"^(@ttc|@ttc-dev|ttc-)/(.*)",
"^[./]"
],
"importOrderCaseInsensitive": true,
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": [
"typescript",
"decorators-legacy",
"importAssertions"
],
"plugins": [
"/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@trivago/prettier-plugin-sort-imports/lib/src/index.js",
"/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/prettier-plugin-packagejson/lib/index.cjs"
],
"proseWrap": "never",
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
["ERROR" - 6:23:40 PM] Error formatting document.
SyntaxError: 'return' outside of function. (1:0)
at constructor (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:351:19)
at TypeScriptParserMixin.raise (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:3237:19)
at TypeScriptParserMixin.parseReturnStatement (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12610:12)
at TypeScriptParserMixin.parseStatementContent (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12267:21)
at TypeScriptParserMixin.parseStatementContent (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:9110:18)
at TypeScriptParserMixin.parseStatementLike (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12236:17)
at TypeScriptParserMixin.parseModuleItem (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12213:17)
at TypeScriptParserMixin.parseBlockOrModuleBlockBody (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12793:36)
at TypeScriptParserMixin.parseBlockBody (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12786:10)
at TypeScriptParserMixin.parseProgram (/Users/forivall/code/sandbox/prettier-sort-imports-repro/node_modules/@babel/parser/lib/index.js:12113:10)
["INFO" - 6:23:40 PM] Formatting completed in 22ms.
Contribute to @trivago/prettier-plugin-sort-imports
I'm willing to fix this bug 🥇
The text was updated successfully, but these errors were encountered:
Your Environment
Describe the bug
Formatting a selection from within VScode can fail
To Reproduce
With the following code:
select only the return statement
Format the selection
Expected behavior
The selection should be formatted as
Screenshots, code sample, etc
Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)
see the below log. Note the
rangeEnd
andrangeStart
, that can probably be used to detect when a range is being formatted and skip the plugin processing, as a first-pass fix.I verified that this plugin is the issue by removing the plugin from the config; it works as expected when I do so.
Error log
vscode error log
Contribute to @trivago/prettier-plugin-sort-imports
The text was updated successfully, but these errors were encountered: