If you want esLint to run across your code in one commit, call npx eslint . --fix.

This will run eslint and attempt to fix all possible issues (such as import sorting) that it can.

In my vsCode settings.json I have the following:

  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },
  "eslint.ignoreUntitled": true,
  "eslint.validate": ["javascript", "typescript"],
  "eslint.format.enable": true,
  "eslint.run": "onSave",

This will then run eslint on save to correct issues like imports or let => const

Also, make sure VScode is updated; on ubuntu, it took updating the app to get this working.

Answer from Shadoath on Stack Overflow
🌐
GitHub
github.com › eslint › eslint › issues › 11542
sort-import does not auto fix · Issue #11542 · eslint/eslint
January 25, 2019 - /home/tristan957/Projects/myma-store-server/src/product/product.module.ts 4:1 error Imports should be sorted alphabetically sort-imports /home/tristan957/Projects/myma-store-server/src/product/product.providers.ts 2:1 error Imports should be sorted alphabetically sort-imports 4:1 error Imports should be sorted alphabetically sort-imports /home/tristan957/Projects/myma-store-server/src/product/product.service.ts 4:1 error Expected 'single' syntax before 'multiple' syntax sort-imports
Author   tristan957
🌐
GitHub
github.com › lydell › eslint-plugin-simple-import-sort
GitHub - lydell/eslint-plugin-simple-import-sort: Easy autofixable import sorting. · GitHub
Easy autofixable import sorting. ... This is for those who use eslint --fix (autofix) a lot and want to completely forget about sorting imports!
Starred by 2.4K users
Forked by 73 users
Languages   JavaScript
🌐
DEV Community
dev.to › receter › automatic-import-sorting-in-vscode-275m
Automatic import sorting with ESLint - DEV Community
August 14, 2024 - Recently I found that it is possible to automatically sort imports in VS Code when saving a file. To do this you just need to set a flag in the settings.json ... If, like me, you need more precise settings, you can also use eslint plugins in ...
🌐
npm
npmjs.com › package › eslint-plugin-sort-imports-es6-autofix
eslint-plugin-sort-imports-es6-autofix - npm
March 18, 2021 - This rule respects whitespace and comments between imports by only looking at the order of (and sorting) consecutive import statements (those without newlines/comments in between them). This fork also fixes the import order on eslint --fix.
      » npm install eslint-plugin-sort-imports-es6-autofix
    
🌐
GitHub
github.com › marudor › eslint-plugin-sort-imports-es6-autofix
GitHub - marudor/eslint-plugin-sort-imports-es6-autofix
This rule respects whitespace and comments between imports by only looking at the order of (and sorting) consecutive import statements (those without newlines/comments in between them). This fork also fixes the import order on eslint --fix.
Starred by 83 users
Forked by 15 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
ESLint
eslint.org › docs › latest › rules › sort-imports
sort-imports - ESLint - Pluggable JavaScript Linter
This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by the first member or alias name.
🌐
npm
npmjs.com › package › eslint-plugin-simple-import-sort
eslint-plugin-simple-import-sort - npm
July 2, 2024 - Start using eslint-plugin-simple-import-sort in your project by running `npm i eslint-plugin-simple-import-sort`. There are 1574 other projects in the npm registry using eslint-plugin-simple-import-sort.
      » npm install eslint-plugin-simple-import-sort
    
