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 StrictLocals linter #553

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Add StrictLocals linter #553

merged 2 commits into from
Feb 24, 2025

Conversation

wilfison
Copy link
Contributor

StrictLocals

Checks for the presence of a locals magic comment at the beginning of a file. Read more about this in the Ruby on Rails Guides on why it is good practice to define local variables at the beginning of the file.

Bad:

%h1= title

Good

-# locals: (title:)

%h1= title

The new linter follows the same settings as InstanceVariables as designed by @mockdeep in #486

  StrictLocals:
    enabled: true
    file_types: partials
    matchers:
      all: .*
      partials: \A_.*\.haml\z

Close #486

Copy link
Owner

@sds sds left a comment

Choose a reason for hiding this comment

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

Looks great—thank you. Will adjust the default to be disabled so this doesn't come as a surprise to existing users.

@@ -102,6 +102,13 @@ linters:
enabled: true
style: space

StrictLocals:
enabled: true
Copy link
Owner

Choose a reason for hiding this comment

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

I would suggest disabling this by default, since it seems like a relatively invasive change for existing codebases.

@sds sds enabled auto-merge (squash) February 24, 2025 21:41
@sds sds merged commit 3c12b64 into sds:main Feb 24, 2025
34 checks passed
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.

Feature Suggestion: require strict locals
2 participants