Coder Social home page Coder Social logo

ttmdung203 / linter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dart-lang/linter

0.0 1.0 0.0 3.88 MB

Linter for Dart.

Home Page: https://dart-lang.github.io/linter/

License: BSD 3-Clause "New" or "Revised" License

Dart 99.81% Shell 0.19%

linter's Introduction

Linter for Dart

The 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 dartanalyzer commandline tool.

Lint Count Build Status Coverage Status Pub

Installing

The linter is bundled with the Dart SDK; if you have an updated Dart SDK already, you're done!

Alternatively, if you want to contribute to the linter or examine the source, clone the linter repo like this:

$ git clone https://github.com/dart-lang/linter.git

Usage

The linter gives you feedback to help you catch potential errors and keep your code in line with the published Dart Style Guide. Currently enforceable lint rules (or "lints") are catalogued here and can be configured via an analysis options file. The linter is run from within the dartanalyzer command-line tool shipped with the Dart SDK. Assuming you have lints configured in an analysis_options.yaml file with these contents:

linter:
  rules:
    - annotate_overrides
    - hash_and_equals
    - prefer_is_not_empty

you could lint your package like this:

$ dartanalyzer --options analysis_options.yaml .

and see any violations of the annotate_overrides, hash_and_equals, and prefer_is_not_empty rules in the console. To help you choose the rules you want to enable for your package, we have provided a complete list of rules. For the lints that are enforced internally at Google, see package:pedantic. For a set of rules corresponding to the Effective Dart guide, see package:effective_dart.

If a specific lint warning should be ignored, it can be flagged with a comment. For example,

   // ignore: avoid_as
   (pm as Person).firstName = 'Seth';

tells the dartanalyzer to ignore this instance of the avoid_as warning.

End-of-line comments are supported as well. The following communicates the same thing:

   (pm as Person).firstName = 'Seth'; // ignore: avoid_as

To ignore a rule for an entire file, use the ignore_for_file comment flag. For example,

// ignore_for_file: avoid_as

void main() {
  ...
  (pm as Person).firstName = 'Seth';
}

tells the dartanalyzer to ignore all occurences of the avoid_as warning in this file.

As lints are treated the same as errors and warnings by the analyzer, their severity can similarly be configured in an options file. For example, an analysis options file that specifies

linter:
  rules:
    - avoid_as
analyzer:
  errors:
    avoid_as: error

tells the analyzer to treat avoid_as lints as errors. For more on configuring analysis see the analysis option file docs.

Contributing

Feedback is greatly appreciated and contributions are welcome! Please read the contribution guidelines; mechanics of writing lints are covered here.

Features and bugs

Please file feature requests and bugs in the issue tracker.

linter's People

Contributors

pq avatar bwilkerson avatar a14n avatar alexeieleusis avatar jpaulsen avatar srawlins avatar scheglov avatar stereotype441 avatar davidmorgan avatar dramos07 avatar michaelrfairhurst avatar devoncarew avatar kevmoo avatar krisgiesing avatar jawahars16 avatar matanlurey avatar dikmax avatar listepo avatar rokob avatar camsteffen avatar pylaligand avatar zanderso avatar aemino avatar nscobie avatar beroso avatar chalin avatar ochafik avatar manuelf avatar jaewookim0 avatar filiph avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.