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

fix(rule): turn off @typescript-eslint/no-var-requires #578

Merged
merged 1 commit into from Oct 11, 2020

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Oct 9, 2020

It's a common pattern to require('package.json') to determine the version # of an application.

We do this in all of our auto generated code:

https://github.com/googleapis/nodejs-asset/pull/403/files

Why this rule is a big problem for client libraries

If we switch these require statements to import statements, it breaks publication of our libraries, because TypeScript copies the package.json into the build/ folder, which in turn stops npm from publishing assets in that folder.

Another argument I'd make against this rule

require isn't just used for pulling in JavaScript files, it's convenient for loading JSON fixtures other than package.json, .e.g., test/fixtures/foo.json -- this is a useful pattern in tests which we'd now need to add ignore rules for.

@google-cla google-cla bot added the cla: yes label Oct 9, 2020
@JustinBeckwith JustinBeckwith merged commit 3b37229 into master Oct 11, 2020
@bcoe bcoe deleted the allow-var-requires branch October 12, 2020 20:11
nevilm-lt pushed a commit to nevilm-lt/gts that referenced this pull request Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants