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

Added control statement spacing linter #81 #82

Merged
merged 4 commits into from
Jul 24, 2018
Merged

Added control statement spacing linter #81 #82

merged 4 commits into from
Jul 24, 2018

Conversation

mmzoo
Copy link
Contributor

@mmzoo mmzoo commented Jul 18, 2018

/ Good
div = 'This is what the official slim documentation uses consistently'

/ Bad
div= 'This is not allowed by the linter.'
div=    'Neither is this'
div         = 'Neither is this'

Notice that this error can only occur with = but not with -

div - bad

/ Compiles to:
/ <div>- bad</div>

@sds sds merged commit d241a81 into sds:master Jul 24, 2018
@ermolaev
Copy link

Hi, it nice rule, but not work if using == https://github.com/slim-template/slim#output-without-html-escaping-

h1 == page_header(@page)

ControlStatementSpacing: Please add a space before and after the =

@mmzoo mmzoo deleted the control-spacing branch September 7, 2018 11:31
end

context 'control statement without element' do
let(:slim) { '= ok' }
Copy link

Choose a reason for hiding this comment

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

I notice this doesn't have any opinion on =ok which, according to my source files, does not seem to raise an error. In my opinion, = ok (with the space) should be enforced. Any opinions from the author or @sds?

Copy link
Contributor Author

@mmzoo mmzoo Oct 4, 2019

Choose a reason for hiding this comment

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

I consistently use the space as it's more readable. Slim's official snippets also keep that standard. I thought this was already enforced 😄

I just checked, you're right and it is not enforced, the following test fails (i.e. nothing is reported):

  context 'control statement without element and without space' do
    let(:slim) { '=ok' }

    it { should report_lint }
  end

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.

4 participants