diff --git a/.gitignore b/.gitignore index 7bf00e8..393f90d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ +# Created by https://www.gitignore.io/api/dart +# Edit at https://www.gitignore.io/?templates=dart + +### Dart ### # See https://www.dartlang.org/guides/libraries/private-files # Files and directories created by pub .dart_tool/ .packages -.pub/ build/ # If you're building an application, you may want to check-in your pubspec.lock pubspec.lock @@ -11,3 +14,14 @@ pubspec.lock # Directory created by dartdoc # If you don't generate documentation locally you can remove this line. doc/api/ + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +# End of https://www.gitignore.io/api/dart diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e94b588 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.0.0 + +- Add linst according to current state of the Effective Dart `analysis_options.yaml`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index c256f1a..aa513e1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # effective_dart -Lints from Effective Dart + +This package provides the lints according to the [Effective Dart](https://dart.dev/guides/language/effective-dart) guide. + +This package is inspired by the [pedantic](https://github.com/dart-lang/pedantic) package, which contains lints internally used at Google. + +## Using the Lints + +To use the lints add a dev dependency in your `pubspec.yaml`: + +```yaml +dev_dependencies: + effective_dart: ^1.0.0 +``` + +Then add an include in your `analysis_options.yaml` file: + +```yaml +include: package:effective_dart/analysis_options.yaml +``` + +You can always specify a specific version instead: + +```yaml +include: package:effective_dart/analysis_options.1.0.0.yaml +``` + +## License + +Licensed under the [MIT License](LICENSE). diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a4bfc29 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: lib/analysis_options.yaml diff --git a/lib/analysis_options.1.0.0.yaml b/lib/analysis_options.1.0.0.yaml new file mode 100644 index 0000000..c35c4b6 --- /dev/null +++ b/lib/analysis_options.1.0.0.yaml @@ -0,0 +1,62 @@ +linter: + rules: + # STYLE + - camel_case_types + - library_names + - file_names + - library_prefixes + - non_constant_identifier_names + - constant_identifier_names # prefer + - directives_ordering + #- lines_longer_than_80_chars # avoid + - curly_braces_in_flow_control_structures + + # DOCUMENTATION + - slash_for_doc_comments + - package_api_docs # prefer # ? + - public_member_api_docs # prefer # ? + - comment_references + + # USAGE + - avoid_relative_lib_imports # prefer + - prefer_adjacent_string_concatenation + - prefer_interpolation_to_compose_strings # prefer + - unnecessary_brace_in_string_interps # avoid + - prefer_collection_literals + - avoid_function_literals_in_foreach_calls # avoid + - prefer_iterable_whereType + - prefer_function_declarations_over_variables + - unnecessary_lambdas + - prefer_equal_for_default_values + - avoid_init_to_null + - unnecessary_getters_setters + #- unnecessary_getters # prefer # Disabled pending fix: https://github.com/dart-lang/linter/issues/23 + #- prefer_expression_function_bodies # consider + - unnecessary_this + - prefer_initializing_formals + - type_init_formals + - empty_constructor_bodies + - unnecessary_new + - unnecessary_const + - avoid_catches_without_on_clauses # avoid + - use_rethrow_when_possible + + # DESIGN + - use_to_and_as_if_applicable # prefer + - one_member_abstracts # avoid + - avoid_classes_with_only_static_members # avoid + - prefer_final_fields # prefer + - use_setters_to_change_properties + - avoid_setters_without_getters + - avoid_returning_null # avoid + - avoid_returning_this # avoid + - type_annotate_public_apis # prefer + #- prefer_typing_uninitialized_variables # consider + - omit_local_variable_types # avoid + - avoid_return_types_on_setters + - prefer_generic_function_type_aliases + - avoid_private_typedef_functions # prefer + #- use_function_type_syntax_for_parameters # consider + - avoid_positional_boolean_parameters # avoid + - hash_and_equals + - avoid_null_checks_in_equality_operators diff --git a/lib/analysis_options.yaml b/lib/analysis_options.yaml new file mode 100644 index 0000000..3c8ce64 --- /dev/null +++ b/lib/analysis_options.yaml @@ -0,0 +1 @@ +include: package:effective_dart/analysis_options.1.0.0.yaml diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..6c812f3 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,8 @@ +name: effective_dart +version: 1.0.0 +description: This package provides the lints according to the Effective Dart guide. +author: Honza Bittner <git@honzabittner.cz> +homepage: https://github.com/tenhobi/effective_dart + +environment: + sdk: ">=2.1.1-dev.0.0 <3.0.0"