[no-var-requires] add an option to ignore require('../package.json')
#1902
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
Create a typescript package that imports fields from
package.json
, e.g.,Attempt to build and publish the module. You will get a build that looks something like this:
☝️ this bundle should include
backoff-timeout.js
,call-credentials-filter.js
. There appears to be a bug (expected behavior?) with npm, such that if there's apackage.json
file in yourbuild/
directory, no JavaScript is included in the publish.Expected Result
@typescript-eslint/no-var-requires
should not advise users toimport
frompackage.json
, as it can lead to bad publications tonpm
.Actual Result
@typescript-eslint/no-var-requires
suggests that you switch anyrequire
s frompackage.json
toimports
.Additional Info
here's where we ran into the issue: grpc/grpc-node#1357
Versions
N/A
, this is related specifically to the@typescript-eslint/no-var-requires
plugin, and is a suggestion for behavior.Thoughts
To help protect folks from this hiccup, it might be nice if
@typescript-eslint/no-var-requires
was able to specifically suggest that folks userequire
on apackage.json
import, while suggestingimport
for other JSON files.The text was updated successfully, but these errors were encountered: