Closed okitan closed 1 year ago
Thanks for the feedback!
The plugin uses your local typescript compiler first, or bundled one (v4.9) if not found. My guess is the local TS is too old. Could you check it?
If it's not working, I'd need your plugin logs which can be obtained following instructions in "Debug Mode" in CONTRIBUTION.md.
The plugin uses your local typescript compiler first, or bundled one (v4.9) if not found. My guess is the local TS is too old. Could you check it?
I'm using typescript@4.9.3 and also debug logs show it.
Here is the debug logs:
[2022-12-05T18:09:07.405] [INFO] default - os: {
arch: 'arm64',
platform: 'darwin',
type: 'Darwin',
release: '22.1.0',
totalmem: 25769803776,
freemem: 608043008,
EOL: '\n'
}
[2022-12-05T18:09:07.405] [INFO] default - vscode: { version: '1.73.1' }
[2022-12-05T18:09:14.005] [INFO] vscode.resolveConfig - Resolving config for fileName: /Users/okita.kunio/tmp/pretter/c.ts languageId: typescript
[2022-12-05T18:09:14.007] [DEBUG] format-imports.loadPretConfig - Loading Prettier/EditorConfig config for fileName: /Users/okita.kunio/tmp/pretter/c.ts
[2022-12-05T18:09:14.009] [DEBUG] require-module.requireUserModule - Found prettier in /Users/okita.kunio/tmp/pretter/node_modules/prettier
[2022-12-05T18:09:14.032] [DEBUG] format-imports.loadPretConfig - Prettier API version: 2.8.0
[2022-12-05T18:09:14.037] [DEBUG] format-imports.loadPretConfig - Prettier config: null
[2022-12-05T18:09:14.037] [DEBUG] format-imports.fileConfig - Loading JSON config from import-sorter.json
[2022-12-05T18:09:14.038] [DEBUG] format-imports.packageConfig - Loading package.json config for fileName: /Users/okita.kunio/tmp/pretter/c.ts
[2022-12-05T18:09:14.038] [DEBUG] format-imports.packageConfig - Found package.json in /Users/okita.kunio/tmp/pretter/package.json
[2022-12-05T18:09:14.038] [DEBUG] format-imports.packageConfig - Found package.json /Users/okita.kunio/tmp/pretter/package.json and config: undefined
[2022-12-05T18:09:14.038] [DEBUG] format-imports.enhanceEol - Determining EOL
[2022-12-05T18:09:14.039] [DEBUG] format-imports.formatSourceFromFile - Config: {
configurationFileName: 'import-sorter.json',
autoFormat: 'onSave',
formatExports: true,
exclude: [ 'node_modules' ],
excludeGlob: [],
sortImportsBy: 'paths',
nodeProtocol: 'preserve',
groupRules: [
'^react(-dom)?$',
'^@angular/',
'^vue$',
'^node:',
{},
'^[@]',
'^[.]'
],
sortRules: { paths: [ '_', 'aA' ], names: [ '_', 'aA' ] },
keepUnused: [],
emptyLinesBetweenGroups: 1,
emptyLinesAfterAllImports: 1,
removeLastSlashInPath: false,
removeLastIndexInPath: false,
wrappingStyle: {
maxBindingNamesPerLine: 0,
maxDefaultAndBindingNamesPerLine: 2,
maxExportNamesPerLine: 0,
maxNamesPerWrappedLine: 1,
ignoreComments: false
},
development: { enableDebug: true },
insertFinalNewline: 'preserve',
eol: 'LF',
force: false
}
[2022-12-05T18:09:14.039] [DEBUG] format-imports.formatSourceFromFile - Options: undefined
[2022-12-05T18:09:14.039] [DEBUG] format-imports.loadTsConfig - Loading TS config for fileName: /Users/okita.kunio/tmp/pretter/c.ts from default
[2022-12-05T18:09:14.039] [DEBUG] require-module.requireUserModule - Found typescript in /Users/okita.kunio/tmp/pretter/node_modules/typescript
[2022-12-05T18:09:14.085] [DEBUG] format-imports.loadTsConfig - TypeScript API version: 4.9.3
[2022-12-05T18:09:14.085] [DEBUG] format-imports.loadESLintConfig - Loading ESLint config for fileName: /Users/okita.kunio/tmp/pretter/c.ts from default
[2022-12-05T18:09:14.085] [WARN] require-module.requireModule - Cannot find eslint from path: /Users/okita.kunio/tmp/pretter/c.ts and use default provided
[2022-12-05T18:09:14.085] [DEBUG] format-imports.loadESLintConfig - ESLint API version: 8.28.0
[2022-12-05T18:09:14.093] [WARN] format-imports.loadESLintConfig - Failed to load ESLint config for fileName: /Users/okita.kunio/tmp/pretter/c.ts with error: No ESLint configuration found in /Users/okita.kunio/tmp/pretter.
[2022-12-05T18:09:14.093] [INFO] format-imports.formatSource - Formatting /Users/okita.kunio/tmp/pretter/c.ts with enhanced config: {
configurationFileName: 'import-sorter.json',
autoFormat: 'onSave',
formatExports: true,
exclude: [ 'node_modules' ],
excludeGlob: [],
sortImportsBy: 'paths',
nodeProtocol: 'preserve',
groupRules: [
'^react(-dom)?$',
'^@angular/',
'^vue$',
'^node:',
{},
'^[@]',
'^[.]'
],
sortRules: { paths: [ '_', 'aA' ], names: [ '_', 'aA' ] },
keepUnused: [],
emptyLinesBetweenGroups: 1,
emptyLinesAfterAllImports: 1,
removeLastSlashInPath: false,
removeLastIndexInPath: false,
wrappingStyle: {
maxBindingNamesPerLine: 0,
maxDefaultAndBindingNamesPerLine: 2,
maxExportNamesPerLine: 0,
maxNamesPerWrappedLine: 1,
ignoreComments: false
},
development: { enableDebug: true },
insertFinalNewline: 'preserve',
eol: 'LF',
force: false
}
[2022-12-05T18:09:14.094] [DEBUG] format-imports.formatSource - tsCompilerOptions: undefined
[2022-12-05T18:09:14.094] [DEBUG] format-imports.formatSource - ESLint config processed: undefined
[2022-12-05T18:09:14.094] [DEBUG] format-imports.formatSource - composeConfig: {
maxLength: 80,
wrap: {
withoutDefault: 9007199254740991,
withDefault: 2,
perLine: 1,
exported: 9007199254740991,
parts: true,
skipCmt: false
},
groupSep: '\n\n',
groupEnd: 2,
tab: ' ',
tabw: 2,
quote: [Function (anonymous)],
sComma: '',
mComma: ',',
semi: ';',
bracket: [Function (anonymous)],
lastNewLine: undefined,
nl: '\n'
}
[2022-12-05T18:09:14.110] [INFO] vscode.formatDocument - Finished format
Sorry for the late response!
I think it's a bug in TS 4.9.3 that it thinks Fuga
is unused.
I updated to TS 4.9.4 and it works fine.
@daidodo
Thank you for the response. I updated and confirmed the fix.
Thx!
Describe the bug When I use
satisfies
operator intruduced in Typescript 4.9. JS/TS Import/Export Sorter removes lines I actually used.To Reproduce
Given:
a.ts
b.ts
When: JS/TS Import/Export Sorter formater runs against
c.ts
.Expected behavior It should remain as is.
Actual behavior It removes
import { Fuga } from './b';
OS (please complete the following information):
VS Code (please complete the following information):