0

IntelliJ show the squiggly red underline under require paths (node.js) that it can't find. In my case, I have a file that is copied to a particular place on installation. Their location in the source has nothing to do with their location in the installation. Its especially annoying because intelij shows that red underline for all folders in its file browser.

var x = require('./some/invalid/path')

I like that it has this check, but I want to disable it for this file since it doesn't make sense for that case. How can I do this, ideally in intelliJ 12?

B T
  • 57,525
  • 34
  • 189
  • 207

2 Answers2

0

That's how you suppress an inspection for a class, method or statement:

Place your cursor inside the warning statement, press Alt + Enter, choose the entry that describes your warning, and from the sub-menu select Suppress for class or statement.

You will find more info on the IDEA webhelp.

Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • Hmm, good idea, but the menu that comes up doesn't have an option for "Suppress for statement". Maybe this is only in a newer version of intellij? – B T Mar 24 '15 at 17:06
  • This should be available in 12.0: https://www.jetbrains.com/idea/help/suppressing-inspections.html – Darek Kay Mar 24 '15 at 17:17
  • Hmmm, it is indeed available for other types of errors, but not for the one its giving me. Strange.. – B T Mar 24 '15 at 17:19
0

I found a dumb way to do it - make the require path an expression rather than a simple string literal like this:

var x = require('./some/invalid/path'+'')

I guess it confounds intellij enough that it just says "screw it its probably fine".

B T
  • 57,525
  • 34
  • 189
  • 207