From 8ba6526844c587ac0aad214c54a9483667c738e7 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Wed, 16 Aug 2023 00:42:51 +0800 Subject: [PATCH] Move lint rules to a separated pacakge --- app/analysis_options.yaml | 5 +--- app/pubspec.lock | 11 ++++++-- app/pubspec.yaml | 3 ++- codegen/analysis_options.yaml | 31 +--------------------- codegen/pubspec.yaml | 3 ++- codegen_build/analysis_options.yaml | 31 +--------------------- codegen_build/pubspec.yaml | 3 ++- np_api/analysis_options.yaml | 8 +----- np_api/pubspec.yaml | 40 ++--------------------------- np_common/analysis_options.yaml | 8 +----- np_common/pubspec.yaml | 40 ++--------------------------- np_lints/.gitignore | 7 +++++ np_lints/lib/np.yaml | 7 +++++ np_lints/pubspec.yaml | 10 ++++++++ plugin/analysis_options.yaml | 5 +--- plugin/pubspec.lock | 19 +++++++++----- plugin/pubspec.yaml | 3 ++- 17 files changed, 64 insertions(+), 170 deletions(-) create mode 100644 np_lints/.gitignore create mode 100644 np_lints/lib/np.yaml create mode 100644 np_lints/pubspec.yaml diff --git a/app/analysis_options.yaml b/app/analysis_options.yaml index f4e55496..4007f270 100644 --- a/app/analysis_options.yaml +++ b/app/analysis_options.yaml @@ -1,10 +1,7 @@ -include: package:flutter_lints/flutter.yaml +include: package:np_lints/np.yaml linter: rules: - unawaited_futures: true - avoid_void_async: true prefer_interpolation_to_compose_strings: false no_leading_underscores_for_local_identifiers: false use_build_context_synchronously: false - directives_ordering: true diff --git a/app/pubspec.lock b/app/pubspec.lock index 1a9b527c..4c10dcba 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -581,7 +581,7 @@ packages: source: hosted version: "1.0.0" flutter_lints: - dependency: "direct dev" + dependency: transitive description: name: flutter_lints sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c @@ -969,6 +969,13 @@ packages: relative: true source: path version: "0.0.1" + np_lints: + dependency: "direct dev" + description: + path: "../np_lints" + relative: true + source: path + version: "1.0.0" octo_image: dependency: "direct main" description: @@ -1786,5 +1793,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=2.19.6 <3.0.0" flutter: ">=3.4.0-17.0.pre" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index ae5f62a2..dfd738b3 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -148,13 +148,14 @@ dev_dependencies: ref: copy_with_build-1.7.0 dart_code_metrics: any drift_dev: 2.8.0 - flutter_lints: any flutter_test: sdk: flutter # integration_test: # sdk: flutter np_codegen_build: path: ../codegen_build + np_lints: + path: ../np_lints to_string_build: git: url: https://gitlab.com/nkming2/dart-to-string diff --git a/codegen/analysis_options.yaml b/codegen/analysis_options.yaml index dee8927a..f92d2567 100644 --- a/codegen/analysis_options.yaml +++ b/codegen/analysis_options.yaml @@ -1,30 +1 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options +include: package:np_lints/np.yaml diff --git a/codegen/pubspec.yaml b/codegen/pubspec.yaml index ffc70482..b27dc761 100644 --- a/codegen/pubspec.yaml +++ b/codegen/pubspec.yaml @@ -7,4 +7,5 @@ environment: sdk: '>=2.17.0 <3.0.0' dev_dependencies: - lints: any + np_lints: + path: ../np_lints diff --git a/codegen_build/analysis_options.yaml b/codegen_build/analysis_options.yaml index dee8927a..f92d2567 100644 --- a/codegen_build/analysis_options.yaml +++ b/codegen_build/analysis_options.yaml @@ -1,30 +1 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options +include: package:np_lints/np.yaml diff --git a/codegen_build/pubspec.yaml b/codegen_build/pubspec.yaml index 639c8749..141a9adb 100644 --- a/codegen_build/pubspec.yaml +++ b/codegen_build/pubspec.yaml @@ -16,7 +16,8 @@ dependencies: dev_dependencies: build_test: ^2.1.5 - lints: any + np_lints: + path: ../np_lints path: any test: any code_gen_tester: diff --git a/np_api/analysis_options.yaml b/np_api/analysis_options.yaml index 23babb48..f92d2567 100644 --- a/np_api/analysis_options.yaml +++ b/np_api/analysis_options.yaml @@ -1,7 +1 @@ -include: package:flutter_lints/flutter.yaml - -linter: - rules: - unawaited_futures: true - avoid_void_async: true - directives_ordering: true +include: package:np_lints/np.yaml diff --git a/np_api/pubspec.yaml b/np_api/pubspec.yaml index 63a999c6..5ed59046 100644 --- a/np_api/pubspec.yaml +++ b/np_api/pubspec.yaml @@ -27,49 +27,13 @@ dependencies: dev_dependencies: build_runner: ^2.2.1 - flutter_lints: any np_codegen_build: path: ../codegen_build + np_lints: + path: ../np_lints test: any to_string_build: git: url: https://gitlab.com/nkming2/dart-to-string ref: to_string_build-1.0.0 path: to_string_build - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/np_common/analysis_options.yaml b/np_common/analysis_options.yaml index 23babb48..f92d2567 100644 --- a/np_common/analysis_options.yaml +++ b/np_common/analysis_options.yaml @@ -1,7 +1 @@ -include: package:flutter_lints/flutter.yaml - -linter: - rules: - unawaited_futures: true - avoid_void_async: true - directives_ordering: true +include: package:np_lints/np.yaml diff --git a/np_common/pubspec.yaml b/np_common/pubspec.yaml index 4158f9f2..d8024a1b 100644 --- a/np_common/pubspec.yaml +++ b/np_common/pubspec.yaml @@ -14,42 +14,6 @@ dependencies: logging: any dev_dependencies: - flutter_lints: any + np_lints: + path: ../np_lints test: any - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/np_lints/.gitignore b/np_lints/.gitignore new file mode 100644 index 00000000..3cceda55 --- /dev/null +++ b/np_lints/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/np_lints/lib/np.yaml b/np_lints/lib/np.yaml new file mode 100644 index 00000000..23babb48 --- /dev/null +++ b/np_lints/lib/np.yaml @@ -0,0 +1,7 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + unawaited_futures: true + avoid_void_async: true + directives_ordering: true diff --git a/np_lints/pubspec.yaml b/np_lints/pubspec.yaml new file mode 100644 index 00000000..98af7911 --- /dev/null +++ b/np_lints/pubspec.yaml @@ -0,0 +1,10 @@ +name: np_lints +description: A starting point for Dart libraries or applications. +version: 1.0.0 +publish_to: none + +environment: + sdk: '>=2.19.6 <3.0.0' + +dependencies: + flutter_lints: ^2.0.0 diff --git a/plugin/analysis_options.yaml b/plugin/analysis_options.yaml index a5744c1c..f92d2567 100644 --- a/plugin/analysis_options.yaml +++ b/plugin/analysis_options.yaml @@ -1,4 +1 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +include: package:np_lints/np.yaml diff --git a/plugin/pubspec.lock b/plugin/pubspec.lock index ef96f57a..90a22f00 100644 --- a/plugin/pubspec.lock +++ b/plugin/pubspec.lock @@ -23,13 +23,13 @@ packages: source: sdk version: "0.0.0" flutter_lints: - dependency: "direct dev" + dependency: transitive description: name: flutter_lints - sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.0.2" js: dependency: transitive description: @@ -42,10 +42,10 @@ packages: dependency: transitive description: name: lints - sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.0.1" logging: dependency: "direct main" description: @@ -70,6 +70,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.0" + np_lints: + dependency: "direct dev" + description: + path: "../np_lints" + relative: true + source: path + version: "1.0.0" sky_engine: dependency: transitive description: flutter @@ -84,5 +91,5 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=2.17.0 <3.0.0" + dart: ">=2.19.6 <3.0.0" flutter: ">=3.3.0" diff --git a/plugin/pubspec.yaml b/plugin/pubspec.yaml index f0c7179f..ae2cb144 100644 --- a/plugin/pubspec.yaml +++ b/plugin/pubspec.yaml @@ -13,7 +13,8 @@ dependencies: logging: any dev_dependencies: - flutter_lints: any + np_lints: + path: ../np_lints # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec