diff --git a/packages/neon_lints/README.md b/packages/neon_lints/README.md index 846963e0..971c86a4 100644 --- a/packages/neon_lints/README.md +++ b/packages/neon_lints/README.md @@ -1,8 +1,8 @@ A package containing a very strict set of linting rules. ### Update rules: -To update the rules you need to update the `commitHash` variable in [neon_lints.dart](bin/neon_lints.dart) and execute it by running: +To update the rules you need to update the `commitHash` in [lint_maker.yaml](lint_maker.yaml) and regenerate by running: ```sh -fvm dart run bin/neon_lints.dart +fvm dart run lint_maker ``` diff --git a/packages/neon_lints/bin/neon_lints.dart b/packages/neon_lints/bin/neon_lints.dart deleted file mode 100644 index 15a7e572..00000000 --- a/packages/neon_lints/bin/neon_lints.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'dart:io'; - -import 'package:http/http.dart' as http; -import 'package:yaml/yaml.dart'; - -/// Disabled rules. -/// -/// These rules will be added but disabled. -const disabledRules = [ - 'always_specify_types', - 'avoid_annotating_with_dynamic', - 'avoid_as', - 'avoid_catches_without_on_clauses', - 'avoid_catching_errors', - 'avoid_classes_with_only_static_members', - 'avoid_final_parameters', - 'avoid_print', - 'diagnostic_describe_all_properties', - 'lines_longer_than_80_chars', - 'no_default_cases', - 'one_member_abstracts', - 'prefer_double_quotes', - 'prefer_relative_imports', - 'unnecessary_final', -]; - -/// Rules that won't be added to the list. -/// -/// This is needed for rules not yet available in the current dart version. -const excludedRules = []; - -/// Commit hash to use to fetch the rules from upstream -const commitHash = '7f40f11'; - -Future main() async { - final uri = Uri.parse('https://raw.githubusercontent.com/dart-lang/linter/$commitHash/example/all.yaml'); - final result = await http.get(uri); - final document = loadYaml(result.body) as YamlMap; - final rules = (document['linter'] as YamlMap)['rules'] as YamlList; - - final buffer = StringBuffer(''' -analyzer: - language: - strict-casts: true - errors: - flutter_style_todos: ignore - todo: ignore - exclude: - - "**.g.dart" - - "**.mocks.dart" -linter: - rules: -'''); - - for (final line in rules) { - final excluded = excludedRules.contains(line); - if (!excluded) { - final disabled = disabledRules.contains(line); - buffer.writeln(' $line: ${!disabled}'); - } - } - - File('lib/dart.yaml').writeAsStringSync(buffer.toString()); -} diff --git a/packages/neon_lints/lint_maker.yaml b/packages/neon_lints/lint_maker.yaml new file mode 100644 index 00000000..bce60456 --- /dev/null +++ b/packages/neon_lints/lint_maker.yaml @@ -0,0 +1,29 @@ +dart: + commitHash: 0a567d0 + output: 'lib/dart.yaml' + disabledRules: + - always_specify_types + - avoid_annotating_with_dynamic + - avoid_as + - avoid_catches_without_on_clauses + - avoid_catching_errors + - avoid_classes_with_only_static_members + - avoid_final_parameters + - avoid_print + - diagnostic_describe_all_properties + - lines_longer_than_80_chars + - no_default_cases + - one_member_abstracts + - prefer_double_quotes + - prefer_relative_imports + - unnecessary_final + preset: + analyzer: + language: + strict-casts: true + errors: + flutter_style_todos: ignore + todo: ignore + exclude: + - '**.g.dart' + - '**.mocks.dart' diff --git a/packages/neon_lints/pubspec.yaml b/packages/neon_lints/pubspec.yaml index e103e315..7fecb2e8 100644 --- a/packages/neon_lints/pubspec.yaml +++ b/packages/neon_lints/pubspec.yaml @@ -1,10 +1,13 @@ name: neon_lints description: Linting package used in the nextcloud-neon project version: 1.0.0 +publish_to: none environment: sdk: '>=3.1.0 <4.0.0' -dependencies: - http: ^1.1.0 - yaml: ^3.1.2 +dev_dependencies: + lint_maker: + git: + url: https://github.com/Leptopoda/lint_maker + ref: 15bfdd3881bffc1516975368e86e6ec7d60aa991