[Lint] Officially deprecate Enzyme (#221779)

## Summary

Please see for
[context](https://docs.google.com/document/d/1J9mGfmGukgFS-6jqD1zopH8wIRvsqNhDhQbjQZ9hjEY/edit?tab=t.hzzf0a72f9gd)

This PR tries to discourage usage of enzyme: 

- Mark shared test utils that use enzyme as `@deprecated` 
- Add eslint warning for imports of `enzyme` 
- Add ci stat counter of imports of `enzyme`
This commit is contained in:
Anton Dosov 2025-06-03 12:15:37 +02:00 committed by GitHub
parent b4b49acb68
commit 0dbbf482a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 175 additions and 11 deletions

View file

@ -34,6 +34,7 @@ import { writeDeprecationDueByTeam } from './mdx/write_deprecations_due_by_team'
import { trimDeletedDocsFromNav } from './trim_deleted_docs_from_nav';
import { getAllDocFileIds } from './mdx/get_all_doc_file_ids';
import { getPathsByPackage } from './get_paths_by_package';
import { countEnzymeImports, EnzymeImportCounts } from './count_enzyme_imports';
function isStringArray(arr: unknown | string[]): arr is string[] {
return Array.isArray(arr) && arr.every((p) => typeof p === 'string');
@ -144,7 +145,9 @@ export function runBuildApiDocsCli() {
const reporter = CiStatsReporter.fromEnv(log);
const allPluginStats: { [key: string]: PluginMetaInfo & ApiStats & EslintDisableCounts } = {};
const allPluginStats: {
[key: string]: PluginMetaInfo & ApiStats & EslintDisableCounts & EnzymeImportCounts;
} = {};
for (const plugin of plugins) {
const id = plugin.id;
@ -162,6 +165,7 @@ export function runBuildApiDocsCli() {
allPluginStats[id] = {
...(await countEslintDisableLines(paths)),
...(await countEnzymeImports(paths)),
...collectApiStatsForPlugin(
pluginApi,
missingApiItems,
@ -283,6 +287,12 @@ export function runBuildApiDocsCli() {
group: 'Total ESLint disabled count',
value: pluginStats.eslintDisableFileCount + pluginStats.eslintDisableLineCount,
},
{
id,
meta: { pluginTeam },
group: 'Enzyme imports',
value: pluginStats.enzymeImportCount,
},
]);
const getLink = (d: ApiDeclaration) =>