Skip to content
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

Adding ESLint as formatter step #1453

Merged
merged 39 commits into from
Jan 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4959227
extract base serve code
simschla Nov 28, 2022
c70bd34
upgrade express to latest
simschla Nov 28, 2022
3884e14
extract common rest code on client side
simschla Dec 3, 2022
c20d3bb
add "eslint --fix" as formatter
simschla Dec 3, 2022
4f5e4d3
eslint: add support for xo standard typescript ruleset
simschla Dec 7, 2022
9633967
eslint: add support for standard-with-typescript ruleset
simschla Dec 9, 2022
7022b7f
eslint: add unit tests, cleanup code
simschla Dec 15, 2022
a2a5502
eslint: reduce required options
simschla Dec 15, 2022
35b2b7c
eslint: remove unneeded configuration
simschla Dec 16, 2022
016dd3a
eslint: test supplying inline config
simschla Dec 16, 2022
a9f89d8
eslint: adding javascript formatting (part 1)
simschla Dec 16, 2022
4efc19b
eslint: introduce separate javascript extension
simschla Dec 18, 2022
0206246
eslint: adding tests for js
simschla Dec 20, 2022
393a4c4
eslint: bumping version numbers
simschla Dec 20, 2022
8dc740e
eslint: adapt to extended api on maven side
simschla Dec 20, 2022
cb3dd55
eslint: speedup npm install
simschla Dec 21, 2022
e12c5ef
eslint: speedup npmrc tests
simschla Dec 21, 2022
218db79
eslint: extract base properties
simschla Dec 21, 2022
31462a2
eslint: initial maven support
simschla Dec 22, 2022
dd5ae78
eslint: tests for maven integration into typescript
simschla Dec 22, 2022
7d2e5ad
eslint: adding maven javascript tests
simschla Dec 23, 2022
1d164d3
eslint: also test custom devDependencies case
simschla Dec 23, 2022
3f37053
eslint: adding readme (common and plugin-gradle)
simschla Jan 4, 2023
bb843ce
eslint: apply spotless
simschla Jan 4, 2023
508dd69
bumping default prettier version
simschla Jan 4, 2023
67a0a05
eslint: update readme for maven
simschla Jan 4, 2023
e07082a
eslint: unify naming in documentation
simschla Jan 4, 2023
2943c66
eslint: adapt to api changes in TestResource
simschla Jan 4, 2023
ce21de7
eslint: adapt PR number
simschla Jan 4, 2023
3a1d43b
eslint: add default version bump to CHANGES
simschla Jan 4, 2023
b4f76b4
eslint: adapt maven code to match documentation
simschla Jan 4, 2023
4598319
eslint: spotlessApply
simschla Jan 4, 2023
3540242
eslint: reduce log-noise, cleanup error codes
simschla Jan 5, 2023
98c023b
eslint: spotbugs fix
simschla Jan 5, 2023
9a0932e
Merge branch 'main' of https://github.com/diffplug/spotless into feat…
simschla Jan 9, 2023
d4d91cb
eslint: remove direct api support for styleguides
simschla Jan 10, 2023
7673e22
Merge branch 'main' of https://github.com/diffplug/spotless into feat…
simschla Jan 10, 2023
6577e29
eslint: fix anchor navigation
simschla Jan 10, 2023
0227e89
eslint: cleanup doc
simschla Jan 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
eslint: extract base properties
to a common base class
  • Loading branch information
simschla committed Jan 4, 2023
commit 218db79b6ff8d0a1ea8c00a83cf38e21b8a19689
Original file line number Diff line number Diff line change
@@ -23,12 +23,12 @@

import com.diffplug.spotless.FormatterStep;
import com.diffplug.spotless.maven.FormatterStepConfig;
import com.diffplug.spotless.maven.FormatterStepFactory;
import com.diffplug.spotless.maven.npm.AbstractNpmFormatterStepFactory;
import com.diffplug.spotless.npm.NpmPathResolver;
import com.diffplug.spotless.npm.PrettierConfig;
import com.diffplug.spotless.npm.PrettierFormatterStep;

