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
+187
View File
@@ -0,0 +1,187 @@
# property-no-unknown
Disallow unknown properties.
<!-- prettier-ignore -->
```css
a { heigth: 100%; }
/** ↑
* This property */
```
This rule considers properties defined in the [CSS Specifications and browser specific properties](https://github.com/betit/known-css-properties#source) to be known.
This rule ignores:
- variables (`$sass`, `@less`, `--custom-property`)
- vendor-prefixed properties (e.g., `-moz-align-self`, `-webkit-align-self`)
Use option `checkPrefixed` described below to turn on checking of vendor-prefixed properties.
## Options
### `true`
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
a {
colr: blue;
}
```
<!-- prettier-ignore -->
```css
a {
my-property: 1;
}
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
a {
color: green;
}
```
<!-- prettier-ignore -->
```css
a {
fill: black;
}
```
<!-- prettier-ignore -->
```css
a {
-moz-align-self: center;
}
```
<!-- prettier-ignore -->
```css
a {
-webkit-align-self: center;
}
```
<!-- prettier-ignore -->
```css
a {
align-self: center;
}
```
## Optional secondary options
### `ignoreProperties: ["/regex/", /regex/, "string"]`
Given:
```
["/^my-/", "custom"]
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
a {
my-property: 10px;
}
```
<!-- prettier-ignore -->
```css
a {
my-other-property: 10px;
}
```
<!-- prettier-ignore -->
```css
a {
custom: 10px;
}
```
### `ignoreSelectors: ["/regex/", /regex/, "string"]`
Skips checking properties of the given selectors against this rule.
Given:
```
[":root"]
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
:root {
my-property: blue;
}
```
### `ignoreAtRules: ["/regex/", /regex/, "string"]`
Ignores properties nested within specified at-rules.
Given:
```
["supports"]
```
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
@supports (display: grid) {
a {
my-property: 1;
}
}
```
### `checkPrefixed: true | false` (default: `false`)
If `true`, this rule will check vendor-prefixed properties.
For example with `true`:
The following patterns are _not_ considered violations:
<!-- prettier-ignore -->
```css
a {
-webkit-overflow-scrolling: auto;
}
```
<!-- prettier-ignore -->
```css
a {
-moz-box-flex: 0;
}
```
The following patterns are considered violations:
<!-- prettier-ignore -->
```css
a {
-moz-align-self: center;
}
```
<!-- prettier-ignore -->
```css
a {
-moz-overflow-scrolling: center;
}
```
+107
View File
@@ -0,0 +1,107 @@
// @ts-nocheck
'use strict';
const _ = require('lodash');
const isCustomProperty = require('../../utils/isCustomProperty');
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration');
const isStandardSyntaxProperty = require('../../utils/isStandardSyntaxProperty');
const optionsMatches = require('../../utils/optionsMatches');
const properties = require('known-css-properties').all;
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const vendor = require('../../utils/vendor');
const ruleName = 'property-no-unknown';
const messages = ruleMessages(ruleName, {
rejected: (property) => `Unexpected unknown property "${property}"`,
});
function rule(actual, options) {
const allValidProperties = new Set(properties);
return (root, result) => {
const validOptions = validateOptions(
result,
ruleName,
{ actual },
{
actual: options,
possible: {
ignoreProperties: [_.isString, _.isRegExp],
checkPrefixed: _.isBoolean,
ignoreSelectors: [_.isString, _.isRegExp],
ignoreAtRules: [_.isString, _.isRegExp],
},
optional: true,
},
);
if (!validOptions) {
return;
}
const shouldCheckPrefixed = _.get(options, 'checkPrefixed');
root.walkDecls(checkStatement);
function checkStatement(decl) {
const prop = decl.prop;
if (!isStandardSyntaxProperty(prop)) {
return;
}
if (!isStandardSyntaxDeclaration(decl)) {
return;
}
if (isCustomProperty(prop)) {
return;
}
if (!shouldCheckPrefixed && vendor.prefix(prop)) {
return;
}
if (optionsMatches(options, 'ignoreProperties', prop)) {
return;
}
const { selector } = decl.parent;
if (selector && optionsMatches(options, 'ignoreSelectors', selector)) {
return;
}
let node = decl.parent;
while (node && node.type !== 'root') {
const { type, name } = node;
if (type === 'atrule' && optionsMatches(options, 'ignoreAtRules', name)) {
return;
}
node = node.parent;
}
if (allValidProperties.has(prop.toLowerCase())) {
return;
}
report({
message: messages.rejected(prop),
node: decl,
result,
ruleName,
});
}
};
}
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;