All Projects → fluttercommunity → import_sorter

fluttercommunity / import_sorter

Licence: MIT license
🎯 Automatically organize your dart imports. Maintainer: @gleich

Programming Languages

dart
5743 projects
swift
15916 projects
HTML
75241 projects

Projects that are alternatives of or similar to import sorter

puppet-ghostbuster
👻 Dead code detector for Puppet
Stars: ✭ 83 (-34.65%)
Mutual labels:  code-quality
TSLint.MSBuild
[Deprecated] An MSBuild task for running TSLint.
Stars: ✭ 13 (-89.76%)
Mutual labels:  code-quality
understanding-the-python-ecosystem
This project focuses on understanding the language ecosystem
Stars: ✭ 68 (-46.46%)
Mutual labels:  code-quality
stash
Key-value store abstraction with plain and cache driven semantics and a pluggable backend architecture.
Stars: ✭ 71 (-44.09%)
Mutual labels:  dart-package
Flogs
An Advanced Logging Framework develop in flutter that provides quick & simple logging solution.
Stars: ✭ 158 (+24.41%)
Mutual labels:  dart-package
flake8-aaa
A Flake8 plugin that checks Python tests follow the Arrange-Act-Assert pattern
Stars: ✭ 51 (-59.84%)
Mutual labels:  code-quality
spellcheck-action
GitHub Action for checking code & Pull Requests for spelling mistakes
Stars: ✭ 35 (-72.44%)
Mutual labels:  code-quality
detekt-hint
Detection of design principle violations in Kotlin as a plugin to detekt.
Stars: ✭ 63 (-50.39%)
Mutual labels:  code-quality
python-test-reporter
DEPRECATED Uploads Python test coverage data to Code Climate
Stars: ✭ 18 (-85.83%)
Mutual labels:  code-quality
surveyor
📐 Tools for surveying Dart packages
Stars: ✭ 40 (-68.5%)
Mutual labels:  dart-package
elm-review
Analyzes Elm projects, to help find mistakes before your users find them.
Stars: ✭ 195 (+53.54%)
Mutual labels:  code-quality
material-color-utilities
Color libraries for Material You
Stars: ✭ 605 (+376.38%)
Mutual labels:  dart-package
flake8-simplify
❄ A flake8 plugin that helps you to simplify code
Stars: ✭ 97 (-23.62%)
Mutual labels:  code-quality
eslint-plugin-import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 4,290 (+3277.95%)
Mutual labels:  code-quality
codeclimate-phpcodesniffer
Code Climate Engine for PHP Code Sniffer
Stars: ✭ 27 (-78.74%)
Mutual labels:  code-quality
checksync
A tool for detecting when related text blocks change
Stars: ✭ 14 (-88.98%)
Mutual labels:  code-quality
sonarqube-action
Integrate SonarQube scanner to GitHub Actions
Stars: ✭ 90 (-29.13%)
Mutual labels:  code-quality
pub updater
A Dart package which supports checking if a current package is up-to-date.
Stars: ✭ 43 (-66.14%)
Mutual labels:  dart-package
jdepend
A Java package dependency analyzer that generates design quality metrics.
Stars: ✭ 13 (-89.76%)
Mutual labels:  code-quality
jacoco-report
Github action that publishes the JaCoCo report as a comment in the Pull Request
Stars: ✭ 31 (-75.59%)
Mutual labels:  code-quality
 ___  _____ ______   ________  ________  ________  _________
|\  \|\   _ \  _   \|\   __  \|\   __  \|\   __  \|\___   ___\
\ \  \ \  \\\__\ \  \ \  \|\  \ \  \|\  \ \  \|\  \|___ \  \_|
 \ \  \ \  \\|__| \  \ \   ____\ \  \\\  \ \   _  _\   \ \  \
  \ \  \ \  \    \ \  \ \  \___|\ \  \\\  \ \  \\  \|   \ \  \
   \ \__\ \__\    \ \__\ \__\    \ \_______\ \__\\ _\    \ \__\
    \|__|\|__|     \|__|\|__|     \|_______|\|__|\|__|    \|__|
    ________  ________  ________  _________  _______   ________
   |\   ____\|\   __  \|\   __  \|\___   ___\\  ___ \ |\   __  \
   \ \  \___|\ \  \|\  \ \  \|\  \|___ \  \_\ \   __/|\ \  \|\  \
    \ \_____  \ \  \\\  \ \   _  _\   \ \  \ \ \  \_|/_\ \   _  _\
     \|____|\  \ \  \\\  \ \  \\  \|   \ \  \ \ \  \_|\ \ \  \\  \|
       ____\_\  \ \_______\ \__\\ _\    \ \__\ \ \_______\ \__\\ _\
      |\_________\|_______|\|__|\|__|    \|__|  \|_______|\|__|\|__|
      \|_________|

Request for a Maintainer

This project needs a maintainer as I no longer work with dart and flutter. Please see the issue thread for more information.

import_sorter Pub Version

Flutter Community: import_sorter

test format

🎯 Dart package to automatically organize your dart imports. Any dart project supported! Will sorts imports alphabetically and then group them in the following order:

  1. Dart imports
  2. Flutter imports
  3. Package imports
  4. Project imports

Below is an example:

Before

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/physics.dart';
import 'package:flutter/painting.dart';
import 'package:intl/intl.dart';
import 'package:mdi/mdi.dart';
import 'package:provider/provider.dart';
import 'anotherFile.dart';
import 'package:example_app/anotherFile2.dart';
import 'dart:async';
import 'dart:io';
import 'dart:js';

After

// Dart imports:
import 'dart:async';
import 'dart:io';
import 'dart:js';

// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/physics.dart';

// Package imports:
import 'package:intl/intl.dart';
import 'package:mdi/mdi.dart';
import 'package:provider/provider.dart';

// Project imports:
import 'package:example_app/anotherFile2.dart';
import 'anotherFile.dart';

🚀 Installing

Simply add import_sorter: ^4.6.0 to your pubspec.yaml's dev_dependencies.

🏃‍♂️ Running

Once you've installed it simply run flutter pub run import_sorter:main (pub run import_sorter:main if normal dart application) to format every file dart file in your lib, bin, test, and tests folder! Don't worry if these folders don't exist.

💻 Command Line

  • Add the -e flag to the run command and have emojis added to your imports 😄.
  • If you're using a config in the pubspec.yaml you can have the program ignore it by adding --ignore-config.
  • Want to make sure your files are sorted? Add --exit-if-changed to make sure the files are sorted. Good for things like CI.
  • Have no comments before your imports by adding the --no-comments flag.
  • Add the -h flag if you need any help from the command line!
  • You can only run import_sorter on certain files by passing in a regular expression(s) that will only sort certain files. Below are two examples:
    • pub run import_sorter:main bin/main.dart lib/args.dart (only sorts bin/main.dart and lib/args.dart)
    • pub run import_sorter:main lib\/* test\/* (only sorts files in the lib and test folders)

🏗️ Config

If you use import_sorter a lot or need to ignore certain files you should look at using the config you put in your pubspec.yaml. Ignored files are in the format of regex. This regex is then applied to the project root path (the one outputted to the terminal). Below is an example config setting emojis to true and ignoring all files in the lib folder:

import_sorter:
  emojis: true # Optional, defaults to false
  comments: false # Optional, defaults to true
  ignored_files: # Optional, defaults to []
    - \/lib\/*

If you need another example check the example app's import_sorter configuration.

🚨 pre-commit Hook

There are two pre-commit hooks available: dart-import-sorter and flutter-import-sorter. They use pub run and flutter pub run respectively. Use the former for a generic Dart project and the latter for a Flutter project.

Using pre-commit hooks in your project:

  • Install and configure pre-commit.
  • Install and configure import_sorter using instructions above.
  • Add the following to the repos section of your .pre-commit-config.yaml:
- repo: https://github.com/fluttercommunity/import_sorter
  rev: 'master'
  hooks:
    - id: dart-import-sorter # use `flutter-import-sorter` for a Flutter project
  • Run initial sort:
pre-commit run --all-files

🙋‍♀️🙋‍♂️ Contributing

All contributions are welcome! Just make sure that it's not an already existing issue or pull request.

👥 Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].