By Dmytro Laptiev • October 2, 2025
Hello, today I am going to share my best practice with setuping eslint for sorting pacakge in the project. I prefer when my import stanaments are organized. Let's start
1. We need to do is to install eslint (if needed)
npm init @eslint/config@latest
2. We need to install eslint import plugin
npm install eslint-plugin-import --dev
3. We need to update our eslint config file
module.exports = {
// ... here is our previous configuration ...
plugins: [
['@typescript-eslint', 'prettier', 'import'],
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
// ... here is our previous rules ...
// turn on errors for missing imports
'import/no-unresolved': 'error',
'import/order': [
'error',
{
groups: [
'builtin', // Built-in imports (come from NodeJS native) go first
'external', // <- External imports
'internal', // <- Absolute imports
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
'index', // <- index imports
'unknown', // <- unknown
],
'newlines-between': 'always',
alphabetize: {
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
order: 'asc',
/* ignore case. Options: [true, false] */
caseInsensitive: true,
},
},
],
}
};