Skip to content

Commit 54a5dcb

Browse files
committed
Ignore absent EditorConfig settings
1 parent 2a1ae88 commit 54a5dcb

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/resolve-config.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@ const syncNoCache = cosmiconfig("prettier", { cache: false, sync: true });
1212
function editorConfigToPrettier(filePath) {
1313
const editorConfig = editorconfig.parseSync(filePath);
1414
const result = {};
15-
result.useTabs = editorConfig.indent_style === "tab";
16-
result.tabWidth =
17-
editorConfig.indent_size || editorConfig.tab_width || result.tabWidth;
18-
result.printWidth = editorConfig.max_line_length || result.printWidth;
15+
16+
if (editorConfig.indent_style) {
17+
result.useTabs = editorConfig.indent_style === "tab";
18+
}
19+
20+
const tabWidth = editorConfig.indent_size || editorConfig.tab_width;
21+
if (tabWidth) {
22+
result.tabWidth = tabWidth;
23+
}
24+
25+
if (editorConfig.max_line_length) {
26+
result.printWidth = editorConfig.max_line_length;
27+
}
28+
1929
return result;
2030
}
2131

0 commit comments

Comments
 (0)