Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.93 KB

no-extraneous-require.md

File metadata and controls

51 lines (34 loc) · 1.93 KB

Disallow require() expressions which import extraneous modules (n/no-extraneous-require)

💼 This rule is enabled in the following configs: ☑️ flat/recommended, 🟢 flat/recommended-module, ✅ flat/recommended-script, ☑️ recommended, 🟢 recommended-module, ✅ recommended-script.

If a require()'s target is extraneous (it's not written in package.json), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors. This rule disallows require() of extraneous modules.

📖 Rule Details

This rule warns require() of extraneous modules.

Options

{
    "rules": {
        "n/no-extraneous-require": ["error", {
            "allowModules": [],
            "resolvePaths": [],
            "tryExtensions": []
        }]
    }
}

allowModules

This can be configured in the rule options or as a shared setting settings.allowModules. Please see the shared settings documentation for more information.

resolvePaths

This can be configured in the rule options or as a shared setting settings.resolvePaths. Please see the shared settings documentation for more information.

convertPath

This can be configured in the rule options or as a shared setting settings.convertPath. Please see the shared settings documentation for more information.

tryExtensions

This can be configured in the rule options or as a shared setting settings.tryExtensions. Please see the shared settings documentation for more information.

🔎 Implementation