64 lines
2.2 KiB
YAML
64 lines
2.2 KiB
YAML
# 根级共享 lint 配置。
|
||
# 来源:conti-docs/14-conventions-and-ci-gates.md §二
|
||
# 每个子包的 analysis_options.yaml 只写一行 include 指向本文件,禁止在子包里
|
||
# 放宽规则——放宽必须改这里,让所有人一起讨论。
|
||
|
||
include: package:flutter_lints/flutter.yaml
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 偏离文档说明(riverpod_lint 3.1.0 起的破坏性变更)
|
||
#
|
||
# 文档 03/14 写的是 `analyzer: plugins: - custom_lint` + CI 里单独跑
|
||
# `dart run custom_lint`。但 riverpod_lint 3.1.0 已经从 custom_lint 迁移到
|
||
# analysis_server_plugin:
|
||
# > `riverpod_lint` is no-longer implemented using `custom_lint`,
|
||
# > but instead `analysis_server_plugin`. —— riverpod_lint CHANGELOG 3.1.0
|
||
# 实测 riverpod_lint 3.1.8 的依赖里已无 custom_lint。
|
||
#
|
||
# 因此:插件改在下面的顶层 plugins: 段声明,规则由 `dart analyze` /
|
||
# `flutter analyze` 直接执行,CI 里不再需要独立的 custom_lint 步骤。
|
||
# 详见根目录 SCAFFOLD-NOTES.md §B。
|
||
# ---------------------------------------------------------------------------
|
||
plugins:
|
||
riverpod_lint: ^3.1.8
|
||
|
||
analyzer:
|
||
language:
|
||
strict-casts: true
|
||
strict-raw-types: true
|
||
strict-inference: true
|
||
errors:
|
||
# freezed / riverpod 生成器会在非法位置放注解,这是生成器的正常行为
|
||
invalid_annotation_target: ignore
|
||
# 下面三条从 warning 提到 error:它们几乎总是真实缺陷
|
||
unused_import: error
|
||
dead_code: error
|
||
unawaited_futures: error
|
||
exclude:
|
||
- "**/*.g.dart"
|
||
- "**/*.freezed.dart"
|
||
- "**/generated/**"
|
||
|
||
formatter:
|
||
page_width: 100
|
||
|
||
linter:
|
||
rules:
|
||
# --- 可读性 ---
|
||
- always_declare_return_types
|
||
- prefer_single_quotes
|
||
- require_trailing_commas
|
||
- directives_ordering
|
||
- sort_pub_dependencies
|
||
# --- 正确性(这几条是真正拦过线上事故的) ---
|
||
- avoid_dynamic_calls
|
||
- avoid_slow_async_io
|
||
- cancel_subscriptions
|
||
- close_sinks
|
||
- discarded_futures
|
||
- unawaited_futures
|
||
- no_adjacent_strings_in_list
|
||
- test_types_in_equals
|
||
- throw_in_finally
|
||
- unnecessary_statements
|