Skip to content

Commit 02c23ab

Browse files
javachefacebook-github-bot
authored andcommitted
Exclude generated files from repository formatting (#58645)
Summary: Prevent repository-wide formatting commands from rewriting internal-only sources and generated renderer implementations. Changelog: [Internal] Differential Revision: D121200839
1 parent 361bc24 commit 02c23ab

6 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎.clang-format-ignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**/Pods/**
22
**/build/**
3+
**/metainternal/**
34
**/node_modules/**
45
packages/react-native/React/I18n/FBXXHashUtils.h
56
packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/**

‎.prettierignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# Ignore Pods
22
**/Pods
3+
**/metainternal/**
34

45
# Ignore hermes as it is downloaded from the react_native_pods
56
**/sdks/hermes
67
**/sdks/downloads
78

9+
flow-typed/npm/**
810
packages/*/dist
911
vendor
1012
packages/**/types_generated/
13+
packages/react-native/ReactNativeApi.d.ts
14+
packages/react-native/Libraries/Renderer/**
15+
packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
16+
packages/react-native-babel-preset/src/__tests__/__fixtures__/output/**
17+
private/eslint-plugin-monorepo/rules/sort-imports.js
1118

1219
packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeEnumTurboModule.js

‎scripts/format-java.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const IGNORE = [
2525
'**/Pods/**',
2626
'**/build/**',
2727
'**/com/facebook/yoga/**',
28+
'**/metainternal/**',
2829
'**/node_modules/**',
2930
];
3031

‎scripts/format-kotlin.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const IGNORE = [
2727
'**/com/facebook/yoga/**',
2828
'**/hermes-engine/**',
2929
'**/internal/featureflags/**',
30+
'**/metainternal/**',
3031
'**/node_modules/**',
3132
'**/systeminfo/ReactNativeVersion.kt',
3233
];

‎scripts/format-python.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const path = require('node:path');
1717

1818
const REPO_ROOT = path.resolve(__dirname, '..');
1919
const RUFF_VERSION = '0.14.0';
20+
// Passed to Ruff as `--config <inline TOML>`, which overrides only this single
21+
// setting and leaves any discovered configuration files in place. The
22+
// `--exclude` flag cannot be used instead: it replaces Ruff's default
23+
// exclusions (`node_modules`, `build`, …) rather than adding to them.
24+
const RUFF_CONFIG = 'extend-exclude = ["**/metainternal/**"]';
2025
const RUFF_ROOT = path.join(
2126
REPO_ROOT,
2227
'node_modules',
@@ -99,7 +104,12 @@ function runRuff(command, prefixArguments, check) {
99104
}
100105
const format = run(command, [
101106
...prefixArguments,
107+
'--config',
108+
RUFF_CONFIG,
102109
'format',
110+
// Ruff ignores RUFF_CONFIG's exclusions for any path named explicitly on
111+
// the command line unless exclusions are forced.
112+
'--force-exclude',
103113
...(check ? ['--check'] : []),
104114
'.',
105115
]);
@@ -193,7 +203,10 @@ function main() {
193203
...python.prefixArguments,
194204
'-m',
195205
'ruff',
206+
'--config',
207+
RUFF_CONFIG,
196208
'format',
209+
'--force-exclude',
197210
...(check ? ['--check'] : []),
198211
'.',
199212
],

‎scripts/format-swift.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ const MINIMUM_SWIFT_FORMAT_MAJOR = 6;
2727
const MINIMUM_SWIFT_FORMAT_MINOR = 3;
2828
const MAX_FILES_PER_PROCESS = 100;
2929
const MAX_HEADER_BYTES = 4096;
30-
const IGNORE = ['**/Pods/**', '**/build/**', '**/node_modules/**'];
30+
const IGNORE = [
31+
'**/Pods/**',
32+
'**/build/**',
33+
'**/metainternal/**',
34+
'**/node_modules/**',
35+
];
3136

3237
function isGenerated(file) {
3338
let fd;

0 commit comments

Comments
 (0)