rexios_lints 13.0.0 copy "rexios_lints: ^13.0.0" to clipboard
rexios_lints: ^13.0.0 copied to clipboard

A collection of the linting rules I use for Flutter/Dart projects and packages

example/example.dart

// ignore_for_file: document_ignores

import 'dart:async';
import 'dart:io';
import 'package:flutter/widgets.dart';

// ignore: prefer_single_quotes
const string = "";

Future<void> future() async {}

void unawaitedFutures() async {
  // ignore: unawaited_futures
  future();
  await future();
  unawaited(future());
}

@immutable
class UseSuperParametersBase {
  final int param;

  const UseSuperParametersBase(this.param);
}

@immutable
class UseSuperParameters extends UseSuperParametersBase {
  // ignore: use_super_parameters
  const UseSuperParameters(int param) : super(param);
}

void preferFinal() {
  // ignore: prefer_final_in_for_each
  for (var i in []) {
    print(i);
  }

  // ignore: prefer_final_locals
  var i = 0;
  print(i);
}

void preferAsyncAwait() async {
  // expect_lint: prefer_async_await
  await Future.value().then((_) {});
}

void preferTimestamps() {
  // expect_lint: prefer_timestamps
  DateTime.now();
  DateTime.timestamp();
}

void doNotUseRawPaths() {
  // expect_lint: do_not_use_raw_paths
  Directory('path/to/directory');
  // expect_lint: do_not_use_raw_paths
  File('path/to/file');
  // expect_lint: do_not_use_raw_paths
  Link('path/to/entity');

  // expect_lint: do_not_use_raw_paths
  Directory('path\\to\\directory');
  File('file.txt');

  // expect_lint: do_not_use_raw_paths
  Directory(r'path\to\directory');
}

// expect_lint: prefer_immutable_classes
class PreferImmutableClasses {
  final int value;

  PreferImmutableClasses(this.value);
}

@immutable
class ImmutableSupertype {
  const ImmutableSupertype();
}

class ImmutableSubclass extends ImmutableSupertype {
  final String asdf;

  const ImmutableSubclass(this.asdf);
}

class MutableSupertype {
  int value;

  MutableSupertype(this.value);
}

class MutableSubclass extends MutableSupertype {
  MutableSubclass(super.value);
}

void inlineContextLookups(BuildContext context) {
  final navigator = Navigator.of(context);
  navigator.pop();

  // expect_lint: inline_context_lookups
  Navigator.of(context).pop();

  final accessibleNavigation = MediaQuery.maybeAccessibleNavigationOf(context);
  print(accessibleNavigation);

  // expect_lint: inline_context_lookups
  print(MediaQuery.maybeAccessibleNavigationOf(context));
}
4
likes
160
points
2.07k
downloads

Publisher

verified publisherrexios.dev

Weekly Downloads

A collection of the linting rules I use for Flutter/Dart projects and packages

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

analyzer, analyzer_plugin, custom_lint, custom_lint_builder, flutter_lints, lints

More

Packages that depend on rexios_lints