eslint-plugin-import
eslint-plugin-import copied to clipboard
Disallow duplicate require
I have following code :
const { addCellToRow } = require("./cell-utils.js");
const { setCellValue, findCell, createCell } = require("./cell-utils.js");
Both require are using the same path, and should thus be grouped.
I've tried to enable this in my .eslintrc :
"import/no-duplicates": ["error", {"prefer-inline": true}],
But it didn't have any effect.
Are there any rules that can catch this ?
Try adding commonjs: true?
Do you mean, in my .eslintrc,
"env": {
"node": true,
"commonjs": true,
"mocha": true
},
I've tried just that and it didn't change anything.
Still the same issue
I've also tried : "import/no-unresolved": [2, {commonjs: true, amd: true}],,
and also :
"import/no-duplicates": [
"error",
{ "prefer-inline": true, "commonjs": true }
],
But both didn't work.
The latter is what I meant; if that doesn't work, then it seems like a good enhancement PR to make to the rule.
I confirm that it doesn't work with the latter either.
I'm sorry I won't have much time to work on this issue.
Doesn't that overlap with ESLint's existing no-duplicate-imports rule?
Yes, by design - that rule can't take advantage of custom resolvers.