Stylelint: Fix false positives for style attributes in no-missing-end-of-source-newline

Created on 21 Jun 2018  路  1Comment  路  Source: stylelint/stylelint

Since version 9.3.0 (not in version 9.2.1), the rule 'no-missing-end-of-source-newline' is provoking strange behavior in my code.

 <v-layout
      :class="serviceStatusClass"
      style="flex:0;"
      class="table-row"
      row>

becomes

<v-layout
      :class="serviceStatusClass"
      style="flex:0;
"
      class="table-row"
      row>

Which rule, if any, is the bug related to?

no-missing-end-of-source-newline

What stylelint configuration is needed to reproduce the bug?

nothing particular

Which version of stylelint are you using?

I was in 9.2.1. I pass in 9.3.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

e.g. "CLI with stylelint src/**/*.vue src/**/*.css src/**/*.scss"

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

in Vue component

What did you expect to happen?

"No problem to be flagged and no autofix ."

Most helpful comment

@trollepierre Thanks for the report and for using the template.

As a way of an explanation...

Historically, there has been a 1 to 1 mapping with what we call a "source" and a file on the file system. This assumption is no longer valid with the introduction of syntaxes that extract multiple sources from within files e.g. from style attributes within .vue files. I think the way these syntaxes work is correct, though. As such, not all rules/plugins will be applicable to all syntaxes.

It's the responsibility of the user to configure stylelint accordingly. Turning on only rules that are applicable to the syntaxes they are linting. The introduction of an overrides property within the configuration object, as proposed in https://github.com/stylelint/stylelint/issues/3128, would help give users the control to do this on a more granular level.

@trollepierre Sorry about the unexpected change in behaviour. It was an unintended side effect of our ongoing work to support linting CSS within things like .vue files. Until the overrides feature is added you can either:

  1. turn off the rule entirely i.e. no-missing-end-of-source-newline: null
  2. use this workaround to turn the rule off for just .vue files.

It feels like the need for a overrides property is more pressing now, so feel free to jump into that issue if you've time to help contribute it.

>All comments

@trollepierre Thanks for the report and for using the template.

As a way of an explanation...

Historically, there has been a 1 to 1 mapping with what we call a "source" and a file on the file system. This assumption is no longer valid with the introduction of syntaxes that extract multiple sources from within files e.g. from style attributes within .vue files. I think the way these syntaxes work is correct, though. As such, not all rules/plugins will be applicable to all syntaxes.

It's the responsibility of the user to configure stylelint accordingly. Turning on only rules that are applicable to the syntaxes they are linting. The introduction of an overrides property within the configuration object, as proposed in https://github.com/stylelint/stylelint/issues/3128, would help give users the control to do this on a more granular level.

@trollepierre Sorry about the unexpected change in behaviour. It was an unintended side effect of our ongoing work to support linting CSS within things like .vue files. Until the overrides feature is added you can either:

  1. turn off the rule entirely i.e. no-missing-end-of-source-newline: null
  2. use this workaround to turn the rule off for just .vue files.

It feels like the need for a overrides property is more pressing now, so feel free to jump into that issue if you've time to help contribute it.

Was this page helpful?
0 / 5 - 0 ratings