Skip to content

Change Request: Provide an API for rule to specify dependency for caching purposes #19869

Closed as not planned
@Knagis

Description

@Knagis

ESLint version

9.29.0

What problem do you want to solve?

We have our custom rule that performs the linting based on tsconfig and package.json file it finds. The idea is that the lint rule automatically checks if a TS feature is enabled (or for example, if package.json has type:module) and adjusts the behavior accordingly.

In our case we run in monorepo, where eslint is configured globally but then there are 200 different package/tsconfig files - so reading the tsconfig and passing it in eslintrc as object to the rule isn't an option.

However, eslint currently caches rule result based on the file being linted only - so fixing the issue on the other side - the config file, result in IDE (or cli launch with --cache) still showing the old error.

What do you think is the correct solution?

either:

  1. add API to the context passed to rule function: context.addCacheDependency("path/to/file")
  2. add option to configure files in eslintrc that invalidate cache - for example, by default this could have package.json/yarn.lock and similar files, but could be extended

Participation

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

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelates 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