From abe3cafcfb59c69eadb6dc150c7e86e149d095fc Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 17:23:27 +0100 Subject: [PATCH 01/14] Add prettier to maven plugin --- .../spotless/maven/FormatterFactory.java | 4 + .../spotless/maven/generic/Prettier.java | 103 ++++++++++++++++++ .../spotless/maven/MavenIntegrationTest.java | 4 + .../prettier/PrettierFormatStepTest.java | 96 ++++++++++++++++ .../prettier/filetypes/html/.prettierrc.yml | 1 + .../npm/prettier/filetypes/html/html.clean | 13 +++ .../npm/prettier/filetypes/html/html.dirty | 17 +++ .../prettier/filetypes/tsx/.prettierrc.yml | 3 + .../npm/prettier/filetypes/tsx/tsx.clean | 31 ++++++ .../npm/prettier/filetypes/tsx/tsx.dirty | 28 +++++ .../npm/PrettierFormatterStepTest.java | 2 +- 11 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java create mode 100644 plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/html/.prettierrc.yml create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/html/html.clean create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/html/html.dirty create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/tsx/.prettierrc.yml create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.clean create mode 100644 testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.dirty diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java index 8796fa255c..d3ad7062ca 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java @@ -111,6 +111,10 @@ public final void addEclipseWtp(EclipseWtp eclipseWtp) { addStepFactory(eclipseWtp); } + public final void addPrettier(Prettier prettier) { + addStepFactory(prettier); + } + protected final void addStepFactory(FormatterStepFactory stepFactory) { Objects.requireNonNull(stepFactory); stepFactories.add(stepFactory); diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java new file mode 100644 index 0000000000..64bc4032de --- /dev/null +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -0,0 +1,103 @@ +/* + * Copyright 2020 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.maven.generic; + +import com.diffplug.spotless.npm.PrettierConfig; +import com.diffplug.spotless.npm.PrettierFormatterStep; +import org.apache.maven.plugins.annotations.Parameter; + +import com.diffplug.spotless.FormatterStep; +import com.diffplug.spotless.maven.FormatterStepConfig; +import com.diffplug.spotless.maven.FormatterStepFactory; + +import java.io.File; +import java.util.LinkedHashMap; +import java.util.Map; + +public class Prettier implements FormatterStepFactory { + + @Parameter + private String prettierVersion; + + @Parameter + private Map devDependencies; + + @Parameter + private Map config; + + @Parameter + private String configFile; + + @Parameter + private String npmExecutable; + + @Override + public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { + + // check if config is only setup in one way + if (this.prettierVersion != null && this.devDependencies != null) { + throw onlyOneConfig(); + } + + // set dev dependencies + if (devDependencies == null) { + if (prettierVersion == null || prettierVersion.isEmpty()) { + devDependencies = PrettierFormatterStep.defaultDevDependencies(); + } else { + devDependencies = PrettierFormatterStep.defaultDevDependenciesWithPrettier(prettierVersion); + } + } + + File npm = npmExecutable != null ? stepConfig.getFileLocator().locateLocal(npmExecutable) : null; + + // process config file or inline config + File configFileHandler; + Map configInline; + if (this.configFile != null) { + configInline = null; + configFileHandler = stepConfig.getFileLocator().locateLocal(this.configFile); + } else { + configFileHandler = null; + } + + if (config != null) { + configInline = new LinkedHashMap<>(); + // try to parse string values as integers or booleans + for (Map.Entry e : config.entrySet()) { + try { + configInline.put(e.getKey(), Integer.parseInt(e.getValue())); + } catch (NumberFormatException ignore) { + try { + configInline.put(e.getKey(), Boolean.parseBoolean(e.getValue())); + } catch (IllegalArgumentException ignore2) { + configInline.put(e.getKey(), e.getValue()); + } + } + } + } else { + configInline = null; + } + + // create the format step + PrettierConfig prettierConfig = new PrettierConfig(configFileHandler, configInline); + File buildDir = stepConfig.getFileLocator().getBuildDir(); + return PrettierFormatterStep.create(devDependencies, stepConfig.getProvisioner(), buildDir, npm, prettierConfig); + } + + private static IllegalArgumentException onlyOneConfig() { + return new IllegalArgumentException("must specify exactly one configFile or config"); + } +} diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationTest.java index 13302a41a1..4a741a37c4 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationTest.java @@ -130,6 +130,10 @@ protected void writePomWithTypescriptSteps(String... steps) throws IOException { writePom(groupWithSteps("typescript", steps)); } + protected void writePomWithPrettierSteps(String includes, String... steps) throws IOException { + writePom(formats(groupWithSteps("format", including(includes), steps))); + } + protected void writePom(String... configuration) throws IOException { writePom(null, configuration); } diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java new file mode 100644 index 0000000000..84a7ac2fdf --- /dev/null +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2020 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.maven.prettier; + +import java.io.IOException; + +import org.junit.Ignore; +import org.junit.Test; + +import com.diffplug.spotless.maven.MavenIntegrationTest; +import com.diffplug.spotless.maven.MavenRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PrettierFormatStepTest extends MavenIntegrationTest { + + private void run(String kind, String suffix) throws IOException, InterruptedException { + String configPath = ".prettierrc.yml"; + setFile(configPath).toResource("npm/prettier/filetypes/" + kind + "/" + ".prettierrc.yml"); + String path = "src/main/"+kind+"/test."+suffix; + setFile(path).toResource("npm/prettier/filetypes/" + kind + "/" + kind + ".dirty"); + mavenRunner().withArguments("spotless:apply").runNoError(); + assertFile(path).sameAsResource("npm/prettier/filetypes/" + kind + "/" + kind + ".clean"); + } + + @Test + public void prettier_typescript() throws Exception { + String suffix = "ts"; + writePomWithPrettierSteps("**/*."+suffix, + "", + " 1.19.010", + " .prettierrc.yml", + ""); + run("typescript", suffix); + } + + @Test + public void prettier_html() throws Exception { + String suffix = "html"; + writePomWithPrettierSteps("**/*."+suffix, + "", + " 1.19.0", + " .prettierrc.yml", + ""); + run("html", suffix); + } + + @Test + public void prettier_tsx() throws Exception { + String suffix = "tsx"; + writePomWithPrettierSteps("src/main/**/*."+suffix, + "src/**/*.tsx", + "", + " 1.19.0", + " .prettierrc.yml", + ""); + run("tsx", suffix); + } + + @Test + public void prettier_tsx_inline_config() throws Exception { + String suffix = "tsx"; + writePomWithPrettierSteps("src/main/**/*."+suffix, + "", + " 1.19.0", + " typescript", + ""); + run("tsx", suffix); + } + + @Test + public void unique_dependency_config() throws Exception { + writePomWithFormatSteps( + "**/*.ts", + "", + " 1.19.0", + " 1.16.0", + ""); + + MavenRunner.Result result = mavenRunner().withArguments("spotless:apply").runHasError(); + assertThat(result.output()).contains("must specify exactly one configFile or config"); + } +} diff --git a/testlib/src/main/resources/npm/prettier/filetypes/html/.prettierrc.yml b/testlib/src/main/resources/npm/prettier/filetypes/html/.prettierrc.yml new file mode 100644 index 0000000000..f1185441f8 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/html/.prettierrc.yml @@ -0,0 +1 @@ +parser: html diff --git a/testlib/src/main/resources/npm/prettier/filetypes/html/html.clean b/testlib/src/main/resources/npm/prettier/filetypes/html/html.clean new file mode 100644 index 0000000000..306b11ebb9 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/html/html.clean @@ -0,0 +1,13 @@ + + + + + Test + + + + + + + + diff --git a/testlib/src/main/resources/npm/prettier/filetypes/html/html.dirty b/testlib/src/main/resources/npm/prettier/filetypes/html/html.dirty new file mode 100644 index 0000000000..482abaadd7 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/html/html.dirty @@ -0,0 +1,17 @@ + + + + + + Test + + + + + + + + + diff --git a/testlib/src/main/resources/npm/prettier/filetypes/tsx/.prettierrc.yml b/testlib/src/main/resources/npm/prettier/filetypes/tsx/.prettierrc.yml new file mode 100644 index 0000000000..afddefc276 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/tsx/.prettierrc.yml @@ -0,0 +1,3 @@ +parser: typescript +files: "scr/**/*.tsx" +excludeFiles: "target/**" diff --git a/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.clean b/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.clean new file mode 100644 index 0000000000..9f13a1dca2 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.clean @@ -0,0 +1,31 @@ +import { Component } from "@stencil/core"; + +@Component({ + tag: "testtag", + shadow: false +}) +export class Sample { + @Prop() error: error; + + hello(word = "world") { + return "Hello, " + word; + } + + render() { + return [ +
+ + + {this.error.messages + .sort((n1, n2) => this.hello(n1)) + .map(message => ( + + ))} + +
{message}
+
+ ]; + } +} + +var s = new Sample(); diff --git a/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.dirty b/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.dirty new file mode 100644 index 0000000000..38035897f1 --- /dev/null +++ b/testlib/src/main/resources/npm/prettier/filetypes/tsx/tsx.dirty @@ -0,0 +1,28 @@ +import {Component} from "@stencil/core"; + +@Component({ +tag: 'testtag', +shadow: false +}) +export class Sample { + +@Prop()error:error; + + hello(word = "world") { + return "Hello, " + word; + } + +render(){ +return[ +
+ + { this.error.messages + .sort((n1,n2) =>this.hello(n1)).map((message) => )} + +
{message}
+]} + +} + + +var s = new Sample(); diff --git a/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java b/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java index 796f6dcc43..d24867fa53 100644 --- a/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java @@ -95,7 +95,7 @@ public static class PrettierFormattingOptionsAreWorking extends NpmFormatterStep public void runFormatTest(PrettierConfig config, String cleanFileNameSuffix) throws Exception { - final String dirtyFile = FILEDIR + "typescript.dirty"; + final String dirtyFile = FILEDIR + "tsx.dirty"; final String cleanFile = FILEDIR + "typescript." + cleanFileNameSuffix + ".clean"; final FormatterStep formatterStep = PrettierFormatterStep.create( From 78ad91416be159bf0b744ba5f0148fb6d5ca1b29 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 18:43:47 +0100 Subject: [PATCH 02/14] Add prettier to maven plugin Docs change --- README.md | 2 +- plugin-maven/CHANGES.md | 2 ++ plugin-maven/README.md | 68 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f5fd141020..fe2ecef463 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ lib('java.RemoveUnusedImportsStep') +'{{yes}} | {{yes}} extra('java.EclipseFormatterStep') +'{{yes}} | {{yes}} | {{no}} |', lib('kotlin.KtLintStep') +'{{yes}} | {{yes}} | {{no}} |', lib('markdown.FreshMarkStep') +'{{yes}} | {{no}} | {{no}} |', -lib('npm.PrettierFormatterStep') +'{{yes}} | {{no}} | {{no}} |', +lib('npm.PrettierFormatterStep') +'{{yes}} | {{yes}} | {{no}} |', lib('npm.TsFmtFormatterStep') +'{{yes}} | {{yes}} | {{no}} |', lib('scala.ScalaFmtStep') +'{{yes}} | {{yes}} | {{no}} |', lib('sql.DBeaverSQLFormatterStep') +'{{yes}} | {{no}} | {{no}} |', diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 4945b4af43..2232e85fe7 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### +* Prettier Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/TODO)) ## [1.29.0] - 2020-04-02 ### Added diff --git a/plugin-maven/README.md b/plugin-maven/README.md index d4354bff20..b1f047e6ab 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -76,6 +76,8 @@ Spotless supports the following powerful formatters: * Eclipse's [CDT](https://www.eclipse.org/cdt/) C/C++ code formatter * Eclipse's [WTP](https://www.eclipse.org/webtools/) Web-Tools code formatters * Google's [google-java-format](https://github.com/google/google-java-format) +* [Typescript Tsfmt formatter](https://github.com/vvakame/typescript-formatter) +* [Prettier formatter](https://prettier.io) * User-defined license enforcement, regex replacement, etc. Contributions are welcome, see [the contributing guide](../CONTRIBUTING.md) for development info. @@ -200,11 +202,13 @@ Use the Eclipse to define the *Code Style preferences* (see [Eclipse documentati ```xml - + src/**/*.ts + + ${basedir}/path/to/repo/tslint.json ${basedir}/path/to/repo/tsfmt.json @@ -218,6 +222,7 @@ Use the Eclipse to define the *Code Style preferences* (see [Eclipse documentati 7.2.2 3.3.3 5.12.1 + 5.12.1 @@ -243,7 +248,66 @@ Spotless will try to auto-discover an npm installation. If that is not working f Spotless uses npm to install necessary packages locally. It runs tsfmt using [J2V8](https://github.com/eclipsesource/J2V8) internally after that. - + + +## Applying [Prettier](https://prettier.io) to javascript | flow | typeScript | css | scss | less | jsx | graphQL | yaml | etc. + +Prettier is a formatter that can format [multiple file types](https://prettier.io/docs/en/language-support.html). + +To use prettier, you first have to specify the files that you want it to apply to. Then you specify prettier, and how you want to apply it. + +```xml + + + + + + src/**/typescript/**/*.ts + + + + + 1.19.0 + + 1.19.0 + + + + ${basedir}/path/to/configfile + + true + + + + + + +``` + +Supported config options are documented on [prettier.io](https://prettier.io/docs/en/options.html). +Supported config file variants are documented on [prettier.io](https://prettier.io/docs/en/configuration.html). + +*Please note:* +- The auto-discovery of config files (up the file tree) will not work when using prettier within spotless. +- Prettier's override syntax is not supported when using prettier within spotless. + +To apply prettier to more kinds of files, just add more formats. + +### Prerequisite: prettier requires a working NodeJS version + +Prettier, like tsfmt, is based on NodeJS, so to use it, a working NodeJS installation (especially npm) is required on the host running spotless. +Spotless will try to auto-discover an npm installation. If that is not working for you, it is possible to directly configure the npm binary to use. + +```xml + + ... + /usr/bin/npm +``` + +Spotless uses npm to install necessary packages locally. It runs prettier using [J2V8](https://github.com/eclipsesource/J2V8) internally after that. +Development for J2V8 for non android envs is stopped (for Windows since J2V8 4.6.0 and Unix 4.8.0), therefore Prettier is limited to <= v1.19.0 as newer versions +use ES6 feature and that needs a newer J2V8 version. ## Applying to custom sources From 9ba42f808ca85c982de44ee792665ea439a3abde Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 18:45:33 +0100 Subject: [PATCH 03/14] Add prettier to maven plugin spotless apply --- README.md | 2 +- .../spotless/maven/generic/Prettier.java | 14 ++--- .../prettier/PrettierFormatStepTest.java | 53 +++++++++---------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index fe2ecef463..b70a1ed42d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ extra('wtp.EclipseWtpFormatterStep') +'{{yes}} | {{yes}} | [`java.EclipseFormatterStep`](lib-extra/src/main/java/com/diffplug/spotless/extra/java/EclipseFormatterStep.java) | :+1: | :+1: | :white_large_square: | | [`kotlin.KtLintStep`](lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java) | :+1: | :+1: | :white_large_square: | | [`markdown.FreshMarkStep`](lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java) | :+1: | :white_large_square: | :white_large_square: | -| [`npm.PrettierFormatterStep`](lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java) | :+1: | :white_large_square: | :white_large_square: | +| [`npm.PrettierFormatterStep`](lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java) | :+1: | :+1: | :white_large_square: | | [`npm.TsFmtFormatterStep`](lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java) | :+1: | :+1: | :white_large_square: | | [`scala.ScalaFmtStep`](lib/src/main/java/com/diffplug/spotless/scala/ScalaFmtStep.java) | :+1: | :+1: | :white_large_square: | | [`sql.DBeaverSQLFormatterStep`](lib/src/main/java/com/diffplug/spotless/sql/DBeaverSQLFormatterStep.java) | :+1: | :white_large_square: | :white_large_square: | diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java index 64bc4032de..60c3119478 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 DiffPlug + * Copyright 2016 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,17 @@ */ package com.diffplug.spotless.maven.generic; -import com.diffplug.spotless.npm.PrettierConfig; -import com.diffplug.spotless.npm.PrettierFormatterStep; +import java.io.File; +import java.util.LinkedHashMap; +import java.util.Map; + import org.apache.maven.plugins.annotations.Parameter; import com.diffplug.spotless.FormatterStep; import com.diffplug.spotless.maven.FormatterStepConfig; import com.diffplug.spotless.maven.FormatterStepFactory; - -import java.io.File; -import java.util.LinkedHashMap; -import java.util.Map; +import com.diffplug.spotless.npm.PrettierConfig; +import com.diffplug.spotless.npm.PrettierFormatterStep; public class Prettier implements FormatterStepFactory { diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index 84a7ac2fdf..97a7b02140 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 DiffPlug + * Copyright 2016 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,22 +15,21 @@ */ package com.diffplug.spotless.maven.prettier; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.IOException; -import org.junit.Ignore; import org.junit.Test; import com.diffplug.spotless.maven.MavenIntegrationTest; import com.diffplug.spotless.maven.MavenRunner; -import static org.assertj.core.api.Assertions.assertThat; - public class PrettierFormatStepTest extends MavenIntegrationTest { private void run(String kind, String suffix) throws IOException, InterruptedException { String configPath = ".prettierrc.yml"; setFile(configPath).toResource("npm/prettier/filetypes/" + kind + "/" + ".prettierrc.yml"); - String path = "src/main/"+kind+"/test."+suffix; + String path = "src/main/" + kind + "/test." + suffix; setFile(path).toResource("npm/prettier/filetypes/" + kind + "/" + kind + ".dirty"); mavenRunner().withArguments("spotless:apply").runNoError(); assertFile(path).sameAsResource("npm/prettier/filetypes/" + kind + "/" + kind + ".clean"); @@ -39,7 +38,7 @@ private void run(String kind, String suffix) throws IOException, InterruptedExce @Test public void prettier_typescript() throws Exception { String suffix = "ts"; - writePomWithPrettierSteps("**/*."+suffix, + writePomWithPrettierSteps("**/*." + suffix, "", " 1.19.010", " .prettierrc.yml", @@ -50,45 +49,45 @@ public void prettier_typescript() throws Exception { @Test public void prettier_html() throws Exception { String suffix = "html"; - writePomWithPrettierSteps("**/*."+suffix, - "", - " 1.19.0", - " .prettierrc.yml", - ""); + writePomWithPrettierSteps("**/*." + suffix, + "", + " 1.19.0", + " .prettierrc.yml", + ""); run("html", suffix); } @Test public void prettier_tsx() throws Exception { String suffix = "tsx"; - writePomWithPrettierSteps("src/main/**/*."+suffix, - "src/**/*.tsx", - "", - " 1.19.0", - " .prettierrc.yml", - ""); + writePomWithPrettierSteps("src/main/**/*." + suffix, + "src/**/*.tsx", + "", + " 1.19.0", + " .prettierrc.yml", + ""); run("tsx", suffix); } @Test public void prettier_tsx_inline_config() throws Exception { String suffix = "tsx"; - writePomWithPrettierSteps("src/main/**/*."+suffix, - "", - " 1.19.0", - " typescript", - ""); + writePomWithPrettierSteps("src/main/**/*." + suffix, + "", + " 1.19.0", + " typescript", + ""); run("tsx", suffix); } @Test public void unique_dependency_config() throws Exception { writePomWithFormatSteps( - "**/*.ts", - "", - " 1.19.0", - " 1.16.0", - ""); + "**/*.ts", + "", + " 1.19.0", + " 1.16.0", + ""); MavenRunner.Result result = mavenRunner().withArguments("spotless:apply").runHasError(); assertThat(result.output()).contains("must specify exactly one configFile or config"); From f4b3e168720db2954b80aecd97a28a348be8a1f7 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 18:51:49 +0100 Subject: [PATCH 04/14] Add prettier to maven plugin spotless apply doc update --- plugin-maven/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 2232e85fe7..8489eaab7d 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -4,7 +4,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### -* Prettier Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/TODO)) +* Prettier Maven Plugin ([#555](https://github.com/diffplug/spotless/pull/555)) ## [1.29.0] - 2020-04-02 ### Added From c8b14be7b25bd3ad98f88fbef35c2f2119d5e49d Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 19:16:02 +0100 Subject: [PATCH 05/14] try to fix build in CI --- .../src/test/resources/plugin-under-test-metadata.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 plugin-gradle/src/test/resources/plugin-under-test-metadata.properties diff --git a/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties b/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties new file mode 100644 index 0000000000..923e8f769c --- /dev/null +++ b/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties @@ -0,0 +1 @@ +implementation-classpath=C\:/Users/naciron/projects/git/spotless/plugin-gradle/build/classes/java/main;C\:/Users/naciron/projects/git/spotless/plugin-gradle/build/resources/main;C\:/Users/naciron/projects/git/spotless/lib-extra/build/libs/lib-extra-1.29.0-SNAPSHOT.jar;C\:/Users/naciron/projects/git/spotless/lib/build/libs/lib-1.29.0-SNAPSHOT.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-io/1.2.0/fc9c103d454d04f7c5b78b437190ea3bd15fb72c/durian-io-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-collect/1.2.0/eee2085a0f894527ac841b05b442656115e2877c/durian-collect-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-core/1.2.0/ddf0b08f6dccae07bcb993645a7634cbe8f9b2f8/durian-core-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.eclipse.jgit/org.eclipse.jgit/5.5.0.201909110433-r/75c27f087134757a8ac335e637c117d68d41c773/org.eclipse.jgit-5.5.0.201909110433-r.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.googlecode.concurrent-trees/concurrent-trees/2.6.1/9b647240522ab67c003de9b6702ca81ac0c15efc/concurrent-trees-2.6.1.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-xml/2.4.7/864b9dc44fb0e05f329fad473e8b4df172f1b48f/groovy-xml-2.4.7.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.jcraft/jsch/0.1.55/bbd40e5aa7aa3cfad5db34965456cee738a42a50/jsch-0.1.55.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.jcraft/jzlib/1.1.1/a1551373315ffc2f96130a0e5704f74e151777ba/jzlib-1.1.1.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.googlecode.javaewah/JavaEWAH/1.1.6/94ad16d728b374d65bd897625f3fbb3da223a2b6/JavaEWAH-1.1.6.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.2/81d61b7f33ebeab314e07de0cc596f8e858d97/slf4j-api-1.7.2.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcpg-jdk15on/1.61/422656435514ab8a28752b117d5d2646660a0ace/bcpg-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcpkix-jdk15on/1.61/89bb3aa5b98b48e584eee2a7401b7682a46779b4/bcpkix-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.61/df4b474e71be02c1349c3292d98886f888d1f7/bcprov-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.4.7/10870e6511f544ce45152d0ad08d7514a00c8201/groovy-2.4.7.jar From 21485490ea74d29696007fa2c80013458c86a3a0 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 19:28:12 +0100 Subject: [PATCH 06/14] Add prettier to maven plugin spotless apply doc update --- .../maven/prettier/PrettierFormatStepTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index 97a7b02140..857d6e2324 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -40,7 +40,7 @@ public void prettier_typescript() throws Exception { String suffix = "ts"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.19.010", + " 1.16.010", " .prettierrc.yml", ""); run("typescript", suffix); @@ -51,7 +51,7 @@ public void prettier_html() throws Exception { String suffix = "html"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.19.0", + " 1.16.0", " .prettierrc.yml", ""); run("html", suffix); @@ -63,7 +63,7 @@ public void prettier_tsx() throws Exception { writePomWithPrettierSteps("src/main/**/*." + suffix, "src/**/*.tsx", "", - " 1.19.0", + " 1.16.0", " .prettierrc.yml", ""); run("tsx", suffix); @@ -74,7 +74,7 @@ public void prettier_tsx_inline_config() throws Exception { String suffix = "tsx"; writePomWithPrettierSteps("src/main/**/*." + suffix, "", - " 1.19.0", + " 1.16.0", " typescript", ""); run("tsx", suffix); @@ -85,7 +85,7 @@ public void unique_dependency_config() throws Exception { writePomWithFormatSteps( "**/*.ts", "", - " 1.19.0", + " 1.16.0", " 1.16.0", ""); From 9b1ac002bdfc23636b7e7faff97f1db561028b55 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 19:42:22 +0100 Subject: [PATCH 07/14] delete accidentally committed file --- .../src/test/resources/plugin-under-test-metadata.properties | 1 - 1 file changed, 1 deletion(-) delete mode 100644 plugin-gradle/src/test/resources/plugin-under-test-metadata.properties diff --git a/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties b/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties deleted file mode 100644 index 923e8f769c..0000000000 --- a/plugin-gradle/src/test/resources/plugin-under-test-metadata.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-classpath=C\:/Users/naciron/projects/git/spotless/plugin-gradle/build/classes/java/main;C\:/Users/naciron/projects/git/spotless/plugin-gradle/build/resources/main;C\:/Users/naciron/projects/git/spotless/lib-extra/build/libs/lib-extra-1.29.0-SNAPSHOT.jar;C\:/Users/naciron/projects/git/spotless/lib/build/libs/lib-1.29.0-SNAPSHOT.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-io/1.2.0/fc9c103d454d04f7c5b78b437190ea3bd15fb72c/durian-io-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-collect/1.2.0/eee2085a0f894527ac841b05b442656115e2877c/durian-collect-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.diffplug.durian/durian-core/1.2.0/ddf0b08f6dccae07bcb993645a7634cbe8f9b2f8/durian-core-1.2.0.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.eclipse.jgit/org.eclipse.jgit/5.5.0.201909110433-r/75c27f087134757a8ac335e637c117d68d41c773/org.eclipse.jgit-5.5.0.201909110433-r.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.googlecode.concurrent-trees/concurrent-trees/2.6.1/9b647240522ab67c003de9b6702ca81ac0c15efc/concurrent-trees-2.6.1.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-xml/2.4.7/864b9dc44fb0e05f329fad473e8b4df172f1b48f/groovy-xml-2.4.7.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.jcraft/jsch/0.1.55/bbd40e5aa7aa3cfad5db34965456cee738a42a50/jsch-0.1.55.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.jcraft/jzlib/1.1.1/a1551373315ffc2f96130a0e5704f74e151777ba/jzlib-1.1.1.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/com.googlecode.javaewah/JavaEWAH/1.1.6/94ad16d728b374d65bd897625f3fbb3da223a2b6/JavaEWAH-1.1.6.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.2/81d61b7f33ebeab314e07de0cc596f8e858d97/slf4j-api-1.7.2.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcpg-jdk15on/1.61/422656435514ab8a28752b117d5d2646660a0ace/bcpg-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcpkix-jdk15on/1.61/89bb3aa5b98b48e584eee2a7401b7682a46779b4/bcpkix-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.61/df4b474e71be02c1349c3292d98886f888d1f7/bcprov-jdk15on-1.61.jar;C\:/Users/naciron/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.4.7/10870e6511f544ce45152d0ad08d7514a00c8201/groovy-2.4.7.jar From 73db41855f89c64b4a194a67af6595387f7f607f Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 19:45:12 +0100 Subject: [PATCH 08/14] doc update --- plugin-maven/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin-maven/README.md b/plugin-maven/README.md index b1f047e6ab..dcf67130f5 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -222,7 +222,6 @@ Use the Eclipse to define the *Code Style preferences* (see [Eclipse documentati 7.2.2 3.3.3 5.12.1 - 5.12.1 From 525f3987ba16d7b8e76de1f57f6d9ebb0b71b749 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 20:05:05 +0100 Subject: [PATCH 09/14] fix --- CHANGES.md | 2 +- plugin-maven/CHANGES.md | 2 +- .../maven/prettier/PrettierFormatStepTest.java | 12 ++++++------ .../spotless/npm/PrettierFormatterStepTest.java | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 581cab23ae..ec060ad87e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -130,7 +130,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Updated default eclipse-jdt from 4.7.3a to 4.9.0 ([#316](https://github.com/diffplug/spotless/pull/316)). New version addresses enum-tab formatting bug in 4.8 ([#314](https://github.com/diffplug/spotless/issues/314)). -## [1.16.0] - 2018-10-30 +## [1.16.4] - 2018-10-30 **WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 1.20.0 (see [#358](https://github.com/diffplug/spotless/issues/358)).** * Minor support for plugin-gradle and plugin-maven CSS plugins ([#311](https://github.com/diffplug/spotless/pull/311)). diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 8489eaab7d..d0275fca12 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -109,7 +109,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Updated default eclipse-jdt from 4.7.3a to 4.9.0 ([#316](https://github.com/diffplug/spotless/pull/316)). New version addresses enum-tab formatting bug in 4.8 ([#314](https://github.com/diffplug/spotless/issues/314)). -## [1.16.0] - 2018-10-30 +## [1.16.4] - 2018-10-30 **WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 1.20.0 (see [#358](https://github.com/diffplug/spotless/issues/358)).** * Added support for Eclipse's CSS formatter from WTP ([#311](https://github.com/diffplug/spotless/pull/311)). diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index 857d6e2324..aa7f19af42 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -40,7 +40,7 @@ public void prettier_typescript() throws Exception { String suffix = "ts"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.16.010", + " 1.16.410", " .prettierrc.yml", ""); run("typescript", suffix); @@ -51,7 +51,7 @@ public void prettier_html() throws Exception { String suffix = "html"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.16.0", + " 1.16.4", " .prettierrc.yml", ""); run("html", suffix); @@ -63,7 +63,7 @@ public void prettier_tsx() throws Exception { writePomWithPrettierSteps("src/main/**/*." + suffix, "src/**/*.tsx", "", - " 1.16.0", + " 1.16.4", " .prettierrc.yml", ""); run("tsx", suffix); @@ -74,7 +74,7 @@ public void prettier_tsx_inline_config() throws Exception { String suffix = "tsx"; writePomWithPrettierSteps("src/main/**/*." + suffix, "", - " 1.16.0", + " 1.16.4", " typescript", ""); run("tsx", suffix); @@ -85,8 +85,8 @@ public void unique_dependency_config() throws Exception { writePomWithFormatSteps( "**/*.ts", "", - " 1.16.0", - " 1.16.0", + " 1.16.4", + " 1.16.4", ""); MavenRunner.Result result = mavenRunner().withArguments("spotless:apply").runHasError(); diff --git a/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java b/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java index d24867fa53..796f6dcc43 100644 --- a/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java @@ -95,7 +95,7 @@ public static class PrettierFormattingOptionsAreWorking extends NpmFormatterStep public void runFormatTest(PrettierConfig config, String cleanFileNameSuffix) throws Exception { - final String dirtyFile = FILEDIR + "tsx.dirty"; + final String dirtyFile = FILEDIR + "typescript.dirty"; final String cleanFile = FILEDIR + "typescript." + cleanFileNameSuffix + ".clean"; final FormatterStep formatterStep = PrettierFormatterStep.create( From 214a25cb0c4b8f9793799320425e4ff79a59a87f Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 21:25:39 +0100 Subject: [PATCH 10/14] fix --- .../spotless/maven/prettier/PrettierFormatStepTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index aa7f19af42..ba0d6179e7 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -40,7 +40,7 @@ public void prettier_typescript() throws Exception { String suffix = "ts"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.16.410", + " 1.16.4", " .prettierrc.yml", ""); run("typescript", suffix); From 5a2926d18d8b62f0f5515185b400aa927930ae0e Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 21:57:44 +0100 Subject: [PATCH 11/14] addressed review comments --- CHANGES.md | 2 +- plugin-maven/CHANGES.md | 4 ++-- plugin-maven/README.md | 4 ++-- .../java/com/diffplug/spotless/maven/generic/Prettier.java | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ec060ad87e..581cab23ae 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -130,7 +130,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Updated default eclipse-jdt from 4.7.3a to 4.9.0 ([#316](https://github.com/diffplug/spotless/pull/316)). New version addresses enum-tab formatting bug in 4.8 ([#314](https://github.com/diffplug/spotless/issues/314)). -## [1.16.4] - 2018-10-30 +## [1.16.0] - 2018-10-30 **WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 1.20.0 (see [#358](https://github.com/diffplug/spotless/issues/358)).** * Minor support for plugin-gradle and plugin-maven CSS plugins ([#311](https://github.com/diffplug/spotless/pull/311)). diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index d0275fca12..c623f7aed9 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -4,7 +4,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### -* Prettier Maven Plugin ([#555](https://github.com/diffplug/spotless/pull/555)) +* Support for prettier ([#555](https://github.com/diffplug/spotless/pull/555)). ## [1.29.0] - 2020-04-02 ### Added @@ -109,7 +109,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Updated default eclipse-jdt from 4.7.3a to 4.9.0 ([#316](https://github.com/diffplug/spotless/pull/316)). New version addresses enum-tab formatting bug in 4.8 ([#314](https://github.com/diffplug/spotless/issues/314)). -## [1.16.4] - 2018-10-30 +## [1.16.0] - 2018-10-30 **WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 1.20.0 (see [#358](https://github.com/diffplug/spotless/issues/358)).** * Added support for Eclipse's CSS formatter from WTP ([#311](https://github.com/diffplug/spotless/pull/311)). diff --git a/plugin-maven/README.md b/plugin-maven/README.md index dcf67130f5..0f0eb30886 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -265,7 +265,7 @@ To use prettier, you first have to specify the files that you want it to apply t - 1.19.0 @@ -300,8 +300,8 @@ Spotless will try to auto-discover an npm installation. If that is not working f ```xml - ... /usr/bin/npm + ... ``` Spotless uses npm to install necessary packages locally. It runs prettier using [J2V8](https://github.com/eclipsesource/J2V8) internally after that. diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java index 60c3119478..a82fcb8b83 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -65,14 +65,13 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { // process config file or inline config File configFileHandler; - Map configInline; if (this.configFile != null) { - configInline = null; configFileHandler = stepConfig.getFileLocator().locateLocal(this.configFile); } else { configFileHandler = null; } + Map configInline; if (config != null) { configInline = new LinkedHashMap<>(); // try to parse string values as integers or booleans From 7d59454495b6f69ec5dde972f8499398cdaf156c Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 22:01:02 +0100 Subject: [PATCH 12/14] re-add deleted line in doc --- plugin-maven/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin-maven/README.md b/plugin-maven/README.md index 0f0eb30886..5e455e4fb3 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -308,6 +308,8 @@ Spotless uses npm to install necessary packages locally. It runs prettier using Development for J2V8 for non android envs is stopped (for Windows since J2V8 4.6.0 and Unix 4.8.0), therefore Prettier is limited to <= v1.19.0 as newer versions use ES6 feature and that needs a newer J2V8 version. + + ## Applying to custom sources By default, no Ant-Style include patterns are defined. Each element under `` is a step, and they will be applied in the order specified. Every step is optional, and they will be applied in the order specified. It is possible to define multiple custom formats. From 550532d89229cfdf9b2d47dea025ce37a441c0a2 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 22:04:01 +0100 Subject: [PATCH 13/14] update copyright date in new files --- .../main/java/com/diffplug/spotless/maven/generic/Prettier.java | 2 +- .../spotless/maven/prettier/PrettierFormatStepTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java index a82fcb8b83..87f8564a5d 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index ba0d6179e7..cc61d93bce 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From ef591ef14f183383a761ba66120e6f5d6f79b3a9 Mon Sep 17 00:00:00 2001 From: oliver-szymanski Date: Thu, 9 Apr 2020 22:15:22 +0100 Subject: [PATCH 14/14] spotless apply --- .../java/com/diffplug/spotless/maven/generic/Prettier.java | 2 +- .../spotless/maven/prettier/PrettierFormatStepTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java index 87f8564a5d..a82fcb8b83 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 DiffPlug + * Copyright 2016 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java index cc61d93bce..4db0ed8ead 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 DiffPlug + * Copyright 2016 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public void prettier_typescript() throws Exception { String suffix = "ts"; writePomWithPrettierSteps("**/*." + suffix, "", - " 1.16.4", + " 1.16.4", " .prettierrc.yml", ""); run("typescript", suffix);