-
Notifications
You must be signed in to change notification settings - Fork 461
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 JVM-based JSON formatter #850
Comments
JVM-only json formatter is very welcome! If you can implement it without any third-party dependencies, then it can live in If it needs just third-party dependencies then it should live in lib-extra. spotless/lib-extra/build.gradle Lines 11 to 18 in 59173b0
If the dependencies you need cause a lot of conflicts (ala #587), then we can always pull it out into a third-party lib later on. |
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We've added an `equality` test, but it doesn't really test too much right now as there's nothing stored in the state. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We've added an `equality` test, but it doesn't really test too much right now as there's nothing stored in the state. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We've added an `equality` test, but it doesn't really test too much right now as there's nothing stored in the state. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We've added an `equality` test, but it doesn't really test too much right now as there's nothing stored in the state. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We've added an `equality` test, but it doesn't really test too much right now as there's nothing stored in the state. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We also want our consumers to be able to configure the indentation size. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We also want our consumers to be able to configure the indentation size. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We also want our consumers to be able to configure the indentation size. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We also want our consumers to be able to configure the indentation size. We're calling this a `simple` formatter as it doesn't allow much to be configured other than the indentation size in spaces. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
Currenly, if consumers of Spotless want to format their JSON files, they need to do this by adding `prettier`, which increases the dependencies a project needs. To simplify things for consumers, as documented in diffplug#850, we can provide a JVM-based JSON formatter, using `org.json`'s JSON formatting. To follow how we've done this with other formatters, we can retrieve `org.json`'s JAR at runtime, and retrieve the classes via Reflection, instead of adding this as a `lib-extra` project, with an explicit dependency. To validate this fully, we want a few straightforward JSON files to validate before/after, but we can also use [a sample Cucumber JSON report] as a much more complex example of what happens, which we've removed any `data` objects from its source, so the files are smaller. We also want our consumers to be able to configure the indentation size. We're calling this a `simple` formatter as it doesn't allow much to be configured other than the indentation size in spaces. [a sample Cucumber JSON report]: https://github.com/damianszczepanik/cucumber-reporting/raw/master/src/test/resources/json/sample.json
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
As we've created a JVM JSON formatter as part of diffplug#850, we should make it possible to use it natively in Gradle, which requires we add it as a new supported type in `SpotlessExtension`. When configured, we'll default to including any JSON files under the `src` directory, while allowing it to be overriden if requested.
It would be good to have a JVM-only version of JSON formatters, without needing to have
prettier
installed.I'd be happy to contribute this, for Gradle - would it be best to raise a PR to add this formatter, or shall I create it as a separate project?
The text was updated successfully, but these errors were encountered: