{"size": 867, "ext": "js", "max_stars_repo_path": "src/rules/no-multiple-empty-lines/index.js", "max_stars_repo_name": "chriswrightdesign/stylelint", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/rules/no-multiple-empty-lines/index.js", "max_issues_repo_name": "chriswrightdesign/stylelint", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/rules/no-multiple-empty-lines/index.js", "max_forks_repo_name": "chriswrightdesign/stylelint", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.0833333333, "max_line_length": 85, "alphanum_fraction": 0.5916955017}
import {
  report,
  ruleMessages,
  styleSearch,
  validateOptions,
} from "../../utils"

export const ruleName = "no-multiple-empty-lines"

export const messages = ruleMessages(ruleName, {
  rejected: "Unexpected empty line",
})

export default function (actual) {
  return (root, result) => {
    const validOptions = validateOptions(result, ruleName, { actual })
    if (!validOptions) { return }

    const rootString = root.source.input.css
    styleSearch({ source: rootString, target: "\n", checkComments: true }, match => {
      if (
        rootString.substr(match.startIndex + 1, 2) === "\n\n"
        || rootString.substr(match.startIndex + 1, 4) === "\r\n\r\n"
      ) {
        report({
          message: messages.rejected,
          node: root,
          index: match.startIndex,
          result,
          ruleName,
        })
      }
    })
  }
}
