Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Nov 20, 2024. It is now read-only.
/linterPublic archive

Linter for Dart.

License

NotificationsYou must be signed in to change notification settings

dart-archive/linter

Repository files navigation

The Dart linter is now developed within theDart SDK repository,and can be found athttps://github.com/dart-lang/sdk/tree/main/pkg/linter.

To contribute changes, check out theSDK contribution guide.


The Dart Linter package defines lint rules that identify and report on "lints" found in Dart code. Linting is performed by the Dartanalysis server and thedart analyze command in theDart command-line tool.

Build StatusCoverage StatusOpenSSF Scorecard

Installing

The linter is bundled with the DartSDK; 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 thelinter 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 publishedDart Style Guide. Enforceable lint rules (or "lints") are catalogedhere and can be configured via ananalysis options file. The linter is run from within thedart analyzecommand-line tool shipped with theDart SDK. Assuming you have lints configured in ananalysis_options.yaml file at the root of your project with these contents:

linter:rules:    -annotate_overrides    -hash_and_equals    -prefer_is_not_empty

you could lint your package like this:

$ dart analyze .

and see any violations of theannotate_overrides,hash_and_equals, andprefer_is_not_empty rules in the console.To help you choose the rules you want to enable for your package, we have provided acomplete list of ruleswith lints recommended by the Dart team collected inpackage:lints. Lints recommended for Flutter apps, packages,and plugins are documented inpackage:flutter_lints.

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

// ignore: camel_case_typesclass whyOhWhy { }

tells the Dart analyzer to ignore this instance of thecamel_case_types warning.

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

class whyOhWhy {// ignore: camel_case_types

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

// ignore_for_file: camel_case_types...class whyOhWhy { }

tells the Dart analyzer to ignore all occurrences of thecamel_case_types 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. Forexample, an analysis options file that specifies

linter:rules:    -camel_case_typesanalyzer:errors:camel_case_types:error

tells the analyzer to treatcamel_case_types lints as errors. For more on configuring analysis see the analysis option filedocs.

Contributing

Feedback is greatly appreciated and contributions are welcome! Please read thecontribution guidelines; mechanics of writing lints are coveredhere.

Features and bugs

Please file feature requests and bugs in theissue tracker.


[8]ページ先頭

©2009-2025 Movatter.jp