Skip to content

Commit

Permalink
251: Configure linting, formatting and typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenkleinle committed Oct 24, 2024
1 parent 4874d0b commit fd0e2bc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
21 changes: 21 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

#
# Install this using:
# ln -s ../../.github/hooks/pre-commit .git/hooks/pre-commit
#

DART_FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.dart" | sed 's| |\\ |g')

if [ ! -z "$DART_FILES" ]; then
if [ ! -x "$(command -v fvm)" ]; then
echo "You need to install fvm in order to commit and format files"
exit 1
fi

# Prettify all selected files
echo "$DART_FILES" | xargs fvm dart format -l 120

# Add back the modified/prettified files to staging
echo "$DART_FILES" | xargs git add
fi
7 changes: 7 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 16 additions & 24 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
# 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

analyzer:
exclude: [build/**]
errors:
always_use_package_imports: error
directives_ordering: error
prefer_single_quotes: error
require_trailing_commas: error
language:
strict-casts: true
strict-raw-types: true
strict-inference: true

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.dev/lints.
#
# 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
- always_use_package_imports
- directives_ordering
- prefer_single_quotes
- require_trailing_commas
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void main() {
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down

0 comments on commit fd0e2bc

Please sign in to comment.