added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
# selector-max-empty-lines
Limit the number of adjacent empty lines within selectors.
<!-- prettier-ignore -->
```css
a,
/* ← */
b { /* ↑ */
color: red; /* ↑ */
} /* ↑ */
/** ↑
* This empty line */
```
The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
`int`: Maximum number of adjacent empty lines allowed.
For example, with `0`:
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
a
b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a,
b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a
>
b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a
>
b {
color: red;
}
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
a b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a
b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a,
b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a > b {
color: red;
}
```
<!-- prettier-ignore -->
```css
a
>
b {
color: red;
}
```
+65
View File
@@ -0,0 +1,65 @@
// @ts-nocheck
'use strict';
const _ = require('lodash');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const ruleName = 'selector-max-empty-lines';
const messages = ruleMessages(ruleName, {
expected: (max) => `Expected no more than ${max} empty ${max === 1 ? 'line' : 'lines'}`,
});
function rule(max, options, context) {
const maxAdjacentNewlines = max + 1;
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: max,
possible: _.isNumber,
});
if (!validOptions) {
return;
}
const violatedCRLFNewLinesRegex = new RegExp(`(?:\r\n){${maxAdjacentNewlines + 1},}`);
const violatedLFNewLinesRegex = new RegExp(`\n{${maxAdjacentNewlines + 1},}`);
const allowedLFNewLinesString = context.fix ? '\n'.repeat(maxAdjacentNewlines) : '';
const allowedCRLFNewLinesString = context.fix ? '\r\n'.repeat(maxAdjacentNewlines) : '';
root.walkRules((ruleNode) => {
const selector = ruleNode.raws.selector ? ruleNode.raws.selector.raw : ruleNode.selector;
if (context.fix) {
const newSelectorString = selector
.replace(new RegExp(violatedLFNewLinesRegex, 'gm'), allowedLFNewLinesString)
.replace(new RegExp(violatedCRLFNewLinesRegex, 'gm'), allowedCRLFNewLinesString);
if (ruleNode.raws.selector) {
ruleNode.raws.selector.raw = newSelectorString;
} else {
ruleNode.selector = newSelectorString;
}
} else if (
violatedLFNewLinesRegex.test(selector) ||
violatedCRLFNewLinesRegex.test(selector)
) {
report({
message: messages.expected(max),
node: ruleNode,
index: 0,
result,
ruleName,
});
}
});
};
}
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;