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
+75
View File
@@ -0,0 +1,75 @@
# block-no-empty
Disallow empty blocks.
<!-- prettier-ignore -->
```css
a { }
/** ↑
* Blocks like this */
```
## Options
### `true`
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
a {}
```
<!-- prettier-ignore -->
```css
a { }
```
<!-- prettier-ignore -->
```css
@media print {
a {}
}
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
a {
/* foo */
}
```
<!-- prettier-ignore -->
```css
@media print {
a {
color: pink;
}
}
```
## Optional secondary options
### `ignore: ["comments"]`
Exclude comments from being treated as content inside of a block.
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
a {
/* foo */
}
```
<!-- prettier-ignore -->
```css
@media print {
a {
/* foo */
}
}
```
+83
View File
@@ -0,0 +1,83 @@
// @ts-nocheck
'use strict';
const _ = require('lodash');
const beforeBlockString = require('../../utils/beforeBlockString');
const hasBlock = require('../../utils/hasBlock');
const hasEmptyBlock = require('../../utils/hasEmptyBlock');
const optionsMatches = require('../../utils/optionsMatches');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const ruleName = 'block-no-empty';
const messages = ruleMessages(ruleName, {
rejected: 'Unexpected empty block',
});
function rule(primary, options = {}) {
return (root, result) => {
const validOptions = validateOptions(
result,
ruleName,
{
actual: primary,
possible: _.isBoolean,
},
{
actual: options,
possible: {
ignore: ['comments'],
},
optional: true,
},
);
if (!validOptions) {
return;
}
const ignoreComments = optionsMatches(options, 'ignore', 'comments');
// Check both kinds of statements: rules and at-rules
root.walkRules(check);
root.walkAtRules(check);
function check(statement) {
if (!hasEmptyBlock(statement) && !ignoreComments) {
return;
}
if (!hasBlock(statement)) {
return;
}
const hasCommentsOnly = statement.nodes.every((node) => node.type === 'comment');
if (!hasCommentsOnly) {
return;
}
let index = beforeBlockString(statement, { noRawBefore: true }).length;
// For empty blocks when using SugarSS parser
if (statement.raws.between === undefined) {
index--;
}
report({
message: messages.rejected,
node: statement,
index,
result,
ruleName,
});
}
};
}
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;