first commit
This commit is contained in:
116
node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.cjs
generated
vendored
Normal file
116
node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// NOTICE: This file is generated by Rollup. To modify it,
|
||||
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
|
||||
'use strict';
|
||||
|
||||
const valueParser = require('postcss-value-parser');
|
||||
const hasPrefix = require('../../utils/hasPrefix.cjs');
|
||||
const isAutoprefixable = require('../../utils/isAutoprefixable.cjs');
|
||||
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration.cjs');
|
||||
const isStandardSyntaxProperty = require('../../utils/isStandardSyntaxProperty.cjs');
|
||||
const optionsMatches = require('../../utils/optionsMatches.cjs');
|
||||
const report = require('../../utils/report.cjs');
|
||||
const ruleMessages = require('../../utils/ruleMessages.cjs');
|
||||
const setDeclarationValue = require('../../utils/setDeclarationValue.cjs');
|
||||
const validateOptions = require('../../utils/validateOptions.cjs');
|
||||
const vendor = require('../../utils/vendor.cjs');
|
||||
const validateTypes = require('../../utils/validateTypes.cjs');
|
||||
|
||||
const ruleName = 'value-no-vendor-prefix';
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (value) => `Unexpected vendor-prefix "${value}"`,
|
||||
});
|
||||
|
||||
const meta = {
|
||||
url: 'https://stylelint.io/user-guide/rules/value-no-vendor-prefix',
|
||||
fixable: true,
|
||||
};
|
||||
|
||||
/** @type {import('stylelint').CoreRules[ruleName]} */
|
||||
const rule = (primary, secondaryOptions) => {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(
|
||||
result,
|
||||
ruleName,
|
||||
{ actual: primary },
|
||||
{
|
||||
optional: true,
|
||||
actual: secondaryOptions,
|
||||
possible: {
|
||||
ignoreValues: [validateTypes.isString, validateTypes.isRegExp],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {string | RegExp} IgnoreValue
|
||||
* @type {{ raw: IgnoreValue[], unprefixed: IgnoreValue[] }}
|
||||
* @todo use Object.groupBy once Node v20 support is dropped
|
||||
*/
|
||||
const groups = { raw: [], unprefixed: [] };
|
||||
|
||||
[secondaryOptions?.ignoreValues ?? []].flat().forEach((value) => {
|
||||
const useRawValue = validateTypes.isRegExp(value) || (value.startsWith('/') && value.match(/\/i?$/));
|
||||
const group = useRawValue ? 'raw' : 'unprefixed';
|
||||
|
||||
groups[group].push(value);
|
||||
});
|
||||
|
||||
root.walkDecls((decl) => {
|
||||
const { value } = decl;
|
||||
|
||||
if (!hasPrefix(value)) return;
|
||||
|
||||
if (!isStandardSyntaxDeclaration(decl) || !isStandardSyntaxProperty(decl.prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (optionsMatches(groups, 'raw', value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo consolidate in the next major
|
||||
* @see stylelint/stylelint#7542
|
||||
*/
|
||||
if (optionsMatches(groups, 'unprefixed', vendor.unprefixed(value))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedValue = valueParser(value);
|
||||
|
||||
parsedValue.walk((node) => {
|
||||
if (!isAutoprefixable.propertyValue(node.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = decl.prop.length + (decl.raws.between || '').length + node.sourceIndex;
|
||||
const fix = () => {
|
||||
node.value = isAutoprefixable.unprefix(node.value);
|
||||
setDeclarationValue(decl, parsedValue.toString());
|
||||
};
|
||||
|
||||
report({
|
||||
message: messages.rejected,
|
||||
messageArgs: [node.value],
|
||||
node: decl,
|
||||
index,
|
||||
endIndex: index + node.value.length,
|
||||
result,
|
||||
ruleName,
|
||||
fix,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
rule.ruleName = ruleName;
|
||||
rule.messages = messages;
|
||||
rule.meta = meta;
|
||||
|
||||
module.exports = rule;
|
||||
113
node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.mjs
generated
vendored
Normal file
113
node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import valueParser from 'postcss-value-parser';
|
||||
|
||||
import hasPrefix from '../../utils/hasPrefix.mjs';
|
||||
import isAutoprefixable from '../../utils/isAutoprefixable.mjs';
|
||||
import isStandardSyntaxDeclaration from '../../utils/isStandardSyntaxDeclaration.mjs';
|
||||
import isStandardSyntaxProperty from '../../utils/isStandardSyntaxProperty.mjs';
|
||||
import optionsMatches from '../../utils/optionsMatches.mjs';
|
||||
import report from '../../utils/report.mjs';
|
||||
import ruleMessages from '../../utils/ruleMessages.mjs';
|
||||
import setDeclarationValue from '../../utils/setDeclarationValue.mjs';
|
||||
import validateOptions from '../../utils/validateOptions.mjs';
|
||||
import vendor from '../../utils/vendor.mjs';
|
||||
|
||||
import { isRegExp, isString } from '../../utils/validateTypes.mjs';
|
||||
|
||||
const ruleName = 'value-no-vendor-prefix';
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (value) => `Unexpected vendor-prefix "${value}"`,
|
||||
});
|
||||
|
||||
const meta = {
|
||||
url: 'https://stylelint.io/user-guide/rules/value-no-vendor-prefix',
|
||||
fixable: true,
|
||||
};
|
||||
|
||||
/** @type {import('stylelint').CoreRules[ruleName]} */
|
||||
const rule = (primary, secondaryOptions) => {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(
|
||||
result,
|
||||
ruleName,
|
||||
{ actual: primary },
|
||||
{
|
||||
optional: true,
|
||||
actual: secondaryOptions,
|
||||
possible: {
|
||||
ignoreValues: [isString, isRegExp],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {string | RegExp} IgnoreValue
|
||||
* @type {{ raw: IgnoreValue[], unprefixed: IgnoreValue[] }}
|
||||
* @todo use Object.groupBy once Node v20 support is dropped
|
||||
*/
|
||||
const groups = { raw: [], unprefixed: [] };
|
||||
|
||||
[secondaryOptions?.ignoreValues ?? []].flat().forEach((value) => {
|
||||
const useRawValue = isRegExp(value) || (value.startsWith('/') && value.match(/\/i?$/));
|
||||
const group = useRawValue ? 'raw' : 'unprefixed';
|
||||
|
||||
groups[group].push(value);
|
||||
});
|
||||
|
||||
root.walkDecls((decl) => {
|
||||
const { value } = decl;
|
||||
|
||||
if (!hasPrefix(value)) return;
|
||||
|
||||
if (!isStandardSyntaxDeclaration(decl) || !isStandardSyntaxProperty(decl.prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (optionsMatches(groups, 'raw', value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo consolidate in the next major
|
||||
* @see stylelint/stylelint#7542
|
||||
*/
|
||||
if (optionsMatches(groups, 'unprefixed', vendor.unprefixed(value))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedValue = valueParser(value);
|
||||
|
||||
parsedValue.walk((node) => {
|
||||
if (!isAutoprefixable.propertyValue(node.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = decl.prop.length + (decl.raws.between || '').length + node.sourceIndex;
|
||||
const fix = () => {
|
||||
node.value = isAutoprefixable.unprefix(node.value);
|
||||
setDeclarationValue(decl, parsedValue.toString());
|
||||
};
|
||||
|
||||
report({
|
||||
message: messages.rejected,
|
||||
messageArgs: [node.value],
|
||||
node: decl,
|
||||
index,
|
||||
endIndex: index + node.value.length,
|
||||
result,
|
||||
ruleName,
|
||||
fix,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
rule.ruleName = ruleName;
|
||||
rule.messages = messages;
|
||||
rule.meta = meta;
|
||||
export default rule;
|
||||
Reference in New Issue
Block a user