Skip to content

Bug: <short description of the issue> #5994

Closed
@A-Shleifman

Description

@A-Shleifman

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

utils

Playground Link

No response

Repro Code

ESLintUtils.getParserServices(context, true).program.getSourceFile('/Users/user/Documents/repo/src/context.ts');

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "./tsconfig.json",
  },
  plugins: ["@typescript-eslint", "import-access"],
  extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
  ignorePatterns: [".eslintrc.js", "node_modules"],
  rules: {
    "import-access/no-imports-outside-package": [
      "error",
      {
        strictMode: true,
      },
    ],
  },
};

tsconfig

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "eslint-plugin-import-access",
        "strictMode": true
      }
    ],
    "target": "ES2017",
    "module": "CommonJS",
    "esModuleInterop": true,
    "noEmit": true
  },
  "include": ["./src/**/*"]
}

Expected Result

program.getSourceFile('...') returns requested file when parserOptions.project is specified in .eslintrc, but when parserOptions.project is missing, getSourceFile('...') returns the file that is being linted. I would like to remove this setting from .eslintrc, but I can't as it breaks my plugin.

Actual Result

the wrong file is returned

Additional Info

Provided configs are the configs of the project using the plugin, not the project that compiles the plugin

Versions

package version
@typescript-eslint/utils ^5.42.1
@typescript-eslint/eslint-plugin ^5.42.1
@typescript-eslint/parser ^5.42.1
eslint ^8.19.0
eslint-plugin-eslint-plugin ^5.0.0
eslint-plugin-node ^11.1.0
typescript ^4.8.4
node v16.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    working as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    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