question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix false positives for hyphenated functions in function-calc-no-unspaced-operator

See original GitHub issue

Clearly describe the bug

Vue officially released the v-bind grammar in v3.2.2 to support js and facilitate the use of js variables in css. This grammar will conflict with the function-calc-no-unspaced-operator rule in calc(). I checked this The configured rule has only a switch. If you want the editor not to report an error, you can only close the rule globally or use the Ignoring code. I personally feel that v-bind will be used frequently in future vue projects. The above two methods are not very good solutions. Maybe you can add a configuration item to filter some regular or string in the rule.

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

function-calc-no-unspaced-operator

What code is needed to reproduce the bug?

.box {
      height: calc(100% - v-bind('cssVars.layoutHeaderHeight'));
}

What stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "function-calc-no-unspaced-operator":  true
  }
}

Which version of stylelint are you using?

v13.13.1

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

e.g. “CLI with stylelint "**/*.css" --config myconfig.json

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

Related to v-bind syntax of vue v3.2.x

What did you expect to happen?

e.g. “No warnings to be flagged.”

What actually happened (e.g. what warnings or errors did you get)?

image

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
lachiehcommented, Oct 19, 2021

I ended up making the change I mentioned above and the PR is ready for review 👍🏻

0reactions
lachiehcommented, Oct 22, 2021

I think I’m 80% of the way there on this one.

One issue I’m having is to do with this test:

{
	code: 'a { top: calc(2rem + @fh+d*sf-as); }',
	description: 'Less variable with symbols',
},

The AST is interpreted like this:

[
	{ type: "word", sourceIndex: 5, value: "2rem", },
	{ type: "space", sourceIndex: 9, value: " ", },
	{ type: "word", sourceIndex: 10, value: "+", },
	{ type: "space", sourceIndex: 11, value: " ", },
	{ type: "word", sourceIndex: 12, value: "@fh+d", },
	{ type: "word", sourceIndex: 17, value: "*", },
	{ type: "word", sourceIndex: 18, value: "sf-as", },
]

I can check if the word Node starts with an @ symbol and then just skip it, but it feels like that may cause issues. I noticed in the current version the variables are being blurred into a 0 character but that will modify the AST when ‘fixing’ the content at the end.

Thoughts?

Edit: The variable above is actually invalid for a less variable so this check is unnecessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Composer packages with hyphen not resolved to correct CPE
The algorithm used does produce false positives - but in an attempt to reduce false negatives. There are better ways of writing the...
Read more >
C# S1172 and S1854 - False positives with local functions ...
Trying to narrow down a FP found in a relatively complex method, I managed to reproduce two FPs with the following code: private...
Read more >
Cochrane Style Manual Common terms and terminology
Note: 'time point' should be written as two separate words (see below) ... false negative, false positive, true negative, true positive (when used...
Read more >
Hyphens - The Writing Center @ KUMC
Hyphens connect words, prefixes, and suffixes permanently or ... The test results were false-positive; the false-positive results were recorded.
Read more >
Fix text hyphenation - Microsoft Support
You can fix hyphenation manually in a Publisher publication by using the Hyphenation command on the Format tab.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found