2021-10-30 04:25:12 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
2023-08-11 22:42:37 +08:00
|
|
|
#include "Luau/LinterConfig.h"
|
2021-10-30 04:25:12 +08:00
|
|
|
#include "Luau/ParseOptions.h"
|
|
|
|
|
|
|
|
#include <optional>
|
2023-12-02 15:46:57 +08:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
2021-10-30 04:25:12 +08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
|
|
|
using ModuleName = std::string;
|
|
|
|
|
|
|
|
constexpr const char* kConfigName = ".luaurc";
|
|
|
|
|
|
|
|
struct Config
|
|
|
|
{
|
2022-09-30 06:23:10 +08:00
|
|
|
Config();
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2023-07-28 23:13:53 +08:00
|
|
|
Mode mode = Mode::Nonstrict;
|
2021-10-30 04:25:12 +08:00
|
|
|
|
|
|
|
ParseOptions parseOptions;
|
|
|
|
|
|
|
|
LintOptions enabledLint;
|
|
|
|
LintOptions fatalLint;
|
|
|
|
|
|
|
|
bool lintErrors = false;
|
|
|
|
bool typeErrors = true;
|
|
|
|
|
|
|
|
std::vector<std::string> globals;
|
2023-12-02 15:46:57 +08:00
|
|
|
|
|
|
|
std::vector<std::string> paths;
|
|
|
|
std::unordered_map<std::string, std::string> aliases;
|
2021-10-30 04:25:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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<std::string> parseModeString(Mode& mode, const std::string& modeString, bool compat = false);
|
|
|
|
std::optional<std::string> parseLintRuleString(
|
|
|
|
LintOptions& enabledLints, LintOptions& fatalLints, const std::string& warningName, const std::string& value, bool compat = false);
|
|
|
|
|
2023-12-02 15:46:57 +08:00
|
|
|
bool isValidAlias(const std::string& alias);
|
|
|
|
|
2021-10-30 04:25:12 +08:00
|
|
|
std::optional<std::string> parseConfig(const std::string& contents, Config& config, bool compat = false);
|
|
|
|
|
|
|
|
} // namespace Luau
|