-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for require-pragma option (#574)
- Loading branch information
1 parent
fbb3bc9
commit 3bb0653
Showing
9 changed files
with
246 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/prettier-plugin-java/test/unit-test/require-pragma/format-pragma/_input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @format | ||
*/ | ||
public enum Enum { | ||
|
||
SOME_ENUM, ANOTHER_ENUM, LAST_ENUM; | ||
|
||
} | ||
|
||
public enum Enum { | ||
|
||
THIS_IS_GOOD("abc"), THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
|
||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
|
||
FIRST, SECOND | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
packages/prettier-plugin-java/test/unit-test/require-pragma/format-pragma/_output.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @format | ||
*/ | ||
public enum Enum { | ||
SOME_ENUM, | ||
ANOTHER_ENUM, | ||
LAST_ENUM, | ||
} | ||
|
||
public enum Enum { | ||
THIS_IS_GOOD("abc"), | ||
THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
FIRST, | ||
SECOND, | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/prettier-plugin-java/test/unit-test/require-pragma/invalid-pragma/_input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @surely this is invalid | ||
*/ | ||
public enum Enum { | ||
|
||
SOME_ENUM, ANOTHER_ENUM, LAST_ENUM; | ||
|
||
} | ||
|
||
public enum Enum { | ||
|
||
THIS_IS_GOOD("abc"), THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
|
||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
|
||
FIRST, SECOND | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
packages/prettier-plugin-java/test/unit-test/require-pragma/invalid-pragma/_output.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @surely this is invalid | ||
*/ | ||
public enum Enum { | ||
|
||
SOME_ENUM, ANOTHER_ENUM, LAST_ENUM; | ||
|
||
} | ||
|
||
public enum Enum { | ||
|
||
THIS_IS_GOOD("abc"), THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
|
||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
|
||
FIRST, SECOND | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
packages/prettier-plugin-java/test/unit-test/require-pragma/prettier-pragma/_input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
public enum Enum { | ||
|
||
SOME_ENUM, ANOTHER_ENUM, LAST_ENUM; | ||
|
||
} | ||
|
||
public enum Enum { | ||
|
||
THIS_IS_GOOD("abc"), THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
|
||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
|
||
FIRST, SECOND | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
packages/prettier-plugin-java/test/unit-test/require-pragma/prettier-pragma/_output.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
public enum Enum { | ||
SOME_ENUM, | ||
ANOTHER_ENUM, | ||
LAST_ENUM, | ||
} | ||
|
||
public enum Enum { | ||
THIS_IS_GOOD("abc"), | ||
THIS_IS_FINE("abc"); | ||
|
||
public static final String thisWillBeDeleted = "DELETED"; | ||
|
||
private final String value; | ||
|
||
public Enum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toString() { | ||
return "STRING"; | ||
} | ||
} | ||
|
||
class CLassWithEnum { | ||
|
||
public static enum VALID_THINGS { | ||
FIRST, | ||
SECOND, | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/prettier-plugin-java/test/unit-test/require-pragma/require-pragma-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as path from "path"; | ||
import { testSampleWithOptions } from "../../test-utils"; | ||
|
||
describe("prettier-java: require-pragma option", () => { | ||
[ | ||
path.resolve(__dirname, "./format-pragma"), | ||
path.resolve(__dirname, "./prettier-pragma"), | ||
path.resolve(__dirname, "./invalid-pragma") | ||
].forEach(testFolder => | ||
testSampleWithOptions({ | ||
testFolder, | ||
prettierOptions: { requirePragma: true } | ||
}) | ||
); | ||
}); |