Skip to content

Change Request: Allow to patch ModuleResolver in ESLint 8 #15036

@onigoetz

Description

@onigoetz

ESLint version

8.0.0-beta.1

What problem do you want to solve?

In the current version of ESLint, it's currently not possible to have plugins as dependencies in shared configs (as detailed in #3458)
It is however possible to patch ModuleResolver to make this work :

The patch isn't anything fancy:
https://github.com/swissquote/crafty/blob/master/packages/crafty-preset-eslint/src/patchModuleResolver.js#L78-L95

But it works better than --resolve-plugins-relative-to since it allows to have logic for more than one directory and doesn't require the end-user to add it to each of his calls to eslint

Now since this patching accesses the modules directly at their location inside the eslint or @eslint/eslintrc package it won't be possible anymore as

  • they will be using exports in package.json
  • @eslint/eslintrc is bundled so we can't refer to a module directly
  • Rollup automatically wraps exports in Object.freeze thus effectively blocking require("@eslint/eslintrc").Legacy.ModuleResolver.resolve = someNewResolver
  • Even if patching worked, Rollup simplifies module references to directly refer to the resolve function so it wouldn't take the patch into consideration anyway. ( Fix: ConfigArrayFactory was ignoring the resolver option in some places eslintrc#53 (comment) )

What do you think is the correct solution?

The easiest solution I would see and was proposed by @mdjermanovic : disable the freezing of objects by Rollup : eslint/eslintrc#53 (comment)

That would need to be combined with something that makes sure to not refer to the function directly but to refer to the ModuleResolver object so that the patching works.

This summary is a follow up of the discussion in eslint/eslintrc#53

Participation

  • I am willing to submit a pull request for this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussioncoreRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLint

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy