eslint-import-resolver-parcel2

1.0.1 • Public • Published

npm Version Tests codecov License

eslint-import-resolver-parcel2

Parcel import resolution plugin for eslint-plugin-import. This allows eslint/import to work with module resolution in Parcel 2.

This plugin is based on ABuffSeagull/eslint-import-resolver-parcel, but adds support for non-code assets in Parcel 2 and named pipelines.

Installing

Installation is with npm:

npm install -D eslint-import-resolver-parcel2

or yarn:

yarn add --dev eslint-import-resolver-parcel2

Usage

Add this to your eslint config:

settings: {
  "import/resolver": "parcel2"
}

See the Parcel 2 documentation for details on how Parcel resolves dependencies -- this plugin is intended to follow this specification.

If migrating from Parcel 1 (parceljs), note that Parcel 2 doesn't support glob file paths.

A Note on Absolute Paths

Absolute paths are resolved relative to the project root, which can depend on the entrypoint passed to Parcel (see here). This plugin will use the folder where eslint is called from as the project root (which will be appropriate in most cases), but if you need to specify an alternative project root, you can do so in your eslint config:

settings: {
  "import/resolver": {
    parcel: {
      projectRoot: "src" // wherever your entrypoints are located
    }
  }
}

Extensions

If an asset is imported without specifying a file extension, Parcel 2 will look for the following extensions in this order: ["ts", "tsx", "js", "jsx", "json", "css", "styl", "vue"]. Other extensions need to be specified in full in the import statement. This plugin follows the same behaviour. If you are using a custom resolver, however, it may be convenient to add extensions to this list. This can be done in your eslint config by specifying a value for the extensions key:

settings: {
  "import/resolver": {
    parcel: {
      extensions: [".svelte"]  // additional extensions to look for
    }
  }
}

Package Sidebar

Install

npm i eslint-import-resolver-parcel2

Weekly Downloads

208

Version

1.0.1

License

MIT

Unpacked Size

18 kB

Total Files

9

Last publish

Collaborators

  • simonwiles