Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 910 Bytes

no-relative-imports.md

File metadata and controls

23 lines (17 loc) · 910 Bytes

Pattern: Use of relative import

Issue: -

Description

Do not use relative paths when importing external modules or ES6 import declarations. The advantages of removing all relative paths from imports is that:

  • The import name will be consistent across all files and subdirectories so searching for usages is much easier.
  • Moving source files to different folders will not require you to edit your import statements.
    1. It will be possible to copy and paste import lines between files regardless of the file location.
    1. version control diffs will be simplified by having overall fewer edits to the import lines.

Option allow-siblings can be passed to allow relative imports for files in the same or nested folders.

Further Reading