Skip to content

Commit

Permalink
Merge pull request #15 from andy-viv/semicolon-option
Browse files Browse the repository at this point in the history
add semicolon config option
  • Loading branch information
NuclleaR authored Jul 18, 2018
2 parents 27ab939 + 8352289 commit 151c486
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,22 @@
"autoimport.showNotifications": {
"type": "boolean",
"default": false,
"description": "Specifies wether to show notifications from Auto Import"
"description": "Specifies whether to show notifications from Auto Import"
},
"autoimport.doubleQuotes": {
"type": "boolean",
"default": false,
"description": "Specifies wether to use double quotes"
"description": "Specifies whether to use double quotes"
},
"autoimport.semicolon": {
"type": "boolean",
"default": true,
"description": "Specifies whether to use a semicolon at the end of the line"
},
"autoimport.spaceBetweenBraces": {
"type": "boolean",
"default": true,
"description": "Specifies wether to use spaces between first and last brace"
"description": "Specifies whether to use spaces between first and last brace"
},
"autoimport.autoComplete": {
"type": "boolean",
Expand Down
5 changes: 4 additions & 1 deletion src/import-fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export class ImportFixer {

private spacesBetweenBraces;
private doubleQuotes;
private semicolon;

constructor() {
let config = vscode.workspace.getConfiguration('autoimport');

this.spacesBetweenBraces = config.get<boolean>('spaceBetweenBraces');
this.doubleQuotes = config.get<boolean>('doubleQuotes');
this.semicolon = config.get<boolean>('semicolon');
}

public fix(document: vscode.TextDocument, range: vscode.Range,
Expand Down Expand Up @@ -110,7 +112,8 @@ export class ImportFixer {
isDefault ? '' : this.spacesBetweenBraces ? ' }' : '}',
' from ',
quoteSymbol + formattedPath + quoteSymbol,
endline ? ';\r\n' : ';',
this.semicolon ? ';' : '',
endline ? '\r\n' : '',
].join('');
return importStr;
}
Expand Down

0 comments on commit 151c486

Please sign in to comment.