Skip to main content

dart_easy_json_lints 0.3.0 copy "dart_easy_json_lints: ^0.3.0" to clipboard
dart_easy_json_lints: ^0.3.0 copied to clipboard

Analyzer plugin for dart_easy_json: flags misused annotations in the editor, before build_runner runs.

example/README.md

Example #

analysis_options.yaml at the root of your package:

plugins:
  dart_easy_json_lints: ^0.3.0

A model with mistakes the plugin reports (dart analyze output shown below it):

import 'package:dart_easy_json/easy_json.dart';

class Conv {
  static String fromJson(Object? v) => '$v';
  static int toJson(int v) => v;
}

bool isShort(String v) => v.length < 3;

@EasyJson()
class LintDemo with LintDemoSerializer {
  @EasyValidate(minLength: 3)
  final int age;

  @EasyValidate(past: true)
  final String name;

  @EasyConvert(fromJson: Conv.fromJson, toJson: Conv.toJson)
  final DateTime createdAt;

  @EasyValidate(custom: isShort)
  final int code;

  LintDemo(this.age, this.name, this.createdAt, this.code);
}
warning - 'minLength' doesn't apply to 'int' fields, so it is ignored. - easy_validate_wrong_type
warning - 'past' doesn't apply to 'String' fields, so it is ignored. - easy_validate_wrong_type
warning - The fromJson function 'Conv.fromJson' doesn't fit field 'createdAt': it returns 'String', but the value is 'DateTime'. - easy_convert_wrong_signature
warning - The toJson function 'Conv.toJson' doesn't fit field 'createdAt': it takes 'int', but the value is 'DateTime'. - easy_convert_wrong_signature
warning - The custom function 'isShort' doesn't fit field 'code': it takes 'String', but the value is 'int'. - easy_convert_wrong_signature
0
likes
160
points
420
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Analyzer plugin for dart_easy_json: flags misused annotations in the editor, before build_runner runs.

Repository (GitHub)
View/report issues

Topics

#json #lints #analyzer #codegen

License

MIT (license)

Dependencies

analysis_server_plugin, analyzer

More

Packages that depend on dart_easy_json_lints