• Stars
    star
    275
  • Rank 146,652 (Top 3 %)
  • Language
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An opinionated, community-driven set of lint rules for Dart and Flutter projects. Like pedantic but stricter

Pub style: lint

Lint for Dart/Flutter

lint is a hand-picked, open-source, community-driven collection of lint rules for Dart and Flutter projects. The set of rules follows the Effective Dart: Style Guide.

This package can be used as a replacement for package:lints or the discontinued package:pedantic for those who prefer stricter rules.

lint supports 3 different set of rules:

  • strict: tries to be strict but not annoying. Perfect for production app code
  • casual: great when prototyping, to be used in code samples, any non-production code
  • package: like strict but for dart packages, that have a public API

Install

Add lint as dependency to your pubspec.yaml. Version ^1.0.0 means you're automatically getting the latest version for lint when running pub upgrade

dev_dependencies:
  lint: ^2.0.0

Create an analysis_options.yaml file in the root of your project with the following content:

# This file configures the analyzer to use the lint rule set from `package:lint`

include: package:lint/strict.yaml # For production apps
# include: package:lint/casual.yaml # For code samples, hackathons and other non-production code
# include: package:lint/package.yaml # Use this for packages with public API


# You might want to exclude auto-generated files from dart analysis
analyzer:
  exclude:
    #- '**.freezed.dart'
    #- '**.g.dart'

# You can customize the lint rules set to your own liking. A list of all rules
# can be found at https://dart-lang.github.io/linter/lints/options/options.html
linter:
  rules:
    # Util classes are awesome!
    # avoid_classes_with_only_static_members: false
    
    # Make constructors the first thing in every class
    # sort_constructors_first: true

    # Choose wisely, but you don't have to
    # prefer_double_quotes: true
    # prefer_single_quotes: true

Lint badge

You're using lint in your open-source project? Add the badge to your README.md show that you honor strict lint rules

style: lint

[![style: lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)](https://pub.dev/packages/lint)

Comparison with other lint packages

A detailed comparison of all linting packages for dart can be found at https://rydmike.com/blog_flutter_linting.html

lint is among the strictest but not the strictest. It tires to find the right balance between useful and annoying.

Which version to use?

Generally, you can just put lint: ^2.0.0 in your pubspec.yaml and pub get the latest version compatible with your Dart version.

Dart Version Lint Version
2.18 2.0.0
2.17 1.10.0
2.16 1.9.0
2.15 1.8.0
2.14 1.7.0
2.13 1.6.0
2.12 1.5.0

Comparison to discontinued package:pedantic

Google publicly shares their internal rules as package:pedantic in open-source. It represents what Google is enforcing internally throughout all Dart code. For a lint rule to be added to pedantic, Google has to change all code which doesn't follow the style.

This strict practice results in only 27/150+ rules to be enabled. While some are contradictory to each other and can not enabled together, a big chunk of rules isn't enabled because it requires too much work to update all of Googles existing code.

For developers outside Google, it is the norm to have separate lint rules per project. One project might enable more rules then others.

lint enables a majority of lint rules, leaving out contradictory and very opinionated rules.

License

Copyright 2022 Pascal Welsch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

android-HoloCircularProgressBar

Holo Circular ProgressBar
Java
957
star
2

CompositeAndroid

Composition over inheritance for Android components like Activity or Fragment
Java
516
star
3

kt.dart

A port of kotlin-stdlib for Dart/Flutter including immutable collections (KtList, KtMap, KtSet) and other packages
Dart
467
star
4

flutter_wrapper

Flutter execution wrapper which keeps the flutter version in sync for each project
Dart
282
star
5

deep_pick

Pick values from Dart deep nested data structures (usually json)
Dart
106
star
6

gradle-GitVersioner

generates a project version for the given git project to distinguish between builds
81
star
7

gradle-gitVersioner-plugin

Extracts a useful versionCode and versionName from git history
Kotlin
71
star
8

Konduit

A declarative UI Framework for android using Kotlin
Kotlin
70
star
9

spot

Chainable powerful Flutter widget selector API, screenshots and assertions for awesome widget tests.
Dart
62
star
10

ArrayAdapter

The missing ArrayAdapter implementation for RecyclerView
Java
37
star
11

git-revision

Git extension to generate a meaningful, human readable revision for each commit in a git repository.
Dart
25
star
12

android-wear-GoPro-Remote

Android Wear Application to control a GoPro with wifi commands
Java
22
star
13

android-GetReactive

GitHub repository search with RxJava (code from talk "Get Reactive" at DroidconUk15/Devoxx15)
Java
13
star
14

nanoid2

Dart
11
star
15

docker-flutterw

Docker image for flutter projects using flutter_wrapper
Dockerfile
10
star
16

kotlin-advent-of-code

Kotlin implementation of http://adventofcode.com/
Kotlin
8
star
17

flutter-tdd-workshop

Flutter TDD workshop
C++
7
star
18

immutability_in_dart

Dart
7
star
19

aoc22_dart_code_golf

AdventOfCode 2022 in Dart focusing on code golf, making the solutions as small as possible
Dart
5
star
20

cgn_code_design_workshop

Android workshop at Code+Design in Cologne
Java
3
star
21

android-wear-samples

samples for android wear APIs for the Hackathon in Cologne 5.3.15 http://hackathon.mobile.cologne/
Java
3
star
22

flutterw_sidekick_plugin

Binds the flutter_wrapper Flutter SDK to sidekick CLIs
Dart
2
star
23

flutter_dependabot_example

Dart
2
star
24

Kata-Kotlin-Pancake-Flipper

Coding challenge in Kotlin from first qualification round of Google code jam 2017
Kotlin
1
star
25

dart-aoc18

Advent of code solutions in dart
Dart
1
star
26

gdg-dus-study-jam

Java
1
star
27

kata-author-collaboration

Coding dojo kata building a shopping basket with discounts
1
star
28

gh-tidy-clone

Clones github projects into ~/Projects/github/{org}/{repo}
Go
1
star