Skip to content

Bug: [no-var-requires, no-require-imports] support template literal strings for allow #8186

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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.

Playground Link

https://typescript-eslint.io/play#ts=5.3.3&fileType=.ts&code=MYewdgzgLgBAZiEMC8MBOBTAjgVwJaYAUABgHSkD0AJgIZQ2kBWE4xAlANxA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDcBDaWtEQBHWJSGoMAbXDYciaNA7RIAGllysc7JF7x4HAO7owM7dsgAdSwDoAVsg5MAJJA3aAuu4gBfd198QHyA&tsconfig=&tokens=false

Repro Code

var packageData = require(`../package.json`);

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/<rule-name>": ["error", { allow: ['\\.json$'] }],
  },
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

This should be allowed.

Actual Result

Require statement not part of import statement.

Because the rule doesn't look at template literals inside call expressions, it still gets the complaint.

Additional Info

Note that the production site won't have the allow option in the playground until the next release. I'm filing this as a fast follow from #7710 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions