This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit fa221ac37b83befbd9a9361b1bb20a4d5bbdb3c5 Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Mon Sep 26 09:37:37 2022 -0700 linter: aslint-config.xml detection --- .../main/java/org/apache/royale/linter/LINTER.java | 6 +---- .../apache/royale/linter/config/Configurator.java | 31 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/linter/src/main/java/org/apache/royale/linter/LINTER.java b/linter/src/main/java/org/apache/royale/linter/LINTER.java index 7ed58350b..c60aed272 100644 --- a/linter/src/main/java/org/apache/royale/linter/LINTER.java +++ b/linter/src/main/java/org/apache/royale/linter/LINTER.java @@ -214,10 +214,6 @@ public class LINTER { private boolean configure(String[] args, ProblemQuery problems) { try { - if (args.length == 0) { - System.out.println(getStartMessage()); - return false; - } Configurator configurator = new Configurator(); ConfigurationPathResolver resolver = new ConfigurationPathResolver(System.getProperty("user.dir")); configurator.setConfigurationPathResolver(resolver); @@ -234,7 +230,7 @@ public class LINTER { // // Print help if "-help" is present. final List<ConfigurationValue> helpVar = configBuffer.getVar("help"); - if (helpVar != null || args.length == 0) { + if (helpVar != null || (args.length == 0 && configuration.getFiles().size() == 0)) { processHelp(helpVar); return false; } diff --git a/linter/src/main/java/org/apache/royale/linter/config/Configurator.java b/linter/src/main/java/org/apache/royale/linter/config/Configurator.java index 3c63eade4..2397928c3 100644 --- a/linter/src/main/java/org/apache/royale/linter/config/Configurator.java +++ b/linter/src/main/java/org/apache/royale/linter/config/Configurator.java @@ -359,6 +359,9 @@ public class Configurator implements Cloneable if (!loadConfig()) success = false; + if (!loadLocalConfig()) + success = false; + // The command line needs to take precedence over all defaults and config files. // By simply re-merging the command line back on top, // we will get the behavior we want. @@ -444,6 +447,34 @@ public class Configurator implements Cloneable return success; } + /** + * Load project specific configuration. The configuration XML file is at the + * project root with naming convention of aslint-config.xml. + * + * @return true if successful, false otherwise. + */ + protected boolean loadLocalConfig() + { + boolean success = true; + + String project = "aslint-config.xml"; + File projectFile = configurationPathResolver.resolve(project); + if (projectFile.exists()) + { + if (!loadConfigFromFile( + cfgbuf, + projectFile, + new File(project).getParent(), + "royale-config", + false)) + { + success = false; + } + } + + return success; + } + /** * Load a configuration from file. {@code FileConfigurator.load()} is * wrapped in this method because we want to print a message after loading