public class Prettier implements FormatterStepFactory {
public class Prettier extends AbstractNpmFormatterStepFactory {

public static final String ERROR_MESSAGE_ONLY_ONE_CONFIG = "must specify exactly one prettierVersion, devDependencies or devDependencyProperties";

@@ -47,12 +47,6 @@ public class Prettier implements FormatterStepFactory {
@Parameter
private String configFile;

@Parameter
private String npmExecutable;

@Parameter
private String npmrc;

@Override
public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {

@@ -70,10 +64,6 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
this.devDependencies = dependencyPropertiesAsMap();
}

File npm = npmExecutable != null ? stepConfig.getFileLocator().locateFile(npmExecutable) : null;

File npmrcFile = npmrc != null ? stepConfig.getFileLocator().locateFile(npmrc) : null;

// process config file or inline config
File configFileHandler;
if (this.configFile != null) {
@@ -103,10 +93,10 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
}

// create the format step
File baseDir = baseDir(stepConfig);
File buildDir = buildDir(stepConfig);
PrettierConfig prettierConfig = new PrettierConfig(configFileHandler, configInline);
File buildDir = stepConfig.getFileLocator().getBuildDir();
File baseDir = stepConfig.getFileLocator().getBaseDir();
NpmPathResolver npmPathResolver = new NpmPathResolver(npm, npmrcFile, baseDir);
NpmPathResolver npmPathResolver = npmPathResolver(stepConfig);
return PrettierFormatterStep.create(devDependencies, stepConfig.getProvisioner(), baseDir, buildDir, npmPathResolver, prettierConfig);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2016-2022 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.npm;

import java.io.File;

import org.apache.maven.plugins.annotations.Parameter;

import com.diffplug.spotless.maven.FormatterStepConfig;
import com.diffplug.spotless.maven.FormatterStepFactory;
import com.diffplug.spotless.npm.NpmPathResolver;

public abstract class AbstractNpmFormatterStepFactory implements FormatterStepFactory {

@Parameter
private String npmExecutable;

@Parameter
private String npmrc;

protected File npm(FormatterStepConfig stepConfig) {
File npm = npmExecutable != null ? stepConfig.getFileLocator().locateFile(npmExecutable) : null;
return npm;
}

protected File npmrc(FormatterStepConfig stepConfig) {
File npmrc = this.npmrc != null ? stepConfig.getFileLocator().locateFile(this.npmrc) : null;
return npmrc;
}

protected File buildDir(FormatterStepConfig stepConfig) {
return stepConfig.getFileLocator().getBuildDir();
}

protected File baseDir(FormatterStepConfig stepConfig) {
return stepConfig.getFileLocator().getBaseDir();
}

protected NpmPathResolver npmPathResolver(FormatterStepConfig stepConfig) {
return new NpmPathResolver(npm(stepConfig), npmrc(stepConfig), baseDir(stepConfig));
}
}
Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@

import com.diffplug.spotless.FormatterStep;
import com.diffplug.spotless.maven.FormatterStepConfig;
import com.diffplug.spotless.maven.FormatterStepFactory;
import com.diffplug.spotless.maven.npm.AbstractNpmFormatterStepFactory;
import com.diffplug.spotless.npm.NpmPathResolver;
import com.diffplug.spotless.npm.TsConfigFileType;
import com.diffplug.spotless.npm.TsFmtFormatterStep;
import com.diffplug.spotless.npm.TypedTsFmtConfigFile;

public class Tsfmt implements FormatterStepFactory {
public class Tsfmt extends AbstractNpmFormatterStepFactory {

@Parameter
private String tslintFile;
@@ -52,12 +52,6 @@ public class Tsfmt implements FormatterStepFactory {
@Parameter
private String tslintVersion;

@Parameter
private String npmExecutable;

@Parameter
private String npmrc;

@Parameter
private Map<String, String> config;

@@ -74,10 +68,6 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
devDependencies.put("tslint", tslintVersion);
}

File npm = npmExecutable != null ? stepConfig.getFileLocator().locateFile(npmExecutable) : null;

File npmrcFile = npmrc != null ? stepConfig.getFileLocator().locateFile(npmrc) : null;

TypedTsFmtConfigFile configFile;
Map<String, Object> configInline;
// check that there is only 1 config file or inline config
@@ -119,9 +109,9 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
throw onlyOneConfig();
}

File buildDir = stepConfig.getFileLocator().getBuildDir();
File baseDir = stepConfig.getFileLocator().getBaseDir();
NpmPathResolver npmPathResolver = new NpmPathResolver(npm, npmrcFile, baseDir);
File buildDir = buildDir(stepConfig);
File baseDir = baseDir(stepConfig);
NpmPathResolver npmPathResolver = npmPathResolver(stepConfig);
return TsFmtFormatterStep.create(devDependencies, stepConfig.getProvisioner(), baseDir, buildDir, npmPathResolver, configFile, configInline);
}