// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  repositories {
    google()
    mavenCentral()
  }
  dependencies {
    classpath("com.android.tools.build:gradle")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    classpath("com.diffplug.spotless:spotless-plugin-gradle:6.23.3")
  }
}

allprojects {
  repositories {
    mavenLocal()

    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}

subprojects { project ->
  if (project.name.startsWith("react-native")) { return; }
  if (project.projectDir.toString().contains("/node_modules/")) { return; }

  plugins.apply("com.diffplug.spotless")
  spotless {
    // note that spotless config is currently duplicated in expo-go too
    kotlin {
      target '**/*.kt'
      ktlint("1.0.1")
          .editorConfigOverride([
              "ktlint_standard_no-wildcard-imports"          : "disabled",
              "ktlint_standard_import-ordering"              : "disabled",
              "ktlint_standard_filename"                     : "disabled",
              "ktlint_standard_property-naming"              : "disabled",
              "ktlint_standard_discouraged-comment-location" : "disabled",
              "ktlint_standard_comment-wrapping"             : "disabled",
              "ktlint_standard_function-naming"              : "disabled",
              "ktlint_standard_class-naming"                 : "disabled",
              "ktlint_standard_package-name"                 : "disabled",
              "ktlint_standard_multiline-expression-wrapping": "disabled",
              "charset"                                      : "utf-8",
              "end_of_line"                                  : "lf",
              "indent_size"                                  : "2",
              "continuation_indent_size"                     : "2",
              "indent_style"                                 : "space",
              "insert_final_newline"                         : "true",
              "tab_width"                                    : "2",
              "trim_trailing_whitespace"                     : "true",
              "ij_kotlin_allow_trailing_comma_on_call_site"  : "false",
              "ij_kotlin_allow_trailing_comma"               : "false"
          ])
      trimTrailingWhitespace()
      indentWithSpaces()
      endWithNewline()
    }
  }
}

apply plugin: "expo-root-project"
apply plugin: "com.facebook.react.rootproject"
