Path: blob/main/docs/rules/no-useless-path-segments.md
829 views
import/no-useless-path-segments
Use this rule to prevent unnecessary path segments in import and require statements.
Rule Details
Given the following folder structure:
The following patterns are considered problems:
The following patterns are NOT considered problems:
Options
noUselessIndex
If you want to detect unnecessary /index or /index.js (depending on the specified file extensions, see below) imports in your paths, you can enable the option noUselessIndex. By default it is set to false:
Additionally to the patterns described above, the following imports are considered problems if noUselessIndex is enabled:
Note: noUselessIndex only avoids ambiguous imports for .js files if you haven't specified other resolved file extensions. See Settings: import/extensions for details.
commonjs
When set to true, this rule checks CommonJS imports. Default to false.