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

Browser prefixed properties report failures for `spaceAroundOperator` #433

Open
donotknow opened this Issue Sep 25, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@donotknow

donotknow commented Sep 25, 2017

Example failing unit test

Here is an example of a failing test (didn’t seem worth it for me to create a fork/PR because I didn’t figure out where/how I should assert and fix on the underlying postcss-values-parser side of the house):

            it('should not report on browser-prefixed properties', function () {
                const source = 'transition-property: opacity -webkit-filter;';

                return spec.parse(source, function (ast) {
                    const result = spec.linter.lint(options, ast.root.first);

                    expect(result).to.be.undefined;
                });
            });

More practical failing test

.lesshintrc

{
    "spaceAroundOperator": {
        "enabled": true,
        "severity": "error",
        "style": "both"
    }
}

style.less

.my-thing {
	opacity: 0.5;
	-webkit-filter: blur(8px);
	filter: blur(8px);
	transition: opacity -webkit-filter 0.5s ease-out;
	transition-property: opacity filter;
}
.my-thing.transition {
	opacity: 0.5;
	-webkit-filter: blur(0);
	filter: blur(0);
}
Error: style.less: line 5, col 22, spaceAroundOperator: Operators should be preceded and followed by one space.

├─┬ lesshint@4.1.2
│ └── postcss-values-parser@1.2.2 
@donotknow

This comment has been minimized.

Show comment
Hide comment
@donotknow

donotknow Sep 25, 2017

Let me know if you have any ideas on where the fix would be (in postcss-values-parser or otherwise), I can poke around and submit a PR. My first instinct was word under postcss-values-parser but that seemed to work fine in my assertions.

donotknow commented Sep 25, 2017

Let me know if you have any ideas on where the fix would be (in postcss-values-parser or otherwise), I can poke around and submit a PR. My first instinct was word under postcss-values-parser but that seemed to work fine in my assertions.

@donotknow

This comment has been minimized.

Show comment
Hide comment
@donotknow

donotknow Sep 25, 2017

(Also somewhat related to #222 and #179)

donotknow commented Sep 25, 2017

(Also somewhat related to #222 and #179)

@jwilsson

This comment has been minimized.

Show comment
Hide comment
@jwilsson

jwilsson Sep 26, 2017

Member

Hi!
Thanks for the thorough report and for using the template!

I think the issue lies in postcss-values-parser. It seems to work if the prefixed value is first in the list. But when it's the second (or further down) it's parsing the - as an operator node instead as part of the word node.

I'll file an issue over there.

Member

jwilsson commented Sep 26, 2017

Hi!
Thanks for the thorough report and for using the template!

I think the issue lies in postcss-values-parser. It seems to work if the prefixed value is first in the list. But when it's the second (or further down) it's parsing the - as an operator node instead as part of the word node.

I'll file an issue over there.

donotknow added a commit to donotknow/lesshint that referenced this issue Feb 17, 2018

fix: check +5 numbers for spaceAroundOperator (#433)
Update lesshint to work with shellscape/postcss-values-parser#45, which
will return a number for +5 instead of an operator and a number.

So, check both operators and numbers, ignore any numbers that don’t
start with an operator (+-*/), allow the node to be the last node (no
nextElement), and use a whitespace regex to check the none spacing
instead of the exact value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment