Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a lint tool to check the code against the Dart style guide? [closed]

Tags:

dart

I would like to write code that conforms to the Dart style guide. Therefore I am curios, whether there is any automatic way to check the coding style for Dart.

Do you know about any way to do this?

like image 902
Samuel Hapak Avatar asked Sep 24 '13 15:09

Samuel Hapak


People also ask

What is dart Linting?

Linter for DartThe Dart Linter package defines lint rules that identify and report on "lints" found in Dart code. Linting is performed by the Dart analysis server and the dart analyze command in the Dart command-line tool.

What is the purpose of a code style Linting tool?

A linter is great for identifying errors when you use standard rules. Remember, a linter analyzes your code for stylistic and programming errors against the rules it knows. If part of your code breaks the standard rules, this can pose a problem.

What is Linting in flutter?

Linting is the process of checking the source code for Programmatic as well as Stylistic errors and unformatted code. It's helpful in identifying some common and uncommon mistakes that are made during coding like logical errors, unused variables, empty if-else statements among others.

Which language style that dart follows?

Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications. It is an object-oriented, class-based, garbage-collected language with C-style syntax.


2 Answers

Since Dart 1.13 (currently release candidate) you can enable lint checks, strong mode and other features by adding an .analysis_options file to your Dart project (the folder with the pubspec.yaml file)

analyzer:
  strong-mode: true
  exclude:
  - test/data/**
  language:
    enableSuperMixins: true
linter:
  rules:
    # see http://dart-lang.github.io/linter/lints/
    - always_declare_return_types
    - always_specify_types
    - camel_case_types
    - constant_identifier_names
    - empty_constructor_bodies
    - implementation_imports
    - library_names
    - library_prefixes
    - non_constant_identifier_names
    - one_member_abstracts
    - package_api_docs
    - package_prefixed_library_names
    - slash_for_doc_comments
    - super_goes_last
    - type_init_formals
#    - unnecessary_brace_in_string_interp
    - unnecessary_getters_setters
    - package_names

The available lint rules are listed in http://dart-lang.github.io/linter/lints/

See also

  • https://www.dartlang.org/guides/language/analysis-options
  • https://pub.dartlang.org/packages/linter
like image 65
Günter Zöchbauer Avatar answered Nov 22 '22 05:11

Günter Zöchbauer


There is an open issue you can star to vote for adding the feature to Dart Editor:

https://code.google.com/p/dart/issues/detail?id=2059

like image 42
Everton Avatar answered Nov 22 '22 06:11

Everton