diff --git a/src/main/java/pl/touk/sputnik/configuration/GeneralOption.java b/src/main/java/pl/touk/sputnik/configuration/GeneralOption.java index 6ea7318f..7f81c9b5 100644 --- a/src/main/java/pl/touk/sputnik/configuration/GeneralOption.java +++ b/src/main/java/pl/touk/sputnik/configuration/GeneralOption.java @@ -71,6 +71,8 @@ public enum GeneralOption implements ConfigurationOption { ESLINT_ENABLED("eslint.enabled", "ESLint enabled", "false"), ESLINT_RCFILE("eslint.rcfile", "ESLint rcfile", null), + ESLINT_EXECUTABLE("eslint.executable", "ESLint executable", "eslint"), + ESLINT_PLUGINS_FOLDER("eslint.pluginsFolder", "ESLint plugin folder", null), PYLINT_ENABLED("pylint.enabled", "Pylint enabled", "false"), PYLINT_RCFILE("pylint.rcfile", "Pylint rcfile", null), diff --git a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintExecutor.java b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintExecutor.java index edc459c9..28654a5b 100644 --- a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintExecutor.java +++ b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintExecutor.java @@ -8,14 +8,18 @@ class ESLintExecutor { - private static final String ESLINT_EXECUTABLE = "eslint"; private static final String[] ESLINT_OUTPUT_FORMAT = {"--format", "json"}; private static final String ESLINT_RCFILE_NAME = "--config"; + private static final String ESLINT_RESOLVE_PLUGINS_RELATIVE_TO = "--resolve-plugins-relative-to"; private final String eslintRcFile; + private final String eslintExecutable; + private final String pluginsFolder; - ESLintExecutor(String eslintRcFile) { + ESLintExecutor(String eslintRcFile, String eslintExecutable, String pluginsFolder) { this.eslintRcFile = eslintRcFile; + this.eslintExecutable = eslintExecutable; + this.pluginsFolder = pluginsFolder; } String runOnFile(String filePath) { @@ -23,8 +27,11 @@ String runOnFile(String filePath) { } private String[] buildParams(String filePath) { - List args = Lists.newArrayList(ESLINT_EXECUTABLE); + List args = Lists.newArrayList(eslintExecutable); args.addAll(Arrays.asList(ESLINT_OUTPUT_FORMAT)); + if (pluginsFolder != null) { + args.addAll(Arrays.asList(ESLINT_RESOLVE_PLUGINS_RELATIVE_TO, pluginsFolder)); + } if (eslintRcFile != null) { args.addAll(Arrays.asList(ESLINT_RCFILE_NAME, eslintRcFile)); } diff --git a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintProcessor.java b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintProcessor.java index 3ad7a5e9..947d2d7b 100644 --- a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintProcessor.java +++ b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintProcessor.java @@ -17,7 +17,9 @@ class ESLintProcessor extends ProcessorRunningExternalProcess { private final ESLintExecutor executor; ESLintProcessor(Configuration configuration) { - executor = new ESLintExecutor(configuration.getProperty(GeneralOption.ESLINT_RCFILE)); + executor = new ESLintExecutor(configuration.getProperty(GeneralOption.ESLINT_RCFILE), + configuration.getProperty(GeneralOption.ESLINT_EXECUTABLE), + configuration.getProperty(GeneralOption.ESLINT_PLUGINS_FOLDER)); } @Override diff --git a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintResultParser.java b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintResultParser.java index bb47ce64..50ef272b 100644 --- a/src/main/java/pl/touk/sputnik/processor/eslint/ESLintResultParser.java +++ b/src/main/java/pl/touk/sputnik/processor/eslint/ESLintResultParser.java @@ -1,6 +1,7 @@ package pl.touk.sputnik.processor.eslint; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import pl.touk.sputnik.processor.eslint.json.FileViolations; import pl.touk.sputnik.processor.eslint.json.Message; @@ -14,7 +15,7 @@ class ESLintResultParser implements ExternalProcessResultParser { - private final ObjectMapper objectMapper = new ObjectMapper(); + private final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @Override public List parse(String output) {