📋 Summary
When customImportSort.sortOnSave is enabled, the extension strips the final newline character (\n) when rewriting the file after sorting imports. This directly conflicts with ESLint's eol-last rule (which requires files to end with exactly one newline) and creates a frustrating save loop:
- File saved with final
\n
- Extension sorts imports → removes final
\n
- ESLint reports
eol-last error
Steps to Reproduce
- Install
custom-import-sort extension
- Set
"customImportSort.sortOnSave": true in VS Code settings
- Enable ESLint rule:
"eol-last": ["error", "always"] in .eslintrc
- Enable ESLint auto-fix on save:
"editor.codeActionsOnSave": ["source.fixAll.markdownlint", "source.fixAll.eslint"],
- Open a
.js/.jsx file that ends with a newline
- Press
Ctrl+S (or Cmd+S)
- Observe that the final newline is removed and ESLint triggers
eol-last
✅ Expected Behavior
- The extension should preserve the file's trailing newline when writing sorted imports
- Files should continue to comply with
eol-last after auto-sorting
- No lint errors should appear after a normal save
❌ Actual Behavior
- The extension overwrites the file without a trailing newline
- ESLint immediately flags
eol-last
- Developers must manually re-add the newline or wait for ESLint's auto-fix, creating a broken workflow
🖥️ Environment
- VS Code Version:
1.121.0
- Extension Version:
1.0.6
- OS:
[Windows 11]
- ESLint Version:
7.8.1
- Node Version:
22
📋 Summary
When
customImportSort.sortOnSaveis enabled, the extension strips the final newline character (\n) when rewriting the file after sorting imports. This directly conflicts with ESLint'seol-lastrule (which requires files to end with exactly one newline) and creates a frustrating save loop:\n\neol-lasterrorSteps to Reproduce
custom-import-sortextension"customImportSort.sortOnSave": truein VS Code settings"eol-last": ["error", "always"]in.eslintrc"editor.codeActionsOnSave": ["source.fixAll.markdownlint", "source.fixAll.eslint"],.js/.jsxfile that ends with a newlineCtrl+S(orCmd+S)eol-last✅ Expected Behavior
eol-lastafter auto-sorting❌ Actual Behavior
eol-last🖥️ Environment
1.121.01.0.6[Windows 11]7.8.122