Skip to content

Commit

Permalink
Add property-no-unknown rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Aug 24, 2023
1 parent 05cf7f7 commit 55227ae
Show file tree
Hide file tree
Showing 5 changed files with 720 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rules/index.js
Expand Up @@ -59,6 +59,7 @@ const rules = {
"operator-no-unspaced": require("./operator-no-unspaced"),
"partial-no-import": require("./partial-no-import"),
"percent-placeholder-pattern": require("./percent-placeholder-pattern"),
"property-no-unknown": require("./property-no-unknown"),
"selector-nest-combinators": require("./selector-nest-combinators"),
"selector-no-redundant-nesting-selector": require("./selector-no-redundant-nesting-selector"),
"selector-no-union-class-name": require("./selector-no-union-class-name")
Expand Down
207 changes: 207 additions & 0 deletions src/rules/property-no-unknown/README.md
@@ -0,0 +1,207 @@
# property-no-unknown

Disallow unknown properties.

<!-- prettier-ignore -->
```scss
a { height: 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.

The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule.

## Options

### `true`

The following patterns are considered problems:

<!-- prettier-ignore -->
```scss
a {
colr: blue;
}
```

<!-- prettier-ignore -->
```scss
a {
my-property: 1;
}
```

<!-- prettier-ignore -->
```scss
a {
font: {
stuff: bold;
}
}
```

The following patterns are _not_ considered problems:

<!-- prettier-ignore -->
```scss
a {
color: green;
}
```

<!-- prettier-ignore -->
```scss
a {
fill: black;
}
```

<!-- prettier-ignore -->
```scss
a {
-moz-align-self: center;
}
```

<!-- prettier-ignore -->
```scss
a {
-webkit-align-self: center;
}
```

<!-- prettier-ignore -->
```scss
a {
align-self: center;
}
```

<!-- prettier-ignore -->
```scss
a {
font: {
weight: bold;
}
}
```

## Optional secondary options

### `ignoreProperties: ["/regex/", /regex/, "string"]`

Given:

```json
["/^my-/", "custom"]
```

The following patterns are _not_ considered problems:

<!-- prettier-ignore -->
```scss
a {
my-property: 10px;
}
```

<!-- prettier-ignore -->
```scss
a {
my-other-property: 10px;
}
```

<!-- prettier-ignore -->
```scss
a {
custom: 10px;
}
```

### `ignoreSelectors: ["/regex/", /regex/, "string"]`

Skips checking properties of the given selectors against this rule.

Given:

```json
[":root"]
```

The following patterns are _not_ considered problems:

<!-- prettier-ignore -->
```scss
:root {
my-property: blue;
}
```

### `ignoreAtRules: ["/regex/", /regex/, "string"]`

Ignores properties nested within specified at-rules.

Given:

```json
["supports"]
```

The following patterns are _not_ considered problems:

<!-- prettier-ignore -->
```scss
@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 problems:

<!-- prettier-ignore -->
```scss
a {
-webkit-overflow-scrolling: auto;
}
```

<!-- prettier-ignore -->
```scss
a {
-moz-box-flex: 0;
}
```

The following patterns are considered problems:

<!-- prettier-ignore -->
```scss
a {
-moz-align-self: center;
}
```

<!-- prettier-ignore -->
```scss
a {
-moz-overflow-scrolling: center;
}
```

0 comments on commit 55227ae

Please sign in to comment.