A very opinionated Collection of Linter Rules for Flutter and Dart (based on flutter_lints and lints)
Add this package as a devDependency.
flutter pub add --dev galactic_lintsor
dart pub add --dev galactic_lintsAlternatively, you can directly add it to the devDependencies section in your pubspec.yaml:
dev_dependencies:
galactic_lints: ^0.0.1Add the following line to your analysis_options.yaml:
include: package:galactic_lints/lints.yamlFollowing that, you can still easily enable or disable rules as you please.
linter:
rules:
prefer_single_quotes: falseCheckout the packages flutter_lints and lints.
avoid_dynamic_callsavoid_slow_async_iocancel_subscriptionsclose_sinkscollection_methods_unrelated_typecomment_referencesdiagnostic_describe_all_propertiesdiscarded_futuresno_adjacent_strings_in_listprefer_relative_importsthrow_in_finallyunnecessary_statements
always_declare_return_typesavoid_catches_without_on_clausesavoid_catching_errorsavoid_classes_with_only_static_membersavoid_double_and_int_checksavoid_escaping_inner_quotesavoid_final_parametersavoid_implementing_value_typesavoid_js_rounded_intsavoid_multiple_declarations_per_lineavoid_positional_boolean_parametersavoid_private_typedef_functionsavoid_redundant_argument_valuesavoid_returning_thisavoid_setters_without_gettersavoid_types_on_closure_parametersavoid_unused_constructor_parametersavoid_void_asynccascade_invocationsdangling_library_doc_commentsdeprecated_consistencyimplicit_call_tearoffsjoin_return_with_assignmentleading_newlines_in_multiline_stringslines_longer_than_80_charsmissing_whitespace_between_adjacent_stringsnoop_primitive_operationsone_member_abstractsonly_throw_errorsparameter_assignmentsprefer_asserts_in_initializer_listsprefer_asserts_with_messageprefer_constructors_over_static_methodsprefer_final_in_for_eachprefer_final_localsprefer_if_elements_to_conditional_expressionsprefer_int_literalsprefer_null_aware_method_callsprefer_single_quotessecure_pubspec_urlssort_pub_dependenciessort_unnamed_constructors_firsttype_literal_in_constant_patternunawaited_futuresunnecessary_await_in_returnunnecessary_lambdasunnecessary_library_directiveunnecessary_null_aware_operator_on_extension_on_nullableunnecessary_null_checksunnecessary_parenthesisunnecessary_raw_stringsunnecessary_to_list_in_spreadsuse_colored_boxuse_decorated_boxuse_enumsuse_if_null_to_convert_nulls_to_boolsuse_is_even_rather_than_modulouse_late_for_private_fields_and_variablesuse_named_constantsuse_raw_stringsuse_setters_to_change_propertiesuse_string_buffersuse_string_in_part_of_directivesuse_super_parametersuse_test_throws_matchers
This project is configured with husky and lint-staged to automatically format code pre-commit.
To install the pre-commit hook, you need to install and run husky via bun.