0

In a NodeJS, if a module exports a symbol with one name

// File: module-a.jsclass Foo {}module.exports = Foo

it's possible, and common, for that export to imported with a different name

// file: module-b.jsconst Baz = require('./module-a')

Is there an ESLint rule that can flag exported classes and constructor functions that are imported with variable names different from their actual symbol name?

askedJun 4, 2020 at 22:15
Alana Storm's user avatar

1 Answer1

2

Unfortunately this rule is not yet there in ESLint, but there's a PR open for thisAdd rule to enforce default import naming ineslint-plugin-import

If you need it very badly you could add the rule manually into your project as a custom rule.

answeredJun 5, 2020 at 5:56
hendrixchord's user avatar
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.