simolus3 / web3dart

Ethereum library, written in Dart.
MIT License
441 stars 270 forks source link

Ignore non_constant_identifier_names, camel_case_types in generated (.g.dart) files #222

Closed vinicentus closed 2 years ago

vinicentus commented 2 years ago

I would like to propose that we automatically include the comment // ignore_for_file: non_constant_identifier_names, camel_case_types in the beginning of every file generated using pub run build_runner build. That way, dart doesn't complain about Name non-constant identifiers using lowerCamelCase and Name types using UpperCamelCase. The rationale behind this suggestion is that the smart contracts, written in another language and perhaps with other naming conventions, shouldn't have to conform to dart's standards, as long as they still work. This would be especially useful in large projects with multiple contract classes.

If you think this suggestion makes sense, I can create a PR.

RELATED: Naming can however become a problem, as is evident in #213. In that special case, functions outright won't be acessible from outside the file. Then we might need to actually rename a function (starting with _), or create a public wrapper funtion.

simolus3 commented 2 years ago

You can also ignore generated files with an analysis_options.yaml file:

analyzer:
  exclude: 
    - '**/*.g.dart'
vinicentus commented 2 years ago

Yes. That is much cleaner. This probably has to be added manually on a case-by-case basis though? So maybe it could be added to the documentation as an option?

simolus3 commented 2 years ago

This sounds like something the readme could point out, yes :) Do you want to open a PR for that?

vinicentus commented 2 years ago

Sure, can do that tomorrow

vinicentus commented 2 years ago

Created a PR