Skip to content

Repo: deprecate no-var-requires in favor of no-require-imports #8092

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

Closed
Josh-Cena opened this issue Dec 18, 2023 · 4 comments · Fixed by #8334
Closed

Repo: deprecate no-var-requires in favor of no-require-imports #8092

Josh-Cena opened this issue Dec 18, 2023 · 4 comments · Fixed by #8334
Labels
accepting prs Go ahead, send a pull request that resolves this issue breaking change This change will require a new major version to be released locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Milestone

Comments

@Josh-Cena
Copy link
Member

Suggestion

I was discussing this with @bradzacher and @JoshuaKGoldberg.

no-var-requires is a strict subset of no-require-imports: the former only detects require() expressions in very limited contexts (including variable declarations, new expressions, call expressions, member expressions). The latter bans all require expressions and import = require declarations.

They were both imported from other plugins:

Why TSLint has two rules remains unknown, but for the purpose of our maintenance I don't see why we need both. Let's implement no-var-requires as part of no-require-imports (an option called allowAsImport) instead.

@Josh-Cena Josh-Cena added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look breaking change This change will require a new major version to be released labels Dec 18, 2023
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Dec 23, 2023
@bradzacher bradzacher added this to the 7.0.0 milestone Dec 23, 2023
arkapratimc added a commit to arkapratimc/typescript-eslint that referenced this issue Feb 1, 2024
@bradzacher
Copy link
Member

They were both imported from other plugins:
...
no-var-requires comes from eslint-plugin-typescript:

Nitpick note: the rule didn't come from eslint-plugin-typescript - instead eslint-plugin-typescript became/was renamed to @typescript-eslint/eslint-plugin.

@bradzacher
Copy link
Member

One note is that it is a nice feature to ban require but allow import = require.

I.e. It allows a codebase to function without CJS interop.

We'll need to take care of the rule options to ensure we don't lose coverage.

@Josh-Cena
Copy link
Member Author

it is a nice feature to ban require but allow import = require.

That's exactly the proposed allowAsImport option!

@JoshuaKGoldberg
Copy link
Member

#8334 was merged into the v8 branch. ✅

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jun 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 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 breaking change This change will require a new major version to be released locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants
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