Published   Jul 02, 2024
Version   12.1.1
Author   Simon Lydell
🌐
vimtutor
remarkablemark.org › blog › 2020 › 01 › 12 › eslint-sort-imports
ESLint sort imports | remarkablemark
October 4, 2021 - /home/runner/eslint-sort-impor... and 0 warnings potentially fixable with the `--fix` option. Autofixable errors can be fixed by passing --fix in the CLI:...
Find elsewhere
🌐
CodeSandbox
codesandbox.io › examples › package › eslint-plugin-sort-imports-es6-autofix
eslint-plugin-sort-imports-es6-autofix examples - CodeSandbox
October 10, 2021 - Use this online eslint-plugin-sort-imports-es6-autofix playground to view and fork eslint-plugin-sort-imports-es6-autofix example apps and templates on CodeSandbox.
🌐
npm
npmjs.com › package › @youre › eslint-plugin-sort-imports-es6-autofix
@youre/eslint-plugin-sort-imports-es6-autofix - npm
July 2, 2024 - This rule respects whitespace and comments between imports by only looking at the order of (and sorting) consecutive import statements (those without newlines/comments in between them). This fork also fixes the import order on eslint --fix.
      » npm install @youre/eslint-plugin-sort-imports-es6-autofix
    
🌐
npm
npmjs.com › search
eslint sort import - npm search
Fork of eslint rule that sorts keys in objects (https://eslint.org/docs/rules/sort-keys) with autofix enabled ... leo-buneev• 1.1.2 • 5 years ago • 224 dependents • ISCpublished version 1.1.2, 5 years ago224 dependents licensed under $ISC ... A sort-imports rule that properly distinguishes between ES6 import types.
🌐
Oxidation Compiler
oxc.rs › docs › guide › usage › linter › rules › eslint › sort-imports
eslint/sort-imports | The JavaScript Oxidation Compiler
Consistent import sorting can be useful for readability and maintainability of code. ... When true, the rule allows import groups separated by blank lines to be treated independently.
🌐
Medium
engineering.udacity.com › sorting-imports-on-save-in-react-projects-with-eslint-6fd419b994c3
Sorting imports on save in React projects with ESLint. | by Kolby Sisk | Udacity Eng & Data
January 31, 2022 - Figuring out how to automatically sort imports on save was much harder than I’d like to admit. Maybe it’s because I’m particularly picky about the order, or that I wanted it to integrate nicely with the tools I’m already using. Either way, I figured it out and here’s how I did it. Customizable ordering. I want React imports first ... Join Medium for free to get updates from this writer. ... Install the ESLint extension.
🌐
DEV Community
dev.to › julioxavierr › sorting-your-imports-with-eslint-3ped
Sorting your imports with ESLint - DEV Community
January 11, 2023 - # eslintrc.json { "plugins": ["react", "simple-import-sort"], "rules": { // increase the severity of rules so they are auto-fixable "simple-import-sort/imports": "error", "simple-import-sort/exports": "error" } }
🌐
Yarn
yarnpkg.com › package
eslint-plugin-sort-imports-es6-autofix
Yarn is a package manager that doubles down as project manager. Whether you work on simple projects or industry monorepos, whether you're an open source developer or an enterprise user, Yarn has your back · First package manager built specifically around workspaces, Yarn lets you split your ...
🌐
GitHub
github.com › eslint › eslint › issues › 6866
Sort-imports autofixer · Issue #6866 · eslint/eslint
August 8, 2016 - Implement sort-imports rule autofixer. There is sort-import rule but there is no autofixer. Add an option to put some imports on the very top. For example imports from React should go first. The au...
🌐
Medium
medium.com › weekly-webtips › how-to-sort-imports-like-a-pro-in-typescript-4ee8afd7258a
How to sort imports like a pro in TypeScript | by Fast Nguyen | Webtips | Medium
February 14, 2022 - Now you just run ONLY one single command yarn lint:fix to fix all coding style issues caught by ESLint. Easy work, right? 😁 ... To sum up, all of the steps we need to get our TypeScript project imports sorted automatically, there are 3 steps:
🌐
Npm
npm.io › package › eslint-plugin-sort-imports-es6-autofix
Eslint-plugin-sort-imports-es6-autofix NPM | npm.io
This rule respects whitespace and comments between imports by only looking at the order of (and sorting) consecutive import statements (those without newlines/comments in between them). This fork also fixes the import order on eslint --fix.