UNPKG

linter-bundle

Version:

Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.

59 lines (48 loc) 1.72 kB
// @ts-nocheck import stylelint from 'stylelint'; import ruleMessages from 'stylelint/lib/utils/ruleMessages.mjs'; import validateOptions from 'stylelint/lib/utils/validateOptions.mjs'; import whitespaceChecker from '../../utils/whitespaceChecker.mjs'; import functionCommaSpaceChecker from '../functionCommaSpaceChecker.mjs'; import fixer from '../functionCommaSpaceFix.mjs'; const ruleName = 'plugin/function-comma-newline-before'; const messages = ruleMessages(ruleName, { expectedBefore: () => 'Expected newline before ","', expectedBeforeMultiLine: () => 'Expected newline before "," in a multi-line function', rejectedBeforeMultiLine: () => 'Unexpected whitespace before "," in a multi-line function' }); const meta = { url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/README.md', fixable: true }; /** @type {import('stylelint').Rule} */ const rule = (primary, _secondaryOptions, context) => { const checker = whitespaceChecker('newline', primary, messages); return (root, result) => { const validOptions = validateOptions(result, ruleName, { actual: primary, possible: ['always', 'always-multi-line', 'never-multi-line'] }); if (!validOptions) { return; } functionCommaSpaceChecker({ root, result, locationChecker: checker.beforeAllowingIndentation, checkedRuleName: ruleName, fix: (div, index, nodes) => fixer({ div, index, nodes, expectation: primary, position: 'before', symb: context.newline || '' }) }); }; }; rule.ruleName = ruleName; rule.messages = messages; rule.meta = meta; export default stylelint.createPlugin(ruleName, rule);