Skip to content

Files

Latest commit

 

History

History
59 lines (43 loc) · 1.03 KB

File metadata and controls

59 lines (43 loc) · 1.03 KB

Pattern: Use of relative path for aliased module

Issue: -

Description

Allows you to enforce that aliased modules are not using relative paths.

Rule Details

Given the babel configuration below

...
  "plugins": [
    [
      "module-resolver",
      {
        "root": ["."],
        "alias": {
          "action": "./actions"
        }
      }
    ]
  ]
...

The following patterns are considered warnings:

import fetchData from '../../actions/fetchData'
const fetchData = require('../../actions/fetchData')
const fetchData = await import('../../actions/fetchData')

The following patterns are not considered warnings:

import fetchData from 'actions/fetchData'
const fetchData = require('actions/fetchData')
const fetchData = await import('actions/fetchData')

Further Reading