-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add flutter_lints package #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
073773a
Add flutter_lints package
goderbauer 03c11b0
typo
goderbauer 5a9517c
words
goderbauer b951aac
remove dart file
goderbauer 8470f96
++
goderbauer 7abc3d0
pq review
goderbauer 1c27034
++
goderbauer 10f9419
update to 1.0.0-dev.0
goderbauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 1.0.0-dev.0 | ||
|
|
||
| * Initial pre-release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Copyright 2021, The Flutter Authors. All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without | ||
| modification, are permitted provided that the following conditions are | ||
| met: | ||
|
|
||
| * Redistributions of source code must retain the above copyright | ||
| notice, this list of conditions and the following disclaimer. | ||
| * Redistributions in binary form must reproduce the above | ||
| copyright notice, this list of conditions and the following | ||
| disclaimer in the documentation and/or other materials provided | ||
| with the distribution. | ||
| * Neither the name of Google LLC nor the names of its | ||
| contributors may be used to endorse or promote products derived | ||
| from this software without specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| [](https://pub.dev/packages/flutter_lints) | ||
|
|
||
| This package contains a recommended set of lints for [Flutter] apps, packages, | ||
| and plugins to encourage good coding practices. | ||
|
|
||
| Lints are surfaced by the [dart analyzer], which statically checks dart code. | ||
| [Dart-enabled IDEs] typically present the issues identified by the analyzer in | ||
| their UI. Alternatively, the analyzer can be invoked manually by running | ||
| `flutter analyze`. | ||
|
|
||
| This package is built on top of Dart's `recommended.yaml` set of lints from | ||
| [package:lints]. | ||
|
|
||
| ## Usage | ||
|
|
||
| Flutter apps, packages, and plugins created with `flutter create` starting with | ||
| Flutter version 2.xx are already set up to use the lints defined in this | ||
| package. Entities created before that version can use these lints by following | ||
| these instructions: | ||
|
|
||
| 1. Depend on this package as a **dev_dependency** by running | ||
| `flutter pub add --dev flutter_lints`. | ||
| 2. Create an `analyzer_options.yaml` file at the root of the package (alongside | ||
| the `pubspec.yaml` file) and `include: package:flutter_lints/flutter.yaml` | ||
| from it. | ||
|
|
||
| Example `analyzer_options.yaml` file: | ||
|
|
||
| ```yaml | ||
| # This file configures the analyzer, which statically analyzes Dart code to | ||
| # check for errors, warnings, and lints. | ||
| # | ||
| # The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
| # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
| # invoked from the command line by running `flutter analyze`. | ||
|
|
||
| # The following line activates a set of recommended lints for Flutter apps, | ||
| # packages, and plugins designed to encourage good coding practices. | ||
| include: package:flutter_lints/flutter.yaml | ||
|
|
||
| linter: | ||
| # The lint rules applied to this project can be customized in the | ||
| # section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
| # included above or to enable additional rules. A list of all available lints | ||
| # and their documentation is published at | ||
| # https://dart-lang.github.io/linter/lints/index.html. | ||
| # | ||
| # Instead of disabling a lint rule for the entire project in the | ||
| # section below, it can also be suppressed for a single line of code | ||
| # or a specific dart file by using the `// ignore: name_of_lint` and | ||
| # `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
| # producing the lint. | ||
| rules: | ||
| # avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
| # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
|
||
| # Additional information about this file can be found at | ||
| # https://dart.dev/guides/language/analysis-options | ||
| ``` | ||
|
|
||
| [Flutter]: https://flutter.dev | ||
| [dart analyzer]: https://dart.dev/guides/language/analysis-options | ||
| [Dart-enabled IDEs]: https://dart.dev/tools#ides-and-editors | ||
| [package:lints]: https://pub.dev/packages/lints |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Recommended lints for Flutter apps, packages, and plugins. | ||
|
|
||
| include: package:lints/recommended.yaml | ||
|
|
||
| linter: | ||
| rules: | ||
| - avoid_print | ||
| - avoid_unnecessary_containers | ||
| - avoid_web_libraries_in_flutter | ||
| - no_logic_in_create_state | ||
| - prefer_const_constructors | ||
| - prefer_const_constructors_in_immutables | ||
| - prefer_const_declarations | ||
| - prefer_const_literals_to_create_immutables | ||
| - sized_box_for_whitespace | ||
| - use_full_hex_values_for_flutter_colors | ||
| - use_key_in_widget_constructors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| name: flutter_lints | ||
| description: Recommended lints for Flutter apps, packages, and plugins. | ||
| version: 1.0.0-dev.0 | ||
| homepage: https://github.com/flutter/packages/tree/master/packages/flutter_lints | ||
|
|
||
| environment: | ||
| sdk: '>=2.12.0 <3.0.0' | ||
|
|
||
| dependencies: | ||
| lints: ^1.0.0-dev.0 | ||
| # Code is not allowed in this package. Do not add any dependencies or dev_dependencies. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
|
|
||
| filecount=`find . -name '*.dart' | wc -l` | ||
| if [ $filecount -ne 0 ] | ||
| then | ||
| echo 'Dart sources are not allowed in this package:' | ||
| find . -name '*.dart' | ||
| exit 1 | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