Files
FlClash/test/lint/design_package_test.dart
T
chen08209 96fcb9ab5e chore(agents,tool): rebuild agent config, lint gates, CI, and release tooling
Rework .agents/, Claude/Codex config, CI workflows, lint gates and
lint-rule tests, and the release/changelog tooling. The 5% comment
density gate stays diff-scoped inside git hooks, where GIT_DIR outranks
the -C the gate uses to locate the repository. The tray icon generator
writes multi-size ICO files from the SVG sources into the per-platform
tray asset directories. The custom code-review subagents are gone: the
built-in /code-review never dispatched them, and the subagent model now
lives in a user-level setting outside the repository.

The Makefile, build_config.yaml and CI hand the Core and Helper builds to
the setup build hook, so the buildkit launchers go, and setup.dart
packages AppImage and rpm on arm64 with flutter_distributor pinned to the
fork tag that normalizes packaging permissions.

Changelog: skip
2026-09-10 12:42:52 +08:00

64 lines
2.0 KiB
Dart

import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
const _roots = ['lib', 'test', 'tool', 'plugins'];
const _forbiddenImports = <String, String>{
'package:cupertino_ui/':
'the app is Material only; take widgets-layer types from '
'package:flutter/widgets.dart instead',
'package:flutter/material.dart':
'Material comes from package:material_ui/material_ui.dart',
'package:flutter/cupertino.dart':
'the app is Material only; take widgets-layer types from '
'package:flutter/widgets.dart instead',
};
const _generatedL10n = ['lib/l10n/l10n.dart', 'lib/l10n/intl/'];
bool _isGenerated(String path) {
return path.contains('/generated/') ||
path.endsWith('.g.dart') ||
path.endsWith('.freezed.dart') ||
_generatedL10n.any(path.startsWith);
}
void main() {
test('material_ui is the only design library the project imports', () {
final offenders = <String>[];
for (final root in _roots) {
final directory = Directory(root);
if (!directory.existsSync()) {
fail('$root no longer exists; update _roots.');
}
for (final entity in directory.listSync(recursive: true)) {
if (entity is! File || !entity.path.endsWith('.dart')) {
continue;
}
final relative = p.relative(entity.path);
if (_isGenerated(relative)) {
continue;
}
final lines = entity.readAsLinesSync();
for (var i = 0; i < lines.length; i++) {
final line = lines[i].trimLeft();
if (!line.startsWith('import ') && !line.startsWith('export ')) {
continue;
}
for (final entry in _forbiddenImports.entries) {
if (line.contains("'${entry.key}") ||
line.contains('"${entry.key}')) {
offenders.add('$relative:${i + 1} — ${entry.value}');
}
}
}
}
}
expect(offenders, isEmpty, reason: offenders.join('\n'));
});
}