javascriptintellij-ideastructural-searchintellij-inspections

Custom inspection for double quotes


Our code standard requires that all strings in javascript code would have single quotes instead of double quotes. Unfortunately, IntelliJ Idea doesn't have such inspection by default. I've tried to search and follow the official guideline, but it's not very clear how to do that. I've checke also several examples on Structural Search like

class $Class$ { 
  $FieldType$ $Field$ = $Init$;
}

but I can't understand how to check for double quotes.

How can I create custom inspection for IntelliJ Idea, so that double quoted strings would give me a warning?


Solution

  • Use a simple Structural Search pattern like this:

    $v$
    

    And be sure to set the file type to "JavaScript". Click the Edit Variables... button and set the Text/regexp to ".*"(including the quotes).

    The Structural Search dialog with the decribed pattern

    And that's it. This will find all JavaScript expressions with a text that starts and ends with a double quote.