Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
JoshuaKGoldberg opened this issue Jan 4, 2024 · 0 comments · Fixed by #8408
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

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)

@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jan 4, 2024
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Feb 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
1 participant