eslint-plugin-n: 16.6.2: can `n/no-missing-require` allow resolvePaths ['./'] for relative imports?

Environment

Node version: 16.20.2 npm version: 8 ESLint version: 8.57 eslint-plugin-n version: 16.6.2 Operating System: Linux

What rule do you want to report?

n/no-missing-require

Link to Minimal Reproducible Example

What did you expect to happen?

const config = require('config'); is getting flagged for n/no-missing-require, even though config/ module directory is living next to the source file.

(I’ll try following up with a stackblitz example if this is unclear.)

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Am I missing something obvious for why below doesn’t help

  rules: {
    'n/no-missing-require': ['error', {
      'resolvePaths': ['./'],
    }],
  },

I’m not against refactoring everything to explicit require('./config'), but would like to allow sibling requires until we get it done. Is this possible?

PS not a “bug” I think, but Discussions isn’t enabled on this repo.

About this issue

  • Original URL
  • State: open
  • Created 3 months ago
  • Comments: 16

Most upvoted comments

just a reminder: you can use tsconfig.json + "allowJs": true. 😃