Skip to content
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

Lint for lowerCamelCase non-constant identifiers (Style Guide). #16

Closed
pq opened this issue Feb 10, 2015 · 13 comments
Closed

Lint for lowerCamelCase non-constant identifiers (Style Guide). #16

pq opened this issue Feb 10, 2015 · 13 comments
Labels
lint-request type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Feb 10, 2015

DO name non-constant identifiers using lowerCamelCase.

Class members, top-level definitions, variables, parameters, and named parameters should capitalize the first letter of each word except the first word, and use no separators.

GOOD:

var item;

HttpRequest httpRequest;

align(clearItems) {
  // ...
}
@pq pq added the type-enhancement A request for a change that isn't a bug label Feb 10, 2015
@pq pq added the style label Feb 25, 2015
@pq pq added the started label Mar 5, 2015
@pq pq closed this as completed in 03e992e Mar 5, 2015
@zoechi
Copy link

zoechi commented Mar 6, 2015

This should also be supported for constants but as a separate rule to make it possible to disable it for constants.

@pq
Copy link
Member Author

pq commented Mar 6, 2015

Absolutely. Opened #42 to track.

Also, exploring minimal configuration in #41.

@mathieujobin
Copy link

is it possible to configure the linter to disagree with this rule and instead force the use of snake_case everywhere?

http://dart-lang.github.io/linter/lints/non_constant_identifier_names.html

@bwilkerson
Copy link
Member

There isn't currently any support for configuring the linter other than to enable or disable rules. If there were a rule to enforce the use of snake_case, then you could enable it and disable the other identifier-related rules (all rules are disabled by default, so disabling a rule amounts to not enabling it). However, there isn't such a rule at this time.

@mathieujobin
Copy link

Thank you Brian,

@mathieujobin
Copy link

@bwilkerson I just realized, a year later...

when you say no rules are enabled by default, that's probably true for this linter and maybe for dart.
but Flutter enforce that rule by default. I guess I should enter an issue with Flutter.
I wish they would not enable this by default

@mathieujobin
Copy link

created issue flutter/flutter#34532

@bwilkerson
Copy link
Member

As I understand it, Flutter doesn't enable any lint rules by default either. But when you create a flutter project many tools will create an analysis options file that includes the options from a Flutter supplied analysis options file.

In any case, you can control which lint rules are enabled by creating an analysis options file in your package that specifies which rules to enable. If you already have an options file that uses include to add the options that Flutter recommends, you can either remove that line, or, if you want most of what it provides, you can override the included setting for this one lint rule (see https://dart.dev/guides/language/analysis-options#ignoring-rules for instructions).

@Angeloem
Copy link

As I understand it, Flutter doesn't enable any lint rules by default either. But when you create a flutter project many tools will create an analysis options file that includes the options from a Flutter supplied analysis options file.

In any case, you can control which lint rules are enabled by creating an analysis options file in your package that specifies which rules to enable. If you already have an options file that uses include to add the options that Flutter recommends, you can either remove that line, or, if you want most of what it provides, you can override the included setting for this one lint rule (see https://dart.dev/guides/language/analysis-options#ignoring-rules for instructions).

It does, using flutter 2.5....

I have disabled the lint but it still shows up.. Now in my organisation we have a SCREAMING_CASE convention for constants

@pq
Copy link
Member Author

pq commented Oct 28, 2021

I have disabled the lint but it still shows up...

That suggests a configuration error or a bug on our side. If you want to follow-up with more details (your options file contents, the structure of your project and code that is triggering the lint), we can help sort out what's happening.

@Angeloem
Copy link

Oh thank you!

I got it to work by disabling that lint for the constants file. and it works, although its not as good as disabling from the analysis_options.yaml

@EnglishDave
Copy link

How did you manage to disable it for a file? What rule name did you use? I have tried adding
// ignore_for_file: lower_camel_case_constants
(as suggested in some otehr posts) to the top of the file and it has no effect.

@pq
Copy link
Member Author

pq commented Sep 20, 2022

How did you manage to disable it for a file? What rule name did you use?

For this I think you'd want:

// ignore_for_file: non_constant_identifier_names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants