Files
react-native-devtools-frontend/node_modules/stylelint/lib/rules/selector-attribute-quotes/index.js
T
Tim van der Lippe 382089011b Run npm audit
This syncs our dependencies to the latest version. There is still
a reported vulnerability in postcss, but we are luckily unaffected.
However, we can't upgrade postcss yet, as stylelint requires it
and can not use postcss 8 yet:
https://github.com/stylelint/stylelint/issues/4942#issuecomment-823513767

Also updated manage_node_deps.py to not run the full install when
running `ls`, to allow for easier inspection of our dependency graph.

R=jacktfranklin@chromium.org

Bug: none
Change-Id: I1c9e4836fca25500e2e7277ec82b13bf2b881dca
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2887731
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-11 16:18:42 +00:00

95 lines
2.2 KiB
JavaScript

// @ts-nocheck
'use strict';
const getRuleSelector = require('../../utils/getRuleSelector');
const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule');
const parseSelector = require('../../utils/parseSelector');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const ruleName = 'selector-attribute-quotes';
const messages = ruleMessages(ruleName, {
expected: (value) => `Expected quotes around "${value}"`,
rejected: (value) => `Unexpected quotes around "${value}"`,
});
const acceptedQuoteMark = '"';
function rule(expectation, secondary, context) {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: expectation,
possible: ['always', 'never'],
});
if (!validOptions) {
return;
}
root.walkRules((ruleNode) => {
if (!isStandardSyntaxRule(ruleNode)) {
return;
}
if (!ruleNode.selector.includes('[') || !ruleNode.selector.includes('=')) {
return;
}
parseSelector(getRuleSelector(ruleNode), result, ruleNode, (selectorTree) => {
let selectorFixed = false;
selectorTree.walkAttributes((attributeNode) => {
if (!attributeNode.operator) {
return;
}
if (!attributeNode.quoted && expectation === 'always') {
if (context.fix) {
selectorFixed = true;
attributeNode.quoteMark = acceptedQuoteMark;
} else {
complain(
messages.expected(attributeNode.value),
attributeNode.sourceIndex + attributeNode.offsetOf('value'),
);
}
}
if (attributeNode.quoted && expectation === 'never') {
if (context.fix) {
selectorFixed = true;
attributeNode.quoteMark = null;
} else {
complain(
messages.rejected(attributeNode.value),
attributeNode.sourceIndex + attributeNode.offsetOf('value'),
);
}
}
});
if (selectorFixed) {
ruleNode.selector = selectorTree.toString();
}
});
function complain(message, index) {
report({
message,
index,
result,
ruleName,
node: ruleNode,
});
}
});
};
}
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;