How to use the stylelint.utils.checkAgainstRule function in stylelint

To help you get started, we’ve selected a few stylelint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / stylelint / stylelint-tests.ts View on Github external
return (root, result) => {
        const validOptions = utils.validateOptions(result, ruleName, { actual: options });
        if (!validOptions) {
            return;
        }

        utils.checkAgainstRule({
            ruleName: "at-rule-empty-line-before",
            ruleSettings: ["always"],
            root,
        }, warning => {
            utils.report({
                ruleName,
                result,
                message: messages.warning(warning),
                node: root,
                index: 1,
                word: "foo",
                line: 2,
            });
        });
    };
};
github kristerkari / stylelint-scss / src / rules / at-rule-no-unknown / index.js View on Github external
},
        optional: true
      }
    );

    if (!validOptions) {
      return;
    }

    const optionsAtRules = secondaryOptions && secondaryOptions.ignoreAtRules;
    const ignoreAtRules = sassAtRules.concat(optionsAtRules || []);
    const defaultedOptions = Object.assign({}, secondaryOptions, {
      ignoreAtRules
    });

    utils.checkAgainstRule(
      {
        ruleName: ruleToCheckAgainst,
        ruleSettings: [primaryOption, defaultedOptions],
        root
      },
      warning => {
        const name = warning.node.name;

        if (!ignoreAtRules.includes(name)) {
          utils.report({
            message: messages.rejected(`@${name}`),
            ruleName,
            result,
            node: warning.node,
            line: warning.line,
            column: warning.column