rspec/rules/S115/dart/rule.adoc

63 lines
1.3 KiB
Plaintext

== Why is this an issue?
include::../common/why-is-this-an-issue.adoc[]
In Dart, the convention is that constant identifier names should be in camel case and start with a lowercase.
=== What is the potential impact?
include::../common/what-is-the-potential-impact.adoc[]
== How to fix it
Update the name of the constant to match the convention (lowerCamelCase), as well as all usages of the name.
For many IDEs, you can use built-in renaming and refactoring features to update all usages of a constant at once.
=== Code examples
==== Noncompliant code example
[source,dart,diff-id=1,diff-type=noncompliant]
----
class MyClass {
const PI = 3.14159; // Noncompliant
const MY_CONSTANT = 42; // Noncompliant
}
----
==== Compliant solution
[source,dart,diff-id=1,diff-type=compliant]
----
class MyClass {
const pi = 3.14159;
const myConstant = 42;
}
----
== Resources
* Dart Docs - https://dart.dev/tools/linter-rules/constant_identifier_names[Dart Linter rule - constant_identifier_names]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* The constant name '<constantIdentifier>' isn't a lowerCamelCase identifier.
=== Highlighting
The constant identifier.
'''
== Comments And Links
(visible only on this page)
include::../common/comments-and-links.adoc[]
endif::env-github,rspecator-view[]