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

Disallow duplicate require #2925

Open
edi9999 opened this issue Nov 18, 2023 · 7 comments · May be fixed by #2931
Open

Disallow duplicate require #2925

edi9999 opened this issue Nov 18, 2023 · 7 comments · May be fixed by #2931

Comments

@edi9999
Copy link

edi9999 commented Nov 18, 2023

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 ?

@ljharb
Copy link
Member

ljharb commented Nov 18, 2023

Try adding commonjs: true?

@edi9999
Copy link
Author

edi9999 commented Nov 18, 2023

Do you mean, in my .eslintrc,

  "env": {
    "node": true,
    "commonjs": true,
    "mocha": true
  },

I've tried just that and it didn't change anything.

@edi9999
Copy link
Author

edi9999 commented Nov 18, 2023

Still the same issue

@edi9999
Copy link
Author

edi9999 commented Nov 18, 2023

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.

@ljharb
Copy link
Member

ljharb commented Nov 18, 2023

The latter is what I meant; if that doesn't work, then it seems like a good enhancement PR to make to the rule.

@edi9999
Copy link
Author

edi9999 commented Nov 22, 2023

I confirm that it doesn't work with the latter either.

@edi9999
Copy link
Author

edi9999 commented Nov 22, 2023

I'm sorry I won't have much time to work on this issue.

@Pandemic1617 Pandemic1617 linked a pull request Nov 26, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants