function validateIndividualSystemMixins()

in tools/stylelint/theme-mixin-api.ts [145:204]


    function validateIndividualSystemMixins(node: AtRule, type: string, args: string[]) {
      if (args.length !== 1) {
        reportError(node, 'Expected mixin to only declare a single argument.');
      } else if (args[0] !== '$config-or-theme') {
        if (context.fix) {
          node.params = node.params.replace(args[0], '$config-or-theme');
        } else {
          reportError(node, 'Expected first mixin argument to be called `$config-or-theme`.');
        }
      }

      const expectedProperty = type === 'density' ? '$density-scale' : '$config';
      const expectedValues =
        type === 'typography'
          ? [
              'typography.private-typography-to-2014-config(' +
                'theming.get-typography-config($config-or-theme))',
              'typography.private-typography-to-2018-config(' +
                'theming.get-typography-config($config-or-theme))',
            ]
          : [`theming.get-${type}-config($config-or-theme)`];
      let configExtractionNode: Declaration | null = null;
      let nonCommentNodeCount = 0;

      if (node.nodes) {
        for (const currentNode of node.nodes) {
          if (currentNode.type !== 'comment') {
            nonCommentNodeCount++;
          }

          if (
            currentNode.type === 'decl' &&
            expectedValues.includes(stripNewlinesAndIndentation(currentNode.value))
          ) {
            configExtractionNode = currentNode;
            break;
          }
        }
      }

      if (!configExtractionNode && nonCommentNodeCount > 0) {
        if (context.fix) {
          node.insertBefore(0, {prop: expectedProperty, value: expectedValues[0]});
        } else {
          reportError(
            node,
            `Config is not extracted. Consumers could pass a theme object. ` +
              `Extract the configuration by using one of the following:` +
              expectedValues
                .map(expectedValue => `${expectedProperty}: ${expectedValue}`)
                .join('\n'),
          );
        }
      } else if (configExtractionNode && configExtractionNode.prop !== expectedProperty) {
        reportError(
          configExtractionNode,
          `For consistency, variable for configuration should ` + `be called: ${expectedProperty}`,
        );
      }
    }