function runStylelint(pattern) {
  const stylelintCwd = resolve(__dirname, 'fixtures');
  const stylelintCmd = resolve(__dirname, `../node_modules/.bin/stylelint`);

  const result = spawnSync(stylelintCmd, ['--formatter=json', pattern], {
    cwd: stylelintCwd,
  });

  const jsonErrors = JSON.parse(result.stderr.toString().trim());

  const errorLines = [];

  for (const error of jsonErrors) {
    for (const warning of error.warnings) {
      errorLines.push(
        `::error file=${relative(stylelintCwd, error.source)}` +
          `,line=${warning.line}` +
          `,col=${warning.column}` +
          `,endLine=${warning.endLine}` +
          `,endColumn=${warning.endColumn}` +
          `,title=Stylelint problem` +
          `::${warning.text}`,
      );
    }
  }

  return {
    status: result.status,
    output: result.stdout.toString().trim(),
    error: errorLines.join('\n'),
  };
}
Tests that report errors in multiple files may change the order of the files
across multiple runs.
To avoid flaky tests, assert the reporting of errors in one file only per
test case. Asserting no errors are reported across multiple files is ok.