Socket
Socket
Sign inDemoInstall

eslint-import-resolver-node

Package Overview
Dependencies
12
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-import-resolver-node

Node default behavior import resolution plugin for eslint-plugin-import.


Version published
Maintainers
3
Weekly downloads
21,916,562
increased by1.1%
Install size
294 kB

Weekly downloads

Package description

What is eslint-import-resolver-node?

The eslint-import-resolver-node package is a resolver for ESLint's import plugin that resolves node modules and paths. It is used to help ESLint understand the resolution of the import statements in a Node.js environment, ensuring that the paths to modules are correctly interpreted according to Node.js module resolution algorithms.

What are eslint-import-resolver-node's main functionalities?

Resolve Node Modules

This feature allows ESLint to resolve import statements for Node modules, taking into account file extensions like .js, .jsx, .ts, and .tsx. The code sample shows how to configure the resolver in the ESLint configuration file.

module.exports = {
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx']
      }
    }
  }
};

Custom Module Directory

This feature allows the specification of custom module directories beyond the default 'node_modules'. In the code sample, 'src' is added as an additional directory to look for modules.

module.exports = {
  settings: {
    'import/resolver': {
      node: {
        moduleDirectory: ['node_modules', 'src']
      }
    }
  }
};

Other packages similar to eslint-import-resolver-node

Readme

Source

eslint-import-resolver-node

npm

Default Node-style module resolution plugin for eslint-plugin-import.

Published separately to allow pegging to a specific version in case of breaking changes.

Config is passed directly through to resolve as options:

settings:
  import/resolver:
    node:
      extensions:
        # if unset, default is just '.js', but it must be re-added explicitly if set
        - .js
        - .jsx
        - .es6
        - .coffee

      paths:
        # an array of absolute paths which will also be searched
        # think NODE_PATH
        - /usr/local/share/global_modules

      # this is technically for identifying `node_modules` alternate names
      moduleDirectory:

        - node_modules # defaults to 'node_modules', but...
        - bower_components

        - project/src  # can add a path segment here that will act like
                       # a source root, for in-project aliasing (i.e.
                       # `import MyStore from 'stores/my-store'`)

or to use the default options:

settings:
  import/resolver: node

Keywords

FAQs

Last updated on 08 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc