nilts_clock

nilts_clock is lint rules, quick fixes and assists for Dart and Flutter projects using clock package that helps you enforce best practices, and avoid errors.

build pub license


Contents

Usage

nilts_clock depends on custom_lint. You should add nilts_clock and custom_lint to your dev_dependencies in pubspec.yaml file.

dev_dependencies:
  custom_lint: <version>
  nilts_clock: <version>

And also, add custom_lint to your analysis_options.yaml file.

analyzer:
  plugins:
    - custom_lint

Configuration

You can configure all lint rules provided by nilts_clock in analysis_options.yaml file. Choice one of the following configuration strategies.

Disabling strategy

All of nilts_clock rules are enabled by default. Add lint rule name and set false to disable it.

custom_lint:
  rules:
    # Disable particular lint rules if you want ignore them whole package.
    - unnecessary_hook_widget: false

Enabling strategy

You can disable all lint rules depends on custom_lint by setting enable_all_lint_rules to false. Add lint rule name and set true to enable it.

custom_lint:
  # Disable all lint rules depends on custom_lint.
  enable_all_lint_rules: false
  rules:
    - unnecessary_hook_widget: true

NOTE: If you enable_all_lint_rules set to false, all of lint rules (not only all of nilts_clock's lint rules) depends on custom_lint will be disabled by default.

Lint rules and quick fixes

Read below to learn about each lint rules intend to. Some of lint rules support quick fixes on IDE.

Quick fix demo

Overview

Rule name Overview Target SDK Rule type Maturity level Quick fix
using_date_time_now Checks if DateTime.now() is used. Any versions nilts_clock supports ErrorProne Experimental ✅️

Details

using_date_time_now

  • Target SDK : Any versions nilts_clock supports
  • Rule type : ErrorProne
  • Maturity level : Experimental
  • Quick fix : ✅

DON'T use DateTime.now().

If your project depends on clock package and expects current time is encapsulated, always use clock.now() instead for consistency.

BAD:

final dateTimeNow = DateTime.now();

GOOD:

final clockNow = clock.now();

See also:

Assists

Upcoming... 🚀

Known issues

Quick fix priorities (Fixed)

Important

Finding which a plugin version fixed the issue is hard, but it looks work as expected. Checked works as expected on Dart plugin 242.24931 and 243.23654.44.

The priorities assigned to quick fixes are not currently visible in IntelliJ IDEA and Android Studio due to the lack of support for PrioritizedSourceChange in these environments. In contrast, VS Code does support this feature, allowing quick fixes to be listed along with their respective priorities.

VS Code IntelliJ IDEA / Android Studio
VS Code IntelliJ IDEA / Android Studio

See also:

fix-all assist (Fixed)

Important

Finding which a plugin version fixed the issue is hard, but it looks as expected. Checked works as expected on Dart plugin 242.24931 and 243.23654.44.

The fix-all assist feature has been introduced in custom_lint_builder 0.6.0. However, this feature is not yet supported in IntelliJ IDEA and Android Studio, owing to their current lack of support for PrioritizedSourceChange.

VS Code IntelliJ IDEA / Android Studio
VS Code IntelliJ IDEA / Android Studio

Feature requests

If you have any feature requests, please create an issue from this template.

Bug reports

If you find any bugs, please create an issue from this template.

Contributing

Welcome your contributions!! Please read CONTRIBUTING docs before submitting your PR.

Libraries

nilts_clock