Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Reported lines with errors are incorrect #128

Closed
martynhoyer opened this issue Sep 20, 2017 · 8 comments
Closed

Reported lines with errors are incorrect #128

martynhoyer opened this issue Sep 20, 2017 · 8 comments

Comments

@martynhoyer
Copy link

A bit of Googling has led me to believe this is an issue with the Stylelint SC processor...

I'm getting the following error:

4:3 ✖ Unknown word CssSyntaxError

On this file:

import { css } from 'styled-components'
import { transparentize } from 'polished'

export const focusState = css`outline: none;`

Not sure what's wrong there?

P.S. Don't judge me for disabling the default outline - I'm doing it responsibly! 😄

@mxstbr
Copy link
Member

mxstbr commented Sep 20, 2017

Can you try

export const focusState = css`
  outline: none;
`

Does that fix the issue?

@mxstbr mxstbr added the bug label Sep 20, 2017
@emilgoldsmith
Copy link
Member

Yeah I agree that it's probably our bug not any other software, can't see off the bat what the problem would be, but yeah, probably us at fault.

@martynhoyer
Copy link
Author

martynhoyer commented Sep 21, 2017

@mxstbr That doesn't help unfortunately, but we're using Prettier which I have formatting on save anyway, and we've got a Prettier (and linters) step in our CI which would fail the build as well (of course, I turned it off for this test).

I've also tried:

export const focusState = css`
  /* stylelint-disable */
  outline: none;
  /* stylelint-enable */
`

To no avail.

Interestingly, with that option the linter complains about line 8 8:3 ✖ Unknown word CssSyntaxError which is the line with the closing backtick.

If I take out the focusState declaration completely the linter still fails and claims line 2 is problematic... weird.

@martynhoyer
Copy link
Author

Aha! I've fixed it!

Further down the file I had:

const overlay = color => css`
  linear-gradient(to bottom, ${transparentize(0.9, color)}, ${transparentize(
  0.825,
  color
)})
`

Which I was using in other files like: background-image: ${hoverGradientOverlay()};

If I insert the background-image property into overlay, it fixes it:

const overlay = color => css`
  background-image: linear-gradient(
    to bottom,
    ${transparentize(0.9, color)},
    ${transparentize(0.825, color)}
  );
`

That's my mistake I guess, but the linter reporting the wrong line number is a bit of a pain.

Not sure if it's worth keeping the issue open for though?

@mxstbr
Copy link
Member

mxstbr commented Sep 21, 2017

That's my mistake I guess, but the linter reporting the wrong line number is a bit of a pain.

Yep, agreed. Again, would appreciate you adding this to the real-world tests so we can replicate the line issue at least!

@mxstbr mxstbr changed the title Unknown word CssSyntaxError Reported lines with errors are incorrect Sep 21, 2017
@mxstbr
Copy link
Member

mxstbr commented Sep 21, 2017

Another replication here: https://github.com/styled-components/stylelint-config-styled-components/issues/19

@Jmeyering would you mind also adding your code as a real world test case so we can fix the underlying issue? Thanks!

@Jmeyering
Copy link
Contributor

Added a breaking test case above

@mxstbr
Copy link
Member

mxstbr commented Sep 21, 2017

Awesome, thanks @Jmeyering! I currently don't have time to look into the issue, but the failing test should help any contributions to come in 😊

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

No branches or pull requests

4 participants