Hey, is there any way to enable the import/named rule for module.exports?
Eg:
//lib.js
const toExport = true
module.exports = {
toExport,
}
//user.js
const {toEpxort} = require('./lib') // here I want it to throw a lint error
console.log(toEpxort)
It should, i'd expect.
I'd definitely love that, as we haven't migrated backend code to ES6 imports yet. Looks like it doesn't work right now. Tried with this setting:
"import/named": [2, { "commonjs": true }],
Should a case like this be ignored?
if(foo === bar) {
module.exports.foo = bar;
}
I assume we should only check the top-level module.exports/exports.
And also stranger cases like this:
Object.assign(module.exports, {
foo: 'bar'
});
I鈥檓 not worried about the stranger cases. Code that does that should be refactored to use a single static module.exports assignment.
Any idea when this will get merged in?
Sorry, I was referring to the open PR (#1222).
ahhh, i didn't remember there was one :-) I've got it on my list to rereview.
Actually #1226 (commonjs exports) is the relevant one for this issue.
Is there anything I can help with this feature? I want to put this rule in place on my projects and in my option this feature suits really well eslint-plugin-import project
Most helpful comment
Is there anything I can help with this feature? I want to put this rule in place on my projects and in my option this feature suits really well
eslint-plugin-importproject