Gathering detailed insights and metrics for @dword-design/eslint-plugin-import-alias
Gathering detailed insights and metrics for @dword-design/eslint-plugin-import-alias
Gathering detailed insights and metrics for @dword-design/eslint-plugin-import-alias
Gathering detailed insights and metrics for @dword-design/eslint-plugin-import-alias
An ESLint plugin that enforces the use of import aliases. Also supports autofixing.
npm install @dword-design/eslint-plugin-import-alias
Typescript
Module System
Min. Node Version
Node Version
NPM Version
86.5
Supply Chain
97.8
Quality
78.4
Maintenance
100
Vulnerability
99.3
License
TypeScript (99.27%)
Shell (0.73%)
Total Downloads
4,033,993
Last Day
2,247
Last Week
45,118
Last Month
228,370
Last Year
2,973,557
NOASSERTION License
94 Stars
278 Commits
12 Forks
2 Watchers
7 Branches
7 Contributors
Updated on Aug 30, 2025
Latest Version
6.0.3
Package Id
@dword-design/eslint-plugin-import-alias@6.0.3
Unpacked Size
13.05 kB
Size
4.65 kB
File Count
5
NPM Version
10.9.2
Node Version
20.19.2
Published on
Jun 05, 2025
Cumulative downloads
Total Downloads
Last Day
16.8%
2,247
Compared to previous day
Last Week
-33.6%
45,118
Compared to previous week
Last Month
-27.7%
228,370
Compared to previous month
Last Year
284.3%
2,973,557
Compared to previous year
An ESLint plugin that enforces the use of import aliases. Also supports autofixing.
Aliases are a great thing to make imports more readable and you do not have to change import paths that often when a file path is changed.
1import foo from '../../model/sub/foo'; 2import bar from '../other/bar';
changes to
1import foo from '@/model/sub/foo'; 2import bar from '@/sub/other/bar';
Now what if you are in a bigger team or you have a lot of projects to update. Or you just want to make sure that everything is consistent. This is where a linter comes into the play. This rule allows you to detect inconsistent imports and even autofix them. This works by matching alias paths agains the imports and replacing the import paths with the first matching aliased path.
1# npm 2$ npm install @dword-design/eslint-plugin-import-alias 3 4# Yarn 5$ yarn add @dword-design/eslint-plugin-import-alias
Add the plugin to your ESLint config:
1import { defineConfig } from 'eslint/config'; 2import importAlias from '@dword-design/import-alias'; 3 4export default defineConfig([ 5 importAlias.configs.recommended, 6]);
Alright, now you have to tell the plugin which aliases to use. In the simplest case, you are already using babel-plugin-module-resolver for your aliases. Your babel config would look something like this:
1{ 2 "plugins": { 3 ["module-resolver", { 4 "alias": { 5 "@": ".", 6 }, 7 }] 8 } 9}
In this case lucky you, you don't have to do anything else. The plugin should work out of the box.
If you have a special project setup that does not have a babel config in the project path, you can still use the plugin by passing the aliases directly to the rule. In this case you define the rule additionally in the rules
section:
1"rules": { 2 "@dword-design/import-alias/prefer-alias": [ 3 "error", 4 { 5 "alias": { 6 "@": "./src", 7 "@components": "./src/components" 8 } 9 } 10 ] 11}
By default, the plugin will convert parent paths to aliases (like ../model/foo
), but will keep subpath imports relative. You can change that to also convert subpaths to aliased imports by passing the aliasForSubpaths
option to the rule like so:
1"rules": { 2 "@dword-design/import-alias/prefer-alias": ["error", { "aliasForSubpaths": true }] 3}
Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️
Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:
If you want to send me a one time donation. The coffee is pretty good 😊.
Also for one time donations if you like PayPal.
Here you can support me regularly, which is great so I can steadily work on projects.
Thanks a lot for your support! ❤️
No vulnerabilities found.