-
-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix value-no-vendor-prefix
false negatives
#7654
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"stylelint": minor | ||
--- | ||
|
||
Fixed: `value-no-vendor-prefix` false negatives |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
export const prefixes = new Set(['-webkit-', '-moz-', '-ms-', '-o-']); | ||
// used by value-no-vendor-prefix and selector-no-vendor-prefix | ||
// i.e. this list is deliberately not exhaustive | ||
// cf https://www.w3.org/TR/CSS22/syndata.html#vendor-keyword-history | ||
export const prefixes = new Set([ | ||
'-webkit-', | ||
'-moz-', | ||
'-ms-', | ||
'-o-', | ||
'-xv-', | ||
'-apple-', | ||
'-wap-', | ||
'-khtml-', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g. |
||
]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ a { display: -webkit-flex; } | |
* This prefix */ | ||
``` | ||
|
||
This rule ignores non-standard vendor-prefixed values that aren't handled by [Autoprefixer](https://github.com/postcss/autoprefixer). | ||
This rule does not fix vendor-prefixed values that weren't handled by [Autoprefixer](https://github.com/postcss/autoprefixer) version 10.2.5. Exceptions may be added on a case by case basis. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added some examples of such cases that happen to be the false negatives that I am fixing in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the version check #5312 (comment) |
||
|
||
The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule. However, it will not remove duplicate values produced when the prefixes are removed. You can use [Autoprefixer](https://github.com/postcss/autoprefixer) itself, with the [`add` option off and the `remove` option on](https://github.com/postcss/autoprefixer#options), in these situations. | ||
|
||
|
@@ -60,7 +60,7 @@ a { background: linear-gradient(bottom, #000, #fff); } | |
Given: | ||
|
||
```json | ||
["grab", "hangul", "/^-apple-/"] | ||
["grab", "max-content", "/^-moz-all$/"] | ||
``` | ||
|
||
The following patterns are _not_ considered problems: | ||
|
@@ -72,20 +72,15 @@ a { cursor: -webkit-grab; } | |
|
||
<!-- prettier-ignore --> | ||
```css | ||
a { list-style-type: -moz-hangul; } | ||
``` | ||
|
||
<!-- prettier-ignore --> | ||
```css | ||
a { list-style-type: -moz-hangul-consonant; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was technically true that it was being ignored but it was misleading. |
||
a { max-width: -moz-max-content; } | ||
``` | ||
|
||
<!-- prettier-ignore --> | ||
```css | ||
a { -webkit-appearance: -apple-pay-button; } | ||
a { -moz-user-select: -moz-all; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous example was misleading, |
||
``` | ||
|
||
> [!WARNING] | ||
> An _exact_ match comparison will be performed for non-regex strings in the next major version. | ||
> If you want to keep the legacy behavior, please consider using a regex instead. | ||
> E.g. `[/^(-webkit-|-moz-|-ms-)?inline-/]`. | ||
> E.g. `[/^(-webkit-|-moz-|-ms-)?max-content$/]`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,42 @@ testRule({ | |
|
||
accept: [ | ||
{ | ||
code: '.foo { display: flex; }', | ||
code: 'a { display: flex; }', | ||
}, | ||
{ | ||
code: '.foo { background: linear-gradient(to top, #000, #fff); }', | ||
code: 'a { background: linear-gradient(to top, #000, #fff); }', | ||
}, | ||
{ | ||
code: '.foo { max-width: max-content; }', | ||
code: 'a { max-width: max-content; }', | ||
}, | ||
{ | ||
code: '.foo { -webkit-transform: translate(0, 0); }', | ||
code: 'a { -webkit-transform: translate(0, 0); }', | ||
description: 'ignores property vendor prefixes', | ||
}, | ||
{ | ||
code: '.foo { -wEbKiT-tRaNsFoRm: translate(0, 0); }', | ||
code: 'a { -wEbKiT-tRaNsFoRm: translate(0, 0); }', | ||
description: 'ignores property vendor prefixes', | ||
}, | ||
{ | ||
code: '.foo { -WEBKIT-TRANSFORM: translate(0, 0); }', | ||
code: 'a { -WEBKIT-TRANSFORM: translate(0, 0); }', | ||
description: 'ignores property vendor prefixes', | ||
}, | ||
{ | ||
code: 'a { white-space: -pre-wrap; }', | ||
description: 'ignores non-vendor prefixed values', | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}, | ||
{ | ||
code: 'a { background-color: -apple-wireless-playback-target-active; }', | ||
description: '-apple-: ignores unfixable', | ||
}, | ||
{ | ||
code: 'a { display: -wap-marquee; }', | ||
description: '-wap-: ignores unfixable', | ||
}, | ||
{ | ||
code: 'a { list-style-type: -moz-ethiopic-halehame; }', | ||
description: '-moz-: ignores unfixable', | ||
}, | ||
], | ||
|
||
reject: [ | ||
|
@@ -94,6 +110,15 @@ testRule({ | |
endLine: 1, | ||
endColumn: 28, | ||
}, | ||
{ | ||
code: '.foo { display: -khtml-box; }', | ||
fixed: '.foo { display: box; }', | ||
Comment on lines
+114
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
message: messages.rejected('-khtml-box'), | ||
line: 1, | ||
column: 17, | ||
endLine: 1, | ||
endColumn: 27, | ||
}, | ||
{ | ||
code: '.foo { background: -webkit-linear-gradient(bottom, #000, #fff); }', | ||
fixed: '.foo { background: linear-gradient(bottom, #000, #fff); }', | ||
|
@@ -112,6 +137,33 @@ testRule({ | |
endLine: 1, | ||
endColumn: 35, | ||
}, | ||
{ | ||
code: '.foo { speak: -xv-digits; }', | ||
fixed: '.foo { speak: digits; }', | ||
Comment on lines
+141
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
message: messages.rejected('-xv-digits'), | ||
line: 1, | ||
column: 15, | ||
endLine: 1, | ||
endColumn: 25, | ||
}, | ||
{ | ||
code: '.foo { white-space: -o-pre-wrap; }', | ||
fixed: '.foo { white-space: pre-wrap; }', | ||
message: messages.rejected('-o-pre-wrap'), | ||
line: 1, | ||
column: 21, | ||
endLine: 1, | ||
endColumn: 32, | ||
}, | ||
{ | ||
code: '.foo { -webkit-user-select: -moz-all; }', | ||
fixed: '.foo { -webkit-user-select: all; }', | ||
Comment on lines
+159
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
message: messages.rejected('-moz-all'), | ||
line: 1, | ||
column: 29, | ||
endLine: 1, | ||
endColumn: 37, | ||
}, | ||
], | ||
}); | ||
|
||
|
@@ -155,24 +207,21 @@ testRule({ | |
|
||
testRule({ | ||
ruleName, | ||
config: [ | ||
true, | ||
{ ignoreValues: ['grab', 'hangul', '/^-webkit-linear-/', /^-moz-use-text-color$/] }, | ||
], | ||
config: [true, { ignoreValues: ['grab', 'hangul', '/^-webkit-linear-/', /^-moz-all$/] }], | ||
fix: true, | ||
|
||
accept: [ | ||
{ | ||
code: 'a { cursor: -webkit-grab; }', | ||
}, | ||
{ | ||
code: 'a { list-style-type: -moz-hangul-consonant; }', | ||
code: 'a { list-style-type: -moz-hangul; }', | ||
}, | ||
{ | ||
code: 'a { background: -webkit-linear-gradient(bottom, #000, #fff); }', | ||
}, | ||
{ | ||
code: 'a { outline-color: -moz-use-text-color; }', | ||
code: 'a { -moz-user-select: -moz-all; }', | ||
description: 'RegExp: exact match', | ||
}, | ||
], | ||
|
@@ -204,5 +253,14 @@ testRule({ | |
endLine: 1, | ||
endColumn: 29, | ||
}, | ||
{ | ||
code: '.foo { list-style-type: -moz-hangul-consonant; }', | ||
fixed: '.foo { list-style-type: hangul-consonant; }', | ||
message: messages.rejected('-moz-hangul-consonant'), | ||
line: 1, | ||
column: 25, | ||
endLine: 1, | ||
endColumn: 46, | ||
}, | ||
], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://www.developershome.com/wap/wcss/wcss_tutorial.asp?page=marqueeExtension