Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add semicolon config option #15

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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