Pavel
Pavel

Reputation: 2193

ESLint rule: maximum nesting path for file

Is there such a rule that checks the file path nesting level? For example:

Examples of incorrect code for this rule:

import { notifyDevelopers } from '../../../../../utils/ajax'

Examples of correct code for this rule:

import { notifyDevelopers } from './../utils/ajax'
import { notifyDevelopers } from 'utils/ajax'

I found only this package: https://github.com/benmosher/eslint-plugin-import

but it seems that this package does not have such rule

Upvotes: 1

Views: 475

Answers (1)

Pavel
Pavel

Reputation: 2193

.eslintrc

{
  "rules": {
    "no-restricted-imports": [
      "error",
      {
        "patterns": ["../../../*"]
      }
    ]
  }
}

no-restricted-modules rule, also support this

Upvotes: 1

Related Questions