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
@@ -0,0 +1,62 @@
# media-feature-parentheses-space-inside
Require a single space or disallow whitespace on the inside of the parentheses within media features.
<!-- prettier-ignore -->
```css
@media ( max-width: 300px ) {}
/** ↑ ↑
* The space inside these two parentheses */
```
The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
`string`: `"always"|"never"`
### `"always"`
There _must always_ be a single space inside the parentheses.
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
@media (max-width: 300px) {}
```
<!-- prettier-ignore -->
```css
@media (max-width: 300px ) {}
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
@media ( max-width: 300px ) {}
```
### `"never"`
There _must never_ be whitespace on the inside the parentheses.
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
@media ( max-width: 300px ) {}
```
<!-- prettier-ignore -->
```css
@media ( max-width: 300px) {}
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
@media (max-width: 300px) {}
```
@@ -0,0 +1,106 @@
// @ts-nocheck
'use strict';
const _ = require('lodash');
const atRuleParamIndex = require('../../utils/atRuleParamIndex');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const valueParser = require('postcss-value-parser');
const ruleName = 'media-feature-parentheses-space-inside';
const messages = ruleMessages(ruleName, {
expectedOpening: 'Expected single space after "("',
rejectedOpening: 'Unexpected whitespace after "("',
expectedClosing: 'Expected single space before ")"',
rejectedClosing: 'Unexpected whitespace before ")"',
});
function rule(expectation, options, context) {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: expectation,
possible: ['always', 'never'],
});
if (!validOptions) {
return;
}
root.walkAtRules(/^media$/i, (atRule) => {
// If there are comments in the params, the complete string
// will be at atRule.raws.params.raw
const params = _.get(atRule, 'raws.params.raw', atRule.params);
const indexBoost = atRuleParamIndex(atRule);
const violations = [];
const parsedParams = valueParser(params).walk((node) => {
if (node.type === 'function') {
const len = valueParser.stringify(node).length;
if (expectation === 'never') {
if (/[ \t]/.test(node.before)) {
if (context.fix) node.before = '';
violations.push({
message: messages.rejectedOpening,
index: node.sourceIndex + 1 + indexBoost,
});
}
if (/[ \t]/.test(node.after)) {
if (context.fix) node.after = '';
violations.push({
message: messages.rejectedClosing,
index: node.sourceIndex - 2 + len + indexBoost,
});
}
} else if (expectation === 'always') {
if (node.before === '') {
if (context.fix) node.before = ' ';
violations.push({
message: messages.expectedOpening,
index: node.sourceIndex + 1 + indexBoost,
});
}
if (node.after === '') {
if (context.fix) node.after = ' ';
violations.push({
message: messages.expectedClosing,
index: node.sourceIndex - 2 + len + indexBoost,
});
}
}
}
});
if (violations.length) {
if (context.fix) {
atRule.params = parsedParams.toString();
return;
}
violations.forEach((err) => {
report({
message: err.message,
node: atRule,
index: err.index,
result,
ruleName,
});
});
}
});
};
}
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;