Cool linter This is a custom linter package for dart/flutter code.

Overview

Pub Version Dart SDK Version Pub popularity

Cool linter

This is a custom linter package for dart/flutter code. It can set linter for exclude some of words. This words you can set in analysis_options.yaml by example below

Usage

1. Add dependency to pubspec.yaml

dev_dependencies:
  cool_linter: ^1.2.0 # last version of plugin

2. Add configuration to analysis_options.yaml

analyzer:
  plugins:
    - cool_linter

cool_linter:
  extended_rules:
    - always_specify_stream_subscription
    - prefer_trailing_comma
  always_specify_types:
    - typed_literal
    - declared_identifier
    - set_or_map_literal
    - simple_formal_parameter
    - type_name
    - variable_declaration_list
  regexp_exclude:
    -
      pattern: Colors
      hint: Use colors from design system instead!
      severity: WARNING
    -
      pattern: Test123{1}
      severity: ERROR
  exclude_folders:
    - test/**
    - lib/ku/**
  1. always_specify_types linter:

always_specify_types This rule is like dart core linter rule, but you can choose which of this subrules want to use:

  • typed_literal
  • declared_identifier
  • set_or_map_literal
  • simple_formal_parameter
  • type_name
  • variable_declaration_list

Also you can choose exclude folders for this rule. See exclude_folders

  1. regexp_exclude linter:

  • pattern - RegExp-pattern, for example: Test123{1}, ^Test123$ and others
  • severity - [optional parameter]. It is console information level. May be WARNING, INFO, ERROR. Default is WARNING
  • hint - [optional parameter]. It is console information sentence
  • exclude_folders - this folders linter will ignore. By default excluded folders are:
'.dart_tool/**',
'.vscode/**',
'packages/**',
'ios/**',
'macos/**',
'web/**',
'linux/**',
'windows/**',
'go/**',
  1. extended_rules. always_specify_stream_subscription linter:

Always use StreamSubscription for Stream.listen();

CORRECT:

final Stream<String> stream2 = Stream<String>.value('value');
final StreamSubscription<String> sub = stream2.listen((_) {}); // OK

WARNING:

final Stream<String> stream1 = Stream<String>.value('value');
stream1.listen((String ttt) {}); // LINT

⚠️ Attention!!!

You must restart your IDE for starting plugin

3. CLI

You can use linter as command line tool dart bin/cool_linter_cli.dart analyze -tsc -d test/fix/result --regexp_path test/regexp/regexp_settings_cli.yaml

or using dart pub run

💪 available autofix 💪 for:

  • prefer_trailing_comma
  • always_specify_types_rule

for this subrules: declared_identifier simple_formal_parameter variable_declaration_list

for others subrules feel free to provide me PRs

Available options:

  • -d - Folder to analyze
  • -f - Fix issues. Now only for prefer_trailing_comma rule
  • -t - Use always_specify_types_rule rule
  • -s - Use always_specify_stream_subscription rule
  • -c - Use prefer_trailing_comma rule
  • -f - Fix issues. Now only for prefer_trailing_comma rule
  • --regexp_path - Path to file with RegExp settings

Also you must specify --regexp_path parameter if you want to regexp analyzer. Example: --regexp_path

regexp_exclude:
  -
    pattern: Colors
    hint: Use colors from design system instead!
    severity: WARNING
  -
    pattern: \sTestClass\s
    hint: Dont use TestClass
    severity: ERROR
  -
    pattern: \sTestClass2\s
    hint: Dont use TestClass2
    severity: INFO

Screenshot

4. Result

Example of analysis_options.yaml

analyzer:
  plugins:
    - cool_linter

cool_linter:
  extended_rules:
    - always_specify_stream_subscription
    - prefer_trailing_comma
  always_specify_types:
    - typed_literal
    - declared_identifier
    - set_or_map_literal
    - simple_formal_parameter
    - type_name
    - variable_declaration_list
  regexp_exclude:
    -
      pattern: Colors
      hint: Use colors from design system instead!
      severity: WARNING
    -
      pattern: Test123{1}
      severity: ERROR
  exclude_folders:
    - test/**
    - lib/ku/**

Screenshot Screenshot Screenshot

You might also like...

A simple project with cool animations and fluid UI

A simple project with cool animations and fluid UI

Pokedex This task was quite an interesting one. As with all my projects, I started with understanding the scope and state of this app. I decided to us

Dec 31, 2022

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

Nov 26, 2022

FT-Custom-Widget - A Custom Widget Built With Flutter

FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Mar 29, 2022

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

Flutter Carousel Slider A customizable carousel slider for flutter Screenshots Installing dependencies: flutter_carousel_slider: ^1.0.8 Demo Demo a

Nov 6, 2022

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

flutter_custom_carousel_slider A carousel slider Flutter widget, supports custom

Dec 29, 2022

Enum extendable - Dart code generator. Generates enum extensions code.

Generates code for the extension on an enum. Overview Being able to add fields and methods to an enum. Let's say we have the following enum: enum Math

Jan 10, 2022

Shader manages the compilation of your GLSL shaders into SPIR-V byte code and Dart code

shader Shader manages the compilation of your GLSL shaders into SPIR-V byte code and Dart code. Quickstart # Install cli dart pub global activate shad

Dec 1, 2022

Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Custom User Interactions - Flutter Vikings 2022 A companion app for the Flutter Vikings 2022 talk - Custom User Interactions with Shortcuts, Intents,

Sep 16, 2022

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter. Need help? Please do not submit an issue for a "

Jan 8, 2023
Comments
  • Incompatible with freezed v2

    Incompatible with freezed v2

    $ flutter pub get
    Because cool_linter >=2.4.0 depends on freezed_annotation ^1.1.0 and companion depends on freezed_annotation ^2.0.3, cool_linter >=2.4.0 is forbidden.
    So, because companion depends on cool_linter ^2.4.0, version solving failed.
    Running "flutter pub get" in mobile...
    pub get failed (1; So, because companion depends on cool_linter ^2.4.0, version solving failed.)
    
    opened by bartekpacia 6
  • Publish new version

    Publish new version

    Hi !

    I was about to use the package for a project, however, couldn't install it because depends on analyzer: ^1.7.0 and we're using analyzer: ^2.6.0.

    After checking pubspec.yaml seems that the package is ready to support analyzer: ^2.8.0 (since https://github.com/jWinterDay/cool_linter/commit/2940fb9a6702ce9a73e9dd0d5ebfd0425c591bb6)

    But since no new package release (since (https://github.com/jWinterDay/cool_linter/commit/9ebe662aa2096b462196023762cdca4e9ca1e5b8 I assume), can not leverage that change.

    Could we publish a new version of the package, to be able to use analyzer ^2 versions?

    Thanks !

    opened by davidlj95 3
  • Feature/updates

    Feature/updates

    Updated dependencies

    • Fixed the issues that caused
    • Regenerated files

    Migrated from pedantic to dart lints package

    • Fixed the issues that caused

    Fixed pana analysis issues

    opened by Rexios80 1
🇮🇪 A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart.

Irishman ???? A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart. Installation To install this package

Fairfield Programming Association 2 Oct 8, 2022
A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your issue.

r_scan A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your iss

PengHui Li 112 Nov 11, 2022
This is flutter package for creating a gender selection widget which allows users to choose a gender with cool animations

gender_selection A Flutter package for gender selection. It is an aweome gender selection widget with cool gradients and animation effects Demo Instal

Rohan Malik 10 Apr 8, 2022
Flutter package that provides you custom clippers to help you achieve various custom shapes.

flutter_custom_clippers Flutter package that provides you custom clippers to help you achieve various custom shapes. Usage To use this plugin, add flu

Damodar Lohani 291 Dec 23, 2022
best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

Weekly Budget Flutter App A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Mohamed Awnallah 4 Oct 21, 2021
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

Dart_Native Dart_Native operates as both a code generator tool and a bridge to communicate between Dart and native APIs. Replaces the low-performing F

DartNative 893 Jan 4, 2023
Collection of cool Layouts built with Flutter to Inspire Other UI developers and explore the possibilities of Flutter.

Awesome_Flutter_Layouts Would you like to Contribute your Designs? Please refer the Contribution guidelines before you dive In Need help? or Looks Som

Mahesh Jamdade 103 Nov 22, 2022
Simple but pretty cool birthday countdown app built using flutter

Simple but pretty cool birthday countdown app "For You" ?? Don't forget to star ⭐ the repo if you like what you I have created ?? . ?? GIF of a sample

Ruslan Hasanov 6 Aug 13, 2022
A complete music player in flutter with cool UI and design.

Flutter Music Player A complete and open source music player designed in flutter. It is first complete music player designed in flutter. This app expl

Aman gautam 423 Dec 30, 2022
A simple, powerful widget to build cool transitions

motion_widget A simple, powerful widget to build cool transitions Features Fine-grained control with Interval Lightweight & fully customizable No boil

Sumeet Rukeja 33 Jul 29, 2021