Skip to content

Commit 2ab6f22

Browse files
Nivaldo Bondançafacebook-github-bot
authored andcommitted
Codemod format for trailing commas incoming change [5/n] (#53260)
Summary: Pull Request resolved: #53260 X-link: react/yoga#1847 Adding trailing commas. Reviewed By: cortinico Differential Revision: D80174965 fbshipit-source-id: 5438fa9ebce13525b1286dd30704138ef99703cb
1 parent 8a2e7ef commit 2ab6f22

398 files changed

Lines changed: 3665 additions & 1735 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

Lines changed: 83 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class ReactPlugin : Plugin<Project> {
4949
val rootExtension =
5050
project.rootProject.extensions.findByType(PrivateReactExtension::class.java)
5151
?: project.rootProject.extensions.create(
52-
"privateReact", PrivateReactExtension::class.java, project)
52+
"privateReact",
53+
PrivateReactExtension::class.java,
54+
project,
55+
)
5356

5457
// App Only Configuration
5558
project.pluginManager.withPlugin("com.android.application") {
@@ -131,7 +134,7 @@ class ReactPlugin : Plugin<Project> {
131134
project: Project,
132135
localExtension: ReactExtension,
133136
rootExtension: PrivateReactExtension,
134-
isLibrary: Boolean
137+
isLibrary: Boolean,
135138
) {
136139
// First, we set up the output dir for the codegen.
137140
val generatedSrcDir: Provider<Directory> =
@@ -149,70 +152,71 @@ class ReactPlugin : Plugin<Project> {
149152
// We create the task to produce schema from JS files.
150153
val generateCodegenSchemaTask =
151154
project.tasks.register(
152-
"generateCodegenSchemaFromJavaScript", GenerateCodegenSchemaTask::class.java) { it ->
153-
it.nodeExecutableAndArgs.set(rootExtension.nodeExecutableAndArgs)
154-
it.codegenDir.set(rootExtension.codegenDir)
155-
it.generatedSrcDir.set(generatedSrcDir)
156-
it.nodeWorkingDir.set(project.layout.projectDirectory.asFile.absolutePath)
157-
158-
// We're reading the package.json at configuration time to properly feed
159-
// the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the
160-
// parsePackageJson should be invoked inside this lambda.
161-
val packageJson = findPackageJsonFile(project, rootExtension.root)
162-
val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
163-
164-
val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir
165-
val includesGeneratedCode =
166-
parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
167-
if (jsSrcsDirInPackageJson != null) {
168-
it.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson))
169-
} else {
170-
it.jsRootDir.set(localExtension.jsRootDir)
171-
}
172-
it.jsInputFiles.set(
173-
project.fileTree(it.jsRootDir) { tree ->
174-
tree.include("**/*.js")
175-
tree.include("**/*.jsx")
176-
tree.include("**/*.ts")
177-
tree.include("**/*.tsx")
178-
179-
tree.exclude("node_modules/**/*")
180-
tree.exclude("**/*.d.ts")
181-
// We want to exclude the build directory, to don't pick them up for execution
182-
// avoidance.
183-
tree.exclude("**/build/**/*")
184-
})
185-
186-
val needsCodegenFromPackageJson =
187-
project.needsCodegenFromPackageJson(rootExtension.root)
188-
it.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
189-
}
155+
"generateCodegenSchemaFromJavaScript",
156+
GenerateCodegenSchemaTask::class.java,
157+
) { it ->
158+
it.nodeExecutableAndArgs.set(rootExtension.nodeExecutableAndArgs)
159+
it.codegenDir.set(rootExtension.codegenDir)
160+
it.generatedSrcDir.set(generatedSrcDir)
161+
it.nodeWorkingDir.set(project.layout.projectDirectory.asFile.absolutePath)
162+
163+
// We're reading the package.json at configuration time to properly feed
164+
// the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the
165+
// parsePackageJson should be invoked inside this lambda.
166+
val packageJson = findPackageJsonFile(project, rootExtension.root)
167+
val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
168+
169+
val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir
170+
val includesGeneratedCode =
171+
parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
172+
if (jsSrcsDirInPackageJson != null) {
173+
it.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson))
174+
} else {
175+
it.jsRootDir.set(localExtension.jsRootDir)
176+
}
177+
it.jsInputFiles.set(
178+
project.fileTree(it.jsRootDir) { tree ->
179+
tree.include("**/*.js")
180+
tree.include("**/*.jsx")
181+
tree.include("**/*.ts")
182+
tree.include("**/*.tsx")
183+
184+
tree.exclude("node_modules/**/*")
185+
tree.exclude("**/*.d.ts")
186+
// We want to exclude the build directory, to don't pick them up for execution
187+
// avoidance.
188+
tree.exclude("**/build/**/*")
189+
})
190+
191+
val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root)
192+
it.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
193+
}
190194

191195
// We create the task to generate Java code from schema.
192196
val generateCodegenArtifactsTask =
193197
project.tasks.register(
194-
"generateCodegenArtifactsFromSchema", GenerateCodegenArtifactsTask::class.java) { task
195-
->
196-
task.dependsOn(generateCodegenSchemaTask)
197-
task.reactNativeDir.set(rootExtension.reactNativeDir)
198-
task.nodeExecutableAndArgs.set(rootExtension.nodeExecutableAndArgs)
199-
task.generatedSrcDir.set(generatedSrcDir)
200-
task.packageJsonFile.set(findPackageJsonFile(project, rootExtension.root))
201-
task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName)
202-
task.libraryName.set(localExtension.libraryName)
203-
task.nodeWorkingDir.set(project.layout.projectDirectory.asFile.absolutePath)
204-
205-
// Please note that appNeedsCodegen is triggering a read of the package.json at
206-
// configuration time as we need to feed the onlyIf condition of this task.
207-
// Therefore, the appNeedsCodegen needs to be invoked inside this lambda.
208-
val needsCodegenFromPackageJson =
209-
project.needsCodegenFromPackageJson(rootExtension.root)
210-
val packageJson = findPackageJsonFile(project, rootExtension.root)
211-
val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
212-
val includesGeneratedCode =
213-
parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
214-
task.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
215-
}
198+
"generateCodegenArtifactsFromSchema",
199+
GenerateCodegenArtifactsTask::class.java,
200+
) { task ->
201+
task.dependsOn(generateCodegenSchemaTask)
202+
task.reactNativeDir.set(rootExtension.reactNativeDir)
203+
task.nodeExecutableAndArgs.set(rootExtension.nodeExecutableAndArgs)
204+
task.generatedSrcDir.set(generatedSrcDir)
205+
task.packageJsonFile.set(findPackageJsonFile(project, rootExtension.root))
206+
task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName)
207+
task.libraryName.set(localExtension.libraryName)
208+
task.nodeWorkingDir.set(project.layout.projectDirectory.asFile.absolutePath)
209+
210+
// Please note that appNeedsCodegen is triggering a read of the package.json at
211+
// configuration time as we need to feed the onlyIf condition of this task.
212+
// Therefore, the appNeedsCodegen needs to be invoked inside this lambda.
213+
val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root)
214+
val packageJson = findPackageJsonFile(project, rootExtension.root)
215+
val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) }
216+
val includesGeneratedCode =
217+
parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false
218+
task.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
219+
}
216220

217221
// We update the android configuration to include the generated sources.
218222
// This equivalent to this DSL:
@@ -255,29 +259,34 @@ class ReactPlugin : Plugin<Project> {
255259
// dependency.
256260
val generatePackageListTask =
257261
project.tasks.register(
258-
"generateAutolinkingPackageList", GeneratePackageListTask::class.java) { task ->
259-
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
260-
task.generatedOutputDirectory.set(generatedAutolinkingJavaDir)
261-
}
262+
"generateAutolinkingPackageList",
263+
GeneratePackageListTask::class.java,
264+
) { task ->
265+
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
266+
task.generatedOutputDirectory.set(generatedAutolinkingJavaDir)
267+
}
262268

263269
// We add a task called generateAutolinkingPackageList to do not clash with the existing task
264270
// called generatePackageList. This can to be renamed once we unlink the rn <-> cli
265271
// dependency.
266272
val generateEntryPointTask =
267273
project.tasks.register(
268-
"generateReactNativeEntryPoint", GenerateEntryPointTask::class.java) { task ->
269-
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
270-
task.generatedOutputDirectory.set(generatedAutolinkingJavaDir)
271-
}
274+
"generateReactNativeEntryPoint",
275+
GenerateEntryPointTask::class.java,
276+
) { task ->
277+
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
278+
task.generatedOutputDirectory.set(generatedAutolinkingJavaDir)
279+
}
272280

273281
// We also need to generate code for C++ Autolinking
274282
val generateAutolinkingNewArchitectureFilesTask =
275283
project.tasks.register(
276284
"generateAutolinkingNewArchitectureFiles",
277-
GenerateAutolinkingNewArchitecturesFileTask::class.java) { task ->
278-
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
279-
task.generatedOutputDirectory.set(generatedAutolinkingJniDir)
280-
}
285+
GenerateAutolinkingNewArchitecturesFileTask::class.java,
286+
) { task ->
287+
task.autolinkInputFile.set(rootGeneratedAutolinkingFile)
288+
task.generatedOutputDirectory.set(generatedAutolinkingJniDir)
289+
}
281290
project.tasks
282291
.named("preBuild", Task::class.java)
283292
.dependsOn(generateAutolinkingNewArchitectureFilesTask)

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ abstract class BundleHermesCTask : DefaultTask() {
111111
val composeScriptFile = File(reactNativeDir, "scripts/compose-source-maps.js")
112112
val composeSourceMapsCommand =
113113
getComposeSourceMapsCommand(
114-
composeScriptFile, packagerSourceMap, compilerSourceMap, outputSourceMap)
114+
composeScriptFile,
115+
packagerSourceMap,
116+
compilerSourceMap,
117+
outputSourceMap,
118+
)
115119
runCommand(composeSourceMapsCommand)
116120
}
117121
}
@@ -172,7 +176,7 @@ abstract class BundleHermesCTask : DefaultTask() {
172176
internal fun getHermescCommand(
173177
hermesCommand: String,
174178
bytecodeFile: File,
175-
bundleFile: File
179+
bundleFile: File,
176180
): List<Any> {
177181
val rootFile = root.get().asFile
178182
return windowsAwareCommandLine(
@@ -183,14 +187,15 @@ abstract class BundleHermesCTask : DefaultTask() {
183187
"-out",
184188
bytecodeFile.cliPath(rootFile),
185189
bundleFile.cliPath(rootFile),
186-
*hermesFlags.get().toTypedArray())
190+
*hermesFlags.get().toTypedArray(),
191+
)
187192
}
188193

189194
internal fun getComposeSourceMapsCommand(
190195
composeScript: File,
191196
packagerSourceMap: File,
192197
compilerSourceMap: File,
193-
outputSourceMap: File
198+
outputSourceMap: File,
194199
): List<Any> {
195200
val rootFile = root.get().asFile
196201
return windowsAwareCommandLine(
@@ -199,6 +204,7 @@ abstract class BundleHermesCTask : DefaultTask() {
199204
packagerSourceMap.cliPath(rootFile),
200205
compilerSourceMap.cliPath(rootFile),
201206
"-o",
202-
outputSourceMap.cliPath(rootFile))
207+
outputSourceMap.cliPath(rootFile),
208+
)
203209
}
204210
}

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ abstract class GenerateCodegenArtifactsTask : Exec() {
8181
"--libraryName",
8282
libraryName,
8383
"--javaPackageName",
84-
codegenJavaPackageName))
84+
codegenJavaPackageName,
85+
))
8586
}
8687
}

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ abstract class GeneratePackageListTask : DefaultTask() {
6161

6262
internal fun composePackageImports(
6363
packageName: String,
64-
packages: Map<String, ModelAutolinkingDependenciesPlatformAndroidJson>
64+
packages: Map<String, ModelAutolinkingDependenciesPlatformAndroidJson>,
6565
) =
6666
packages.entries.joinToString("\n") { (name, dep) ->
6767
val packageImportPath =
@@ -73,7 +73,7 @@ abstract class GeneratePackageListTask : DefaultTask() {
7373

7474
internal fun composePackageInstance(
7575
packageName: String,
76-
packages: Map<String, ModelAutolinkingDependenciesPlatformAndroidJson>
76+
packages: Map<String, ModelAutolinkingDependenciesPlatformAndroidJson>,
7777
) =
7878
if (packages.isEmpty()) {
7979
""

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ abstract class PrepareBoostTask : DefaultTask() {
4040
"CMakeLists.txt",
4141
"boost_${boostVersion.get()}/boost/**/*.hpp",
4242
"boost/boost/**/*.hpp",
43-
"asm/**/*.S")
43+
"asm/**/*.S",
44+
)
4445
it.includeEmptyDirs = false
4546
it.into(outputDir)
4647
}

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGflagsTask.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ abstract class PrepareGflagsTask : DefaultTask() {
4646
action.include(
4747
"gflags-${gflagsVersion.get()}/src/*.h",
4848
"gflags-${gflagsVersion.get()}/src/*.cc",
49-
"CMakeLists.txt")
49+
"CMakeLists.txt",
50+
)
5051
action.filesMatching("*/src/*") { matchedFile ->
5152
matchedFile.path = "gflags/${matchedFile.name}"
5253
}
@@ -64,7 +65,8 @@ abstract class PrepareGflagsTask : DefaultTask() {
6465
.replace(
6566
Regex(
6667
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"),
67-
"1")
68+
"1",
69+
)
6870
.replace(Regex("@([A-Z0-9_]+)@"), "1")
6971
}
7072
matchedFile.path = "gflags/${matchedFile.name.removeSuffix(".in")}"

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ abstract class PrepareGlogTask : DefaultTask() {
6060
"ac_cv___attribute___noinline" to "__attribute__ ((noinline))",
6161
"ac_cv___attribute___noreturn" to "__attribute__ ((noreturn))",
6262
"ac_cv___attribute___printf_4_5" to
63-
"__attribute__((__format__ (__printf__, 4, 5)))")),
64-
ReplaceTokens::class.java)
63+
"__attribute__((__format__ (__printf__, 4, 5)))",
64+
)),
65+
ReplaceTokens::class.java,
66+
)
6567
matchedFile.path = (matchedFile.name.removeSuffix(".in"))
6668
}
6769
action.into(outputDir)
@@ -74,7 +76,8 @@ abstract class PrepareGlogTask : DefaultTask() {
7476
"logging.h",
7577
"raw_logging.h",
7678
"vlog_is_on.h",
77-
"**/src/glog/log_severity.h")
79+
"**/src/glog/log_severity.h",
80+
)
7881
action.eachFile { file -> file.path = file.name }
7982
action.includeEmptyDirs = false
8083
action.into(exportedDir)

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ data class PrefabPreprocessingEntry(
2323
) : Serializable {
2424
constructor(
2525
libraryName: String,
26-
pathToPrefixCouple: Pair<String, String>
26+
pathToPrefixCouple: Pair<String, String>,
2727
) : this(libraryName, listOf(pathToPrefixCouple))
2828
}

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,15 @@ internal object AgpConfiguratorUtils {
6666
ext.buildFeatures.buildConfig = true
6767
ext.defaultConfig.buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true")
6868
ext.defaultConfig.buildConfigField(
69-
"boolean", "IS_HERMES_ENABLED", project.isHermesEnabled.toString())
69+
"boolean",
70+
"IS_HERMES_ENABLED",
71+
project.isHermesEnabled.toString(),
72+
)
7073
ext.defaultConfig.buildConfigField(
71-
"boolean", "IS_EDGE_TO_EDGE_ENABLED", project.isEdgeToEdgeEnabled.toString())
74+
"boolean",
75+
"IS_EDGE_TO_EDGE_ENABLED",
76+
project.isEdgeToEdgeEnabled.toString(),
77+
)
7278
}
7379
}
7480
project.pluginManager.withPlugin("com.android.application", action)
@@ -95,7 +101,10 @@ internal object AgpConfiguratorUtils {
95101
.getByType(ApplicationAndroidComponentsExtension::class.java)
96102
.finalizeDsl { ext ->
97103
ext.defaultConfig.resValue(
98-
"string", "react_native_dev_server_ip", getHostIpAddress())
104+
"string",
105+
"react_native_dev_server_ip",
106+
getHostIpAddress(),
107+
)
99108
ext.defaultConfig.resValue("integer", "react_native_dev_server_port", devServerPort)
100109
}
101110
}

0 commit comments

Comments
 (0)