// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details #pragma once #include "Luau/DenseHash.h" #include "Luau/LinterConfig.h" #include "Luau/ParseOptions.h" #include #include #include #include #include namespace Luau { using ModuleName = std::string; constexpr const char* kConfigName = ".luaurc"; struct Config { Config(); Config(const Config& other) noexcept; Config& operator=(const Config& other) noexcept; Config(Config&& other) noexcept = default; Config& operator=(Config&& other) noexcept = default; Mode mode = Mode::Nonstrict; ParseOptions parseOptions; LintOptions enabledLint; LintOptions fatalLint; bool lintErrors = false; bool typeErrors = true; std::vector globals; struct AliasInfo { std::string value; std::string_view configLocation; }; DenseHashMap aliases{""}; void setAlias(std::string alias, const std::string& value, const std::string configLocation); private: // Prevents making unnecessary copies of the same config location string. DenseHashMap> configLocationCache{""}; }; struct ConfigResolver { virtual ~ConfigResolver() {} virtual const Config& getConfig(const ModuleName& name) const = 0; }; struct NullConfigResolver : ConfigResolver { Config defaultConfig; virtual const Config& getConfig(const ModuleName& name) const override; }; std::optional parseModeString(Mode& mode, const std::string& modeString, bool compat = false); std::optional parseLintRuleString( LintOptions& enabledLints, LintOptions& fatalLints, const std::string& warningName, const std::string& value, bool compat = false ); bool isValidAlias(const std::string& alias); struct ConfigOptions { bool compat = false; struct AliasOptions { std::string configLocation; bool overwriteAliases; }; std::optional aliasOptions = std::nullopt; }; std::optional parseConfig(const std::string& contents, Config& config, const ConfigOptions& options = ConfigOptions{}); } // namespace Luau