ESLint plugin that enforces absolute import paths, preventing the need to update imports when moving files between folders. Version 1.6.1 supports both legacy ESLint config (.eslintrc) and flat config (eslint.config.js), includes TypeScript types, and offers auto-fix via --fix. Options include allowSameFolder, rootDir, prefix, and allowedDepth for flexible configuration. Unlike similar rules (e.g., import/no-relative-parent-imports), this plugin focuses solely on prohibiting relative imports with fix support.
npm install eslint-plugin-no-relative-import-pathsVerified import paths — ran on the pinned version, not inferred.
Shows flat config and legacy config setup for the plugin with common options: allowSameFolder, rootDir, and prefix.
Update to eslint-plugin-no-relative-import-paths@1.5.4 or newer: npm install eslint-plugin-no-relative-import-paths@latest
Set the rule to 'warn' or 'error' in your ESLint config (or 1 or 2 in legacy config).
Use severity level (0/1/2) instead of 'enabled'. Use 'allowSameFolder' instead of 'ignorePureComponents'.
Set rootDir option to strip the root directory from the absolute path, e.g., { rootDir: 'src' }.Update to v1.5.3 or newer: npm install eslint-plugin-no-relative-import-paths@1.5.3
To allow dynamic or require imports, consider using the 'allowedDepth' option or disable the rule selectively.
Upgrade to v1.6.0 or newer, or manually define types if needed.
Run npm install eslint-plugin-no-relative-import-paths --save-dev
Use 0 (off), 1 (warn), or 2 (error) as numeric values in legacy config, or 'off'/'warn'/'error' in flat config consistently.
In legacy config: add "parserOptions": { "sourceType": "module" }. In flat config, set languageOptions: { sourceType: 'module' }.Update plugin to v1.3.4+: npm install eslint-plugin-no-relative-import-paths@1.3.4
Use plugins: { 'no-relative-import-paths': pluginObject } (not an array).