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

Display linter rules with required boolean parameter #6100

Open
1 task done
egarson opened this issue Sep 20, 2024 · 1 comment
Open
1 task done

Display linter rules with required boolean parameter #6100

egarson opened this issue Sep 20, 2024 · 1 comment
Labels
from.page-issue Reported in a reader-filed concern

Comments

@egarson
Copy link

egarson commented Sep 20, 2024

Page URL

https://dart.dev/tools/linter-rules/avoid_classes_with_only_static_members.html

Page source

https://github.com/dart-lang/site-www/tree/main/src/content/tools/linter-rules/individual-rules.md

Describe the problem

I propose that the documentation for all linter rule "Usage" sections is misleading, because the rule is not activated without the boolean value following the key entry.

For example, here is the "Usage" section at the bottom of the avoid_classes_with_only_static_members rule:

    To enable the avoid_classes_with_only_static_members rule, add avoid_classes_with_only_static_members under linter > rules in your [analysis_options.yaml](https://dart.dev/tools/analysis) file:

        linter:
          rules:
            - avoid_classes_with_only_static_members

The problem is that without explicitly adding true to the end of the key, i.e. avoid_classes_with_only_static_members: true, the rule is not activated. Put another way, it is reasonable to assume that merely listing the value in the analysis_options.yaml file would be sufficient to activate it (as I mistakenly presumed).

Expected fix

I propose merely adding true to the end of every listed key_value. This would also imply that false is equally viable. Note that I would be happy to perform this rote task, presuming this change is deemed worthwhile.

Additional context

No response

I would like to fix this problem.

  • I will try and fix this problem on dart.dev.
@egarson egarson added the from.page-issue Reported in a reader-filed concern label Sep 20, 2024
@raul-sauco
Copy link

raul-sauco commented Sep 23, 2024

I have seen the same issue in the individual linter rule pages, such as:

https://dart.dev/tools/linter-rules/prefer_relative_imports#details

The example there is:

 linter:
   rules:
     - prefer_relative_imports

However, in the current Dart SDK version I am using:

Dart SDK version: 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"

This syntax no longer appears to work correctly, as it doesn't trigger lint errors for package imports. Updating the rule syntax to:

 linter:
   rules:
     - prefer_relative_imports: true

seems to resolve the issue. I think that earlier versions of the analyzer may have implicitly interpreted the first format correctly. However, it seems that newer versions of the Dart analyzer now require the boolean attribute to be explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from.page-issue Reported in a reader-filed concern
Projects
None yet
Development

No branches or pull requests

2 participants