Logo Lint And Style Config

Lint And Style Config

Cộng đồng
zakariaf
lint-and-style-config

Áp dụng analysis_options.yaml nghiêm ngặt dựa trên very_good_analysis với strict-casts/strict-raw-types; nâng một tập hợp cố định các lỗi tiềm ẩn thường bị bỏ qua thành lỗi (unawaited_futures, discarded_futures, empty_catches, use_build_context_synchronously, cancel_subscriptions, close_sinks, avoid_dynamic_calls, exhaustive_cases, avoid_print); dùng dart format làm chuẩn duy nhất cho khoảng trắng; đồng bộ các mục loại trừ tệp được tạo tự động với coverage; và chỉ cho phép bỏ qua theo từng dòng. Giải thích bẫy include ghim phiên bản (include bị thiếu sẽ âm thầm vô hiệu hóa toàn bộ quy tắc), cơ chế errors-only chỉ đổi mức độ lỗi còn linter mới bật quy tắc, và khoảng cách giữa analyze và compile với sealed switch. Hãy dùng khi chỉnh sửa analysis_options.yaml, thêm hoặc tắt một lint, viết `// ignore:`/`// ignore_for_file:`, nâng phiên bản Dart SDK hoặc very_good_analysis, cấu hình riverpod_lint, hoặc giải thích vì sao discarded_futures, use_build_context_synchronously, close_sinks hay missing_provider_scope xuất hiện.

Add to TypingMind

Tổng quan

Nhà phát hànhzakariaf
Kho mãFlutter-Skills
Tên kỹ nănglint-and-style-config
Sao
64
Bản fork
15
Tệp đi kèm
6
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 6 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được zakariaf công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Lint And Style Config trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/zakariaf/Flutter-Skills/tree/main/skills/lint-and-style-config
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zakariaf/Flutter-Skills.git /tmp/Flutter-Skills
mkdir -p .claude/skills
cp -r /tmp/Flutter-Skills/skills/lint-and-style-config .claude/skills/lint-and-style-config
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Lint And Style Config trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Lint And Style Config ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Lint And Style Config với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Lint & Style Config

Style is not taste; it is toolchain-enforced. dart format owns whitespace, the analyzer owns correctness, and a small set of silence-producing bug classes are promoted to build-failing errors. This skill governs the analysis_options.yaml itself and the mechanics that decide whether it actually does anything. Applies whenever you edit that file, add or silence a lint, or bump the SDK/ruleset.

Read the reference for the task at hand:

  • references/rule-catalog.md — every promoted rule and its bug class, the deliberate downgrades, the contested public_member_api_docs call, and the complexity-limit table.
  • references/config-mechanics.md — the include-pin trap, errors:-re-ranks vs linter:-enables, sealed-switch analyze-vs-compile, coverage mirroring, the riverpod_lint plugin, and suppression discipline.

Copy examples/analysis_options.yaml into the package root as the starting config. Run scripts/verify-include-pin.sh and scripts/lint-gates.sh before a PR.

Non-negotiable rules

  1. dart format is the only whitespace authority. Never hand-format, never argue with it, never // dart format off except around a hand-laid table with a justifying comment. CI runs dart format --set-exit-if-changed ..
  2. Build on very_good_analysis, pinned to the version-numbered include. Never the bare analysis_options.yaml — a pub upgrade must not silently change what counts as an error. VGA already sets strict-casts, strict-inference, strict-raw-types; do not restate them in a language: block (redundant config drifts and contradicts).
  3. An info is a failure. CI runs dart analyze --fatal-infos --fatal-warnings. Unaddressed infos accumulate into noise that hides real issues.
  4. Promote only silence-producing bug classes to error — dropped Futures, swallowed failure, dead-context-after-await, resource leaks, dynamic-boundary type holes, non-exhaustive enum switches, print. Not style preferences.
  5. A promotion under errors: only works if the base ruleset already enables the rule. errors: re-ranks existing diagnostics; it cannot turn on an off rule. To enable a rule VGA omits, add it under linter: rules: first.
  6. Never mix list and map form in linter: rules:. - rule items and rule: true entries in one block is a parse error — a broken analyzer, which is a green build. To disable a base rule, use errors: <rule>: ignore.
  7. CI must build, not merely analyze. Sealed-switch exhaustiveness is a compile error, not a lint; an errors: override cannot be trusted to silence it, and any code path that reaches dart compile still fails there — an analyze-only gate can go green over code that will not build.
  8. Exclude generated code, and mirror the exact globs in coverage filtering. Otherwise generated files dilute the coverage number until it is meaningless.
  9. Suppressions are line-scoped only, with a same-line/above reason. Never // ignore_for_file: on a promoted rule; never any suppression on an architecture/import gate. Prefer fixing the code.
  10. Never add custom_lint. riverpod_lint 3.x runs on the first-party plugin system; its diagnostics fire on a plain flutter analyze.

The include, and the trap that silently disables everything

yaml
include: package:very_good_analysis/analysis_options.10.3.0.yaml

If that filename does not exist in the resolved package, you get one warning • include_file_not_found and analysis runs with zero rules. A build that checks nothing is green.

Bump the include filename in the same commit as the SDK/VGA bump, verify the file exists (ls ~/.pub-cache/hosted/pub.dev/very_good_analysis-*/lib/), and after any bump confirm a known violation still errors — never trust green. scripts/verify-include-pin.sh automates the existence check.

Promote the silence-bugs to error

yaml
analyzer:
  errors:
    unawaited_futures: error
    discarded_futures: error
    empty_catches: error
    avoid_catches_without_on_clauses: error
    only_throw_errors: error
    throw_in_finally: error
    use_build_context_synchronously: error
    cancel_subscriptions: error
    close_sinks: error            # VGA ships this at `ignore`; re-promoted
    avoid_dynamic_calls: error
    always_declare_return_types: error
    cast_nullable_to_non_nullable: error
    exhaustive_cases: error
    avoid_print: error
    avoid_slow_async_io: error

Each turns an info-level squiggle a solo dev scrolls past into a build failure. See references/rule-catalog.md for the per-rule bug class and the rules held deliberately at warning/ignore (deprecated_member_use, invalid_annotation_target, lines_longer_than_80_chars).

errors: re-ranks; linter: rules: enables

yaml
# Promoting works ONLY because VGA already enables these rules (close_sinks even
# at severity `ignore` counts as enabled — the override resurrects it).
analyzer:
  errors:
    close_sinks: error

# To enable a rule VGA does NOT ship, add it here FIRST, then optionally promote.
linter:
  rules:
    some_rule_vga_omits: true

Verify with a real violation — never assume a promotion took. The shipped config needs no linter: rules: block because every rule it promotes is VGA-enabled.

Sealed exhaustiveness is a compile error, not a lint

dart
sealed class SaveResult {}
class Saved extends SaveResult {}
class SaveFailed extends SaveResult {}

// Missing a case is `non_exhaustive_switch_statement` — a COMPILE error.
// (A switch *expression* raises `non_exhaustive_switch_expression` instead.)
String describe(SaveResult r) {
  switch (r) {
    case Saved():
      return 'saved';
    case SaveFailed():
      return 'failed';
  }
}

exhaustive_cases only covers enum / static-const sets. Model failure and mode types as sealed so a new case breaks the build at every call site instead of falling through a default into silence. An errors: override cannot be trusted to suppress an exhaustiveness diagnostic, and even where dart analyze is coaxed green dart compile still fails — so CI must build, never merely analyze. See dart3-idioms-and-coding-standards.

Excludes, mirrored to coverage

yaml
analyzer:
  exclude:
    - "**/*.g.dart"
    - "**/*.freezed.dart"
    - "**/*.drift.dart"
    - "**/generated_plugin_registrant.dart"
    - "test/drift/generated/**"   # drift schema snapshots — never reformat/fix

The identical globs must also feed coverage filtering (lcov --remove or your reporter's excludes). Excludes and coverage filters that drift apart lie the number upward. See testing-strategy and codegen-and-toolchain.

The hole no lint catches

dart
// WRONG — flagged by NOTHING. The arrow returns the Future (so discarded_futures
// is satisfied), but the target is VoidCallback, so Dart drops it silently.
onPressed: () => repository.save(note),

// RIGHT — a void-returning intent method the callback holds safely.
class NoteController {
  void saveNow(Note note) => unawaited(_repo.save(note).catchError(_report));
}
// onPressed: () => controller.saveNow(note),

The mitigation is structural, never disciplinary. A green analyzer is not proof an operation ran; the highest-severity failures are invisible to every rule and need a manual pass. See examples/callback_future_hole.dart and async-safety.

Anti-patterns

  • Bare include: package:very_good_analysis/analysis_options.yaml — a pub upgrade silently changes the ruleset; a missing pinned file silently disables it. Pin and verify.
  • Restating strict-casts/strict-raw-types in a language: block — VGA sets them; the copy drifts and eventually contradicts.
  • Promoting a rule VGA does not enable — errors: cannot resurrect an off rule, so the promotion silently does nothing.
  • Mixing - rule and rule: false in one linter: rules: block — parse error, broken analyzer, green build.
  • Analyze-only CI — passes over code that fails dart compile when a sealed switch is non-exhaustive.
  • Excludes not mirrored in coverage — generated files inflate the number.
  • // ignore_for_file: on a promoted rule, or any suppression on an import gate — the next edit is unprotected; a silenced correctness gate is a blocker.
  • Adding custom_lint — legacy plugin system; riverpod_lint 3.x needs none.
  • Reformatting a drift schema snapshot — corrupts the migration-test baseline.

Definition of done

  • dart format --set-exit-if-changed . clean; dart analyze --fatal-infos --fatal-warnings passes; CI builds (not analyze-only).
  • Include is the version-pinned VGA file and resolves in the pub cache (scripts/verify-include-pin.sh passes).
  • No redundant language: block; strict modes come from VGA.
  • The silence-bug classes are promoted to error; every promoted rule is one VGA actually enables.
  • No mixed list/map form in linter: rules:.
  • Generated-file excludes present and mirrored in coverage filtering.
  • Any suppression is line-scoped with a reason, none on an architecture gate; no // ignore_for_file: on a promoted rule.
  • riverpod_lint configured with a version: key; no custom_lint.

Related skills

  • dartdoc-conventions — backs public_member_api_docs: error and the seams to document.
  • async-safety — the Future-dropped-in-a-callback hole this config cannot see.
  • error-handling-typed-results — the sealed Failure/Result spine that makes exhaustiveness a compile-time guarantee.
  • dart3-idioms-and-coding-standards — sealed types and the exhaustive-switch discipline behind rule 7.
  • naming-conventions — the role suffixes and Effective-Dart naming the analyzer does not enforce.
  • state-management-riverpod — the Riverpod patterns riverpod_lint guards.
  • codegen-and-toolchain / run-codegen — the generated files these excludes cover.
  • ci-pipeline-and-gates — where these gates and the build-not-analyze rule run.
  • testing-strategy — coverage mirroring and what a green analyzer cannot prove.
  • dependency-hygiene — the version-pinned lint include as a dependency concern.

References

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Lint And Style Config làm được gì?

Áp dụng analysis_options.yaml nghiêm ngặt dựa trên very_good_analysis với strict-casts/strict-raw-types; nâng một tập hợp cố định các lỗi tiềm ẩn thường bị bỏ qua thành lỗi (unawaited_futures, discarded_futures, empty_catches, use_build_context_synchronously, cancel_subscriptions, close_sinks, avoid_dynamic_calls, exhaustive_cases, avoid_print); dùng dart format làm chuẩn duy nhất cho khoảng trắng; đồng bộ các mục loại trừ tệp được tạo tự động với coverage; và chỉ cho phép bỏ qua theo từng dòng. Giải thích bẫy include ghim phiên bản (include bị thiếu sẽ âm thầm vô hiệu hóa toàn bộ quy tắc),...

Vì sao nên dùng Lint And Style Config trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Lint And Style Config là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Lint And Style Config trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/zakariaf/Flutter-Skills/tree/main/skills/lint-and-style-config. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Lint And Style Config?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Lint And Style Config với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Lint And Style Config với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Lint And Style Config có miễn phí không?

Có. Kỹ năng này được zakariaf phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