Skip to content

Lint class structure best practices for fields #57359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
keaner opened this issue Jul 27, 2016 · 2 comments
Closed

Lint class structure best practices for fields #57359

keaner opened this issue Jul 27, 2016 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-request type-enhancement A request for a change that isn't a bug

Comments

@keaner
Copy link

keaner commented Jul 27, 2016

This is basically an extension of http://dart-lang.github.io/linter/lints/sort_constructors_first.html

It'd be great to lint for fields showing up before constructors.

Good

class MyClass {
  String publicString = 'hello';
  String _privateString;

  const MyClass(this._privateString);

  String get privateString => _privateString;
}

Bad

class MyClass {
  const MyClass(this._privateString);

  String get privateString => _privateString;

  String publicString = 'hello';
  String _privateString;
}
@pq pq added type-enhancement A request for a change that isn't a bug linter-lint-request labels Jul 27, 2016
@srawlins
Copy link
Member

srawlins commented Jan 4, 2019

+1. What are the specifics?

  1. First, public static fields
  2. Then, private static fields
  3. Then, public instance fields
  4. Then, private instance fields

Is that right? What about const things? Maybe const doesn't play a role?

Also, I'd strongly suggest not implementing anything about alphabetical order. While that might have benefits, I'd separate it from this ordering lint.

@srawlins
Copy link
Member

srawlins commented Aug 1, 2024

Closing as a duplicate of #58283, which is newer, but has more discussion.

@srawlins srawlins closed this as completed Aug 1, 2024
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants