-
-
Notifications
You must be signed in to change notification settings - Fork 930
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
Fix tests for function-calc-no-invalid #4533
Comments
PR with changes to tests to highlight the issues: #4534 |
Thank you for the report.
Each rule is reporting exact violations that is described in the doc: I think it's good idea to fix syntax in tests to valid. |
Agreed. |
@LolliDepp Thanks for the report. OK, it took a little while to work through this so let's break it down:
As @fanich37 said, stylelint doesn't check the validity of non-standard syntax. If the postcss-less parser can parse it, stylelint will run its rules against it.
I can't replicate this. % echo "@myVar: 100px; a { width: @myVar; }" | npx stylelint --syntax less --formatter verbose
1 source checked
<input css 1>
0 problems found
Yes, you're totally right. We should probably revisit all our Less tests to make sure we're not making similar mistakes elsewhere. I don't believe any of the core contributors use Less anymore so we rely on the help of outside contributors to support Less. I've focused this issue on the incorrect syntax in the tests as I think the other parts of the issue are duplicated in #4114. |
@jeddy3 I guess this can be closed? (rule removed) |
Yep. We need to go through all the open issues and close those that are no longer relevant now that 14.0.0 is out. I'll try to make time for it some weekend soon. |
@glen-84 Feel free to close them yourself too. I think you have permission to do so as a contributor. We can always reopen them if they're closed by mistake. |
@jeddy3 I don't have permission. I just noticed these two while reading through the changelog. |
With
function-calc-no-invalid
there is a false positive, while invalid syntax is allowed.function-calc-no-invalid
This is valid LESS and should be accepted.
This is invalid LESS, but gets flagged as correct.
More than this, the second scenario is used as a positive test case for that rule!
So that's definitely broken.
Stick the LESS in here to verify: https://lesstester.com/
12.0.1
VSCode extension running it on the currently open file:
stuartzhang.stylelint-stzhang
Yes, it's related to LESS variables
No warnings to be flagged with the valid syntax, warnings flagged with invalid syntax.
I also expect the test cases on the project to not explicitly allow invalid syntax.
Invalid syntax is not flagged, valid syntax is flagged.
Unit tests are wrong.
stylelint/lib/rules/function-calc-no-invalid/__tests__/index.js
Line 380 in d3c4a9f
That line that is in the list of syntax to parse as valid makes no sense at all, it's just not valid LESS.
@{my-var} is for interpolation in properties names, class name, and internal to string values.
@my-var is for using variables as values for properties.
stylelint/lib/rules/function-calc-no-invalid/__tests__/index.js
Line 426 in d3c4a9f
This line that is in the list of syntax to parse with errors should be parsed with errors, but not with the
function-calc-no-invalid
error. The error you're supposed to get is "Right curly bracket expected but not found". It just doesn't make any sense and should probably trigger a bunch of errors.Working on a PR with fixed tests...
The text was updated successfully, but these errors were encountered: