Skip to content
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 function-url-quotes autofix for double-slash comments in SCSS maps #6745

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-dolphins-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `function-url-quotes` autofix for double-slash comments in SCSS maps
13 changes: 13 additions & 0 deletions lib/rules/function-url-quotes/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,16 @@ testRule({
},
],
});

testRule({
ruleName,
config: ['always'],
customSyntax: 'postcss-scss',
fix: true,

accept: [
{
code: '$a: (\n // foo\n)',
},
],
});
3 changes: 3 additions & 0 deletions lib/rules/function-url-quotes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const functionArgumentsSearch = require('../../utils/functionArgumentsSearch');
const getAtRuleParams = require('../../utils/getAtRuleParams');
const getDeclarationValue = require('../../utils/getDeclarationValue');
const isStandardSyntaxUrl = require('../../utils/isStandardSyntaxUrl');
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration');
const optionsMatches = require('../../utils/optionsMatches');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
Expand Down Expand Up @@ -56,6 +57,8 @@ const rule = (primary, secondaryOptions, context) => {
* @param {import('postcss').Declaration} decl
*/
function checkDeclParams(decl) {
if (!isStandardSyntaxDeclaration(decl)) return;

const value = getDeclarationValue(decl);
const startIndex = declarationValueIndex(decl);
const parsed = functionArgumentsSearch(value, /^url$/i, (args, index, funcNode) => {
Expand Down