1
1
/*
2
- * Copyright 2016-2023 DiffPlug
2
+ * Copyright 2016-2024 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
39
39
import com .diffplug .spotless .ThrowingEx ;
40
40
import com .diffplug .spotless .npm .EslintRestService .FormatOption ;
41
41
42
- import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
43
-
44
42
public class EslintFormatterStep {
45
43
46
44
private static final Logger logger = LoggerFactory .getLogger (EslintFormatterStep .class );
@@ -81,12 +79,10 @@ public static FormatterStep create(Map<String, String> devDependencies, Provisio
81
79
}
82
80
83
81
private static class State extends NpmFormatterStepStateBase implements Serializable {
82
+ private static final long serialVersionUID = 1L ;
84
83
85
- private static final long serialVersionUID = -539537027004745812L ;
86
84
private final EslintConfig origEslintConfig ;
87
-
88
- @ SuppressFBWarnings ("SE_TRANSIENT_FIELD_NOT_RESTORED" )
89
- private transient EslintConfig eslintConfigInUse ;
85
+ private EslintConfig eslintConfigInUse ;
90
86
91
87
State (String stepName , Map <String , String > devDependencies , File projectDir , File buildDir , File cacheDir , NpmPathResolver npmPathResolver , EslintConfig eslintConfig ) throws IOException {
92
88
super (stepName ,
@@ -102,15 +98,14 @@ private static class State extends NpmFormatterStepStateBase implements Serializ
102
98
projectDir ,
103
99
buildDir ,
104
100
cacheDir ,
105
- npmPathResolver ::resolveNpmExecutable ,
106
- npmPathResolver ::resolveNodeExecutable ));
101
+ npmPathResolver ));
107
102
this .origEslintConfig = requireNonNull (eslintConfig .verify ());
108
103
this .eslintConfigInUse = eslintConfig ;
109
104
}
110
105
111
106
@ Override
112
- protected void prepareNodeServerLayout () throws IOException {
113
- super .prepareNodeServerLayout ();
107
+ protected void prepareNodeServerLayout (NodeServerLayout nodeServerLayout ) throws IOException {
108
+ super .prepareNodeServerLayout (nodeServerLayout );
114
109
if (origEslintConfig .getEslintConfigPath () != null ) {
115
110
// If any config files are provided, we need to make sure they are at the same location as the node modules
116
111
// as eslint will try to resolve plugin/config names relatively to the config file location and some
@@ -126,9 +121,10 @@ protected void prepareNodeServerLayout() throws IOException {
126
121
public FormatterFunc createFormatterFunc () {
127
122
try {
128
123
logger .info ("Creating formatter function (starting server)" );
129
- ServerProcessInfo eslintRestServer = npmRunServer ();
124
+ Runtime runtime = toRuntime ();
125
+ ServerProcessInfo eslintRestServer = runtime .npmRunServer ();
130
126
EslintRestService restService = new EslintRestService (eslintRestServer .getBaseUrl ());
131
- return Closeable .ofDangerous (() -> endServer (restService , eslintRestServer ), new EslintFilePathPassingFormatterFunc (locations .projectDir (), nodeServerLayout .nodeModulesDir (), eslintConfigInUse , restService ));
127
+ return Closeable .ofDangerous (() -> endServer (restService , eslintRestServer ), new EslintFilePathPassingFormatterFunc (locations .projectDir (), runtime . nodeServerLayout () .nodeModulesDir (), eslintConfigInUse , restService ));
132
128
} catch (IOException e ) {
133
129
throw ThrowingEx .asRuntime (e );
134
130
}
0 commit comments