1.0.0 • Published 1 year ago

stylelint-file-max-lines v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

stylelint-file-max-lines

Stylelint rule for limiting a maximum number of lines per file.

Please note that most editors show an additional empty line at the end if the file ends with a line break. This plugin does not count that extra line.


This plugin is inspired by eslint max-lines and is an enhancement to dkrnl/stylelint-max-lines

install

npm i stylelint-file-max-lines -D

Usage

Add this config to your .stylelintrc:

{
  "plugins": ["stylelint-file-max-lines"],
  "rules": {
    "plugin/file-max-lines": 300
  }
}

Options

int: maximum number of lines per file

For example, with 5:

{
  "plugins": ["stylelint-file-max-lines"],
  "rules": {
    "plugin/file-max-lines": 5
  }
}

The following css file will get an error: 'File has too many lines (6). Maximum allowed is 5 (plugin/file-max-lines)

body {
  border: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

Optional secondary options

ignore: "comments" | "blankLines"

Ignore comments

{
  "plugins": ["stylelint-file-max-lines"],
  "rules": {
    "plugin/file-max-lines": [5, { "ignore": "comments" }]
  }
}

The following css file are not considered problems

body {
  /* border: none; */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

Ignore blankLines

{
  "plugins": ["stylelint-file-max-lines"],
  "rules": {
    "plugin/file-max-lines": [5, { "ignore": "blankLines" }]
  }
}

The following css file are not considered problems

body {
  margin: 0;
  padding: 0;

  box-sizing: border-box;
}