Skip to content

Commit be2150c

Browse files
committed
Fix prettier bug StringIndexOutOfBoundsException on empty files (noted in #751).
1 parent 49af781 commit be2150c

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
2222
* fix typo in javadoc comment for SQL\_FORMATTER\_INDENT\_TYPE ([#753](https://github.com/diffplug/spotless/pull/753))
2323
### Fixed
2424
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
25+
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
2526

2627
## [2.10.2] - 2020-11-16
2728
### Fixed

lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 DiffPlug
2+
* Copyright 2016-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public PrettierFilePathPassingFormatterFunc(String prettierConfigOptions, Pretti
113113

114114
@Override
115115
public String applyWithFile(String unix, File file) throws Exception {
116-
FormattedPrinter.SYSOUT.print("formatting String '" + unix.substring(0, Math.min(50, unix.length() - 1)) + "[...]' in file '" + file + "'");
116+
FormattedPrinter.SYSOUT.print("formatting String '" + unix.substring(0, Math.min(50, unix.length())) + "[...]' in file '" + file + "'");
117117

118118
final String prettierConfigOptionsWithFilepath = assertFilepathInConfigOptions(file);
119119
return restService.format(unix, prettierConfigOptionsWithFilepath);

plugin-gradle/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1313
### Fixed
1414
* `ratchetFrom` now works with git-submodule ([#746](https://github.com/diffplug/spotless/issues/746))
1515
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
16+
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
1617

1718
## [5.8.2] - 2020-11-16
1819
### Fixed

plugin-maven/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1515
* `ratchetFrom` now works with git-submodule ([#746](https://github.com/diffplug/spotless/issues/746))
1616
* Fix broken test for spotlessFiles parameter on windows ([#737](https://github.com/diffplug/spotless/pull/737))
1717
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
18+
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
1819

1920
## [2.6.1] - 2020-11-16
2021
### Fixed

0 commit comments

Comments
 (0)