first commit
This commit is contained in:
91
node_modules/stylelint/lib/rules/function-no-unknown/index.cjs
generated
vendored
Normal file
91
node_modules/stylelint/lib/rules/function-no-unknown/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// 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 node_module = require('node:module');
|
||||
const cssParserAlgorithms = require('@csstools/css-parser-algorithms');
|
||||
const cssTokenizer = require('@csstools/css-tokenizer');
|
||||
const validateTypes = require('../../utils/validateTypes.cjs');
|
||||
const nodeFieldIndices = require('../../utils/nodeFieldIndices.cjs');
|
||||
const isCustomFunction = require('../../utils/isCustomFunction.cjs');
|
||||
const isStandardSyntaxValue = require('../../utils/isStandardSyntaxValue.cjs');
|
||||
const optionsMatches = require('../../utils/optionsMatches.cjs');
|
||||
const report = require('../../utils/report.cjs');
|
||||
const ruleMessages = require('../../utils/ruleMessages.cjs');
|
||||
const validateOptions = require('../../utils/validateOptions.cjs');
|
||||
|
||||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
||||
/** @todo leverage import attributes once support for Node.js v18.19 is dropped */
|
||||
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('lib/rules/function-no-unknown/index.cjs', document.baseURI).href)));
|
||||
const functionsList = require$1('css-functions-list/index.json');
|
||||
|
||||
/** @todo submit PR to css-functions-list */
|
||||
const FUNCTIONS = [...functionsList, 'running'];
|
||||
|
||||
const ruleName = 'function-no-unknown';
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (name) => `Unexpected unknown function "${name}"`,
|
||||
});
|
||||
|
||||
const meta = {
|
||||
url: 'https://stylelint.io/user-guide/rules/function-no-unknown',
|
||||
};
|
||||
|
||||
/** @type {import('stylelint').CoreRules[ruleName]} */
|
||||
const rule = (primary, secondaryOptions) => {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(
|
||||
result,
|
||||
ruleName,
|
||||
{ actual: primary },
|
||||
{
|
||||
actual: secondaryOptions,
|
||||
possible: {
|
||||
ignoreFunctions: [validateTypes.isString, validateTypes.isRegExp],
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
);
|
||||
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkDecls((decl) => {
|
||||
const { value } = decl;
|
||||
|
||||
if (!value.includes('(')) return;
|
||||
|
||||
if (!isStandardSyntaxValue(value)) return;
|
||||
|
||||
cssParserAlgorithms.walk(cssParserAlgorithms.parseListOfComponentValues(cssTokenizer.tokenize({ css: value })), ({ node }) => {
|
||||
if (!cssParserAlgorithms.isFunctionNode(node)) return;
|
||||
|
||||
const name = node.getName();
|
||||
|
||||
if (isCustomFunction(name)) return;
|
||||
|
||||
if (optionsMatches(secondaryOptions, 'ignoreFunctions', name)) return;
|
||||
|
||||
if (FUNCTIONS.includes(name.toLowerCase())) return;
|
||||
|
||||
report({
|
||||
message: messages.rejected,
|
||||
messageArgs: [name],
|
||||
node: decl,
|
||||
index: nodeFieldIndices.declarationValueIndex(decl) + node.name[2],
|
||||
result,
|
||||
ruleName,
|
||||
word: name,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
rule.ruleName = ruleName;
|
||||
rule.messages = messages;
|
||||
rule.meta = meta;
|
||||
|
||||
module.exports = rule;
|
||||
87
node_modules/stylelint/lib/rules/function-no-unknown/index.mjs
generated
vendored
Normal file
87
node_modules/stylelint/lib/rules/function-no-unknown/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
import { isFunctionNode, parseListOfComponentValues, walk } from '@csstools/css-parser-algorithms';
|
||||
import { tokenize } from '@csstools/css-tokenizer';
|
||||
|
||||
import { isRegExp, isString } from '../../utils/validateTypes.mjs';
|
||||
import { declarationValueIndex } from '../../utils/nodeFieldIndices.mjs';
|
||||
import isCustomFunction from '../../utils/isCustomFunction.mjs';
|
||||
import isStandardSyntaxValue from '../../utils/isStandardSyntaxValue.mjs';
|
||||
import optionsMatches from '../../utils/optionsMatches.mjs';
|
||||
import report from '../../utils/report.mjs';
|
||||
import ruleMessages from '../../utils/ruleMessages.mjs';
|
||||
import validateOptions from '../../utils/validateOptions.mjs';
|
||||
|
||||
/** @todo leverage import attributes once support for Node.js v18.19 is dropped */
|
||||
const require = createRequire(import.meta.url);
|
||||
const functionsList = require('css-functions-list/index.json');
|
||||
|
||||
/** @todo submit PR to css-functions-list */
|
||||
const FUNCTIONS = [...functionsList, 'running'];
|
||||
|
||||
const ruleName = 'function-no-unknown';
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (name) => `Unexpected unknown function "${name}"`,
|
||||
});
|
||||
|
||||
const meta = {
|
||||
url: 'https://stylelint.io/user-guide/rules/function-no-unknown',
|
||||
};
|
||||
|
||||
/** @type {import('stylelint').CoreRules[ruleName]} */
|
||||
const rule = (primary, secondaryOptions) => {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(
|
||||
result,
|
||||
ruleName,
|
||||
{ actual: primary },
|
||||
{
|
||||
actual: secondaryOptions,
|
||||
possible: {
|
||||
ignoreFunctions: [isString, isRegExp],
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
);
|
||||
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkDecls((decl) => {
|
||||
const { value } = decl;
|
||||
|
||||
if (!value.includes('(')) return;
|
||||
|
||||
if (!isStandardSyntaxValue(value)) return;
|
||||
|
||||
walk(parseListOfComponentValues(tokenize({ css: value })), ({ node }) => {
|
||||
if (!isFunctionNode(node)) return;
|
||||
|
||||
const name = node.getName();
|
||||
|
||||
if (isCustomFunction(name)) return;
|
||||
|
||||
if (optionsMatches(secondaryOptions, 'ignoreFunctions', name)) return;
|
||||
|
||||
if (FUNCTIONS.includes(name.toLowerCase())) return;
|
||||
|
||||
report({
|
||||
message: messages.rejected,
|
||||
messageArgs: [name],
|
||||
node: decl,
|
||||
index: declarationValueIndex(decl) + node.name[2],
|
||||
result,
|
||||
ruleName,
|
||||
word: name,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
rule.ruleName = ruleName;
|
||||
rule.messages = messages;
|
||||
rule.meta = meta;
|
||||
export default rule;
|
||||
Reference in New Issue
Block a user