Adjusting code templates used for inspections

I would like to figure out how to adjust some of the templates used while actioning on inspections. An example of the issue for the case of ES6/Typescript:

  • I write a variable in my code that is not yet imported
  • IntelliJ recognizes the variable is not available and offers to 'Add import statement' (rule: Unresolved JavaScript variable)
  • IntelliJ correctly creates the following statement at the top of my document: import {APP_BASE_HREF} from "@angular/common";
  • TSLint now flags one error: " should be ' (quotemark)
  • Angular style checks also mentions that the import variable should have spaces: { APP_BASE_HREF }

What I would like to do is to adjust the template "import {<VARIABLE>} from "<PACKAGE>";" to "import { <VARIABLE> } from '<PACKAGE>';" inside my project to comply with these rules. Is there any location I can find and adjust these? I have no luck looking in Editor>File and Code Templates or Editor>Live Templates.

Best regards,

0
3 comments

choose "Single quote" in Preferences | Editor | Code Style | TypeScript, Other/Generated Code/Quote Marks and try enabling Preferences | Editor | Code Style | TypeScript, Spaces / Within / ES6 import/export braces

1
Avatar
Permanently deleted user

Thank you very much, that solved my issue!

Looking forward it would be an interesting feature to have code style linked up with the linting definitions.

0

Already possible with JSCS (https://blog.jetbrains.com/webstorm/2015/08/maintaining-consistent-code-style/), TSLint (https://blog.jetbrains.com/webstorm/2017/01/webstorm-2017-1-eap-171-2455/) and ESLint (https://blog.jetbrains.com/webstorm/2016/09/webstorm-2016-3-eap-163-3983/) - when these linters are used, you can auto-fix formatting issues by running the corresponding actions.

 

Code Style import from ESLint is not yet supported - https://youtrack.jetbrains.com/issue/WEB-19350

0

Please sign in to leave a comment.