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

Add InstanceVariable linter #241

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

emilong
Copy link

@emilong emilong commented Nov 12, 2021

Adds the InstanceVariable linter, which can be limited to partials only
(thus deprecating PartialInstanceVariable), but considers an instance
variable in any template to be an offense by default.

Also changed range behavior in both linters to highlight the instance
variables themselves. The previous behavior highlighted the start of the
variable to the end of the file.

Finally, added support for detecting class instance variables.

Resolves #240

Adds the InstanceVariable linter, which can be limited to partials only
(thus deprecating PartialInstanceVariable), but considers an instance
variable in any template to be an offense by default.

Also changed range behavior in both linters to highlight the instance
variables themselves. The previous behavior highlighted the start of the
variable to the end of the file.

Finally, added support for detecting class instance variables.
@emilong emilong marked this pull request as ready for review November 12, 2021 00:57
include LinterRegistry

class ConfigSchema < LinterConfig
property :partials_only, accepts: [true, false], default: false, reader: :partials_only?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
property :partials_only, accepts: [true, false], default: false, reader: :partials_only?
property :partials_only, accepts: [true, false], default: true, reader: :partials_only?

Instance variables in templates is the Rails default and those linters should follow Rails defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect instance variables in all templates?
2 participants