-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[stylelint-polaris][v5] Final rule categorization #7828
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
const {getCustomPropertyNames, tokens} = require('@shopify/polaris-tokens'); | ||
const { | ||
getCustomPropertyNames, | ||
createVar, | ||
tokens, | ||
} = require('@shopify/polaris-tokens'); | ||
|
||
/** @type {import('./plugins/coverage').PrimaryOptions} */ | ||
const stylelintPolarisCoverageOptions = { | ||
|
@@ -27,14 +31,15 @@ const stylelintPolarisCoverageOptions = { | |
], | ||
'stylelint-polaris/at-rule-disallowed-list': { | ||
include: [ | ||
// mixins | ||
// Legacy mixins | ||
/([\w-]+\.)?color-icon($|\()/, | ||
/([\w-]+\.)?recolor-icon($|\()/, | ||
/([\w-]+\.)?control-backdrop($|\()/, | ||
/([\w-]+\.)?ms-high-contrast-color/, | ||
], | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$polaris-colors/, | ||
/\$color-filter-palette-data/, | ||
/\$color-palette-data/, | ||
|
@@ -55,12 +60,12 @@ const stylelintPolarisCoverageOptions = { | |
'/^animation/': ['ms', 's'], | ||
'/^transition/': ['ms', 's'], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'stylelint-polaris/at-rule-disallowed-list': { | ||
include: [/([\w-]+\.)?skeleton-shimmer($|\()/], | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$duration-data/, | ||
/\$polaris-duration-map/, | ||
/\$skeleton-shimmer-duration/, | ||
|
@@ -80,7 +85,6 @@ const stylelintPolarisCoverageOptions = { | |
'/^font/': ['px', 'rem', 'em'], | ||
'line-height': ['px', 'rem', 'em'], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'function-disallowed-list': [ | ||
/([\w-]+\.)?font-family/, | ||
|
@@ -108,6 +112,7 @@ const stylelintPolarisCoverageOptions = { | |
], | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$typography-condensed/, | ||
/\$typography-condensed/, | ||
/\$base-font-size/, | ||
|
@@ -123,24 +128,15 @@ const stylelintPolarisCoverageOptions = { | |
layout: { | ||
'declaration-property-value-disallowed-list': [ | ||
{ | ||
display: ['grid', 'flex'], | ||
top: [/(?!var\(--p-).+$/], | ||
bottom: [/(?!var\(--p-).+$/], | ||
left: [/(?!var\(--p-).+$/], | ||
right: [/(?!var\(--p-).+$/], | ||
width: [/(?!var\(--p-).+$/], | ||
height: [/(?!var\(--p-).+$/], | ||
'z-index': [/(?!var\(--p-).+$/], | ||
'/^width/': [/(?!var\(--p-).+$/], | ||
'/^height/': [/(?!var\(--p-).+$/], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'declaration-property-unit-disallowed-list': [ | ||
{ | ||
'/^width/': ['px', 'rem', 'em'], | ||
'/^height/': ['px', 'rem', 'em'], | ||
}, | ||
{severity: 'error'}, | ||
], | ||
'property-disallowed-list': [ | ||
[ | ||
'position', | ||
|
@@ -182,11 +178,13 @@ const stylelintPolarisCoverageOptions = { | |
/([\w-]+\.)?hidden-when-printing($|\()/, | ||
/([\w-]+\.)?print-hidden($|\()/, | ||
/([\w-]+\.)?layout-flex-fix($|\()/, | ||
/([\w-]+\.)?safe-area-for($|\()/, | ||
/([\w-]+\.)?skeleton-page-header-layout($|\()/, | ||
/([\w-]+\.)?skeleton-page-secondary-actions-layout($|\()/, | ||
], | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$layout-width-data/, | ||
/\$navigation-width/, | ||
/\$small-thumbnail-size/, | ||
|
@@ -216,9 +214,9 @@ const stylelintPolarisCoverageOptions = { | |
'/^margin/': ['px', 'rem', 'em'], | ||
'/^gap/': ['px', 'rem', 'em'], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$polaris-spacing/, | ||
/\$spacing-data/, | ||
/\$actions-vertical-spacing/, | ||
|
@@ -237,7 +235,6 @@ const stylelintPolarisCoverageOptions = { | |
'outline-offset': ['px', 'rem', 'em'], | ||
outline: ['px', 'rem', 'em'], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'stylelint-polaris/at-rule-disallowed-list': { | ||
include: [ | ||
|
@@ -252,6 +249,7 @@ const stylelintPolarisCoverageOptions = { | |
], | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$border-radius-data/, | ||
/\$border-width-data/, | ||
/\$borders-data/, | ||
|
@@ -276,10 +274,10 @@ const stylelintPolarisCoverageOptions = { | |
{ | ||
'box-shadow': ['px', 'rem', 'em'], | ||
}, | ||
{severity: 'warning'}, | ||
], | ||
'property-disallowed-list': [['text-shadow'], {severity: 'warning'}], | ||
'property-disallowed-list': ['text-shadow'], | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$shadows-data/, | ||
/\$fixed-element-stacking-order/, | ||
/\$global-elements/, | ||
|
@@ -293,6 +291,21 @@ const stylelintPolarisCoverageOptions = { | |
/--p-top-bar-shadow/, | ||
], | ||
}, | ||
'z-index': { | ||
'declaration-property-value-allowed-list': [ | ||
{ | ||
'z-index': Object.keys(tokens.zIndex).map(createVar), | ||
}, | ||
], | ||
'function-disallowed-list': [/([\w-]+\.)?z-index/], | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy mixin map-get data | ||
/\$fixed-element-stacking-order/, | ||
/\$global-elements/, | ||
// Legacy custom properties | ||
/--p-override-loading-z-index/, | ||
], | ||
}, | ||
conventions: { | ||
'stylelint-polaris/custom-properties-allowed-list': { | ||
// Allow any custom property not prefixed with `--p-`, `--pc-`, or `--polaris-version-` | ||
|
@@ -309,30 +322,26 @@ const stylelintPolarisCoverageOptions = { | |
], | ||
}, | ||
}, | ||
'stylelint-polaris/global-disallowed-list': [ | ||
/ \* \$/, | ||
// Legacy custom properties | ||
/--p-override-none/, | ||
/--p-override-one/, | ||
/--p-override-zero/, | ||
/--p-non-null-content/, | ||
], | ||
'stylelint-polaris/media-queries-allowed-list': { | ||
// Allowed media types and media conditions | ||
// https://www.w3.org/TR/mediaqueries-5/#media | ||
allowedMediaTypes: ['print', 'screen'], | ||
allowedMediaFeatureNames: ['forced-colors', '-ms-high-contrast'], | ||
}, | ||
}, | ||
mediaQueries: { | ||
breakpoints: { | ||
// Legacy functions | ||
'function-disallowed-list': [ | ||
/([\w-]+\.)?breakpoint/, | ||
/([\w-]+\.)?layout-width/, | ||
], | ||
'stylelint-polaris/media-queries-allowed-list': { | ||
// Allowed media types and media conditions | ||
// https://www.w3.org/TR/mediaqueries-5/#media | ||
allowedMediaTypes: ['print', 'screen'], | ||
allowedMediaFeatureNames: ['forced-colors', '-ms-high-contrast'], | ||
allowedScssInterpolations: [ | ||
// TODO: Add utility to @shopify/polaris-tokens to getMediaConditionNames | ||
/^\$p-breakpoints-(xs|sm|md|lg|xl)-(up|down|only)$/, | ||
], | ||
}, | ||
// Legacy mixins | ||
'stylelint-polaris/at-rule-disallowed-list': { | ||
include: [ | ||
/([\w-]+\.)?after-topbar-sheet($|\()/, | ||
|
@@ -367,7 +376,8 @@ const stylelintPolarisCoverageOptions = { | |
], | ||
}, | ||
}, | ||
legacySass: { | ||
legacy: { | ||
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. 👍 |
||
// Legacy mixins | ||
'stylelint-polaris/at-rule-disallowed-list': { | ||
include: [ | ||
/([\w-]+\.)?base-button-disabled($|\()/, | ||
|
@@ -376,6 +386,8 @@ const stylelintPolarisCoverageOptions = { | |
/([\w-]+\.)?button-full-width($|\()/, | ||
/([\w-]+\.)?button-outline-disabled($|\()/, | ||
/([\w-]+\.)?button-outline($|\()/, | ||
/([\w-]+\.)?control-backdrop($|\()/, | ||
/([\w-]+\.)?list-selected-indicator($|\()/, | ||
/([\w-]+\.)?plain-button-backdrop($|\()/, | ||
/([\w-]+\.)?unstyled-button($|\()/, | ||
/([\w-]+\.)?skeleton-content($|\()/, | ||
|
@@ -384,15 +396,23 @@ const stylelintPolarisCoverageOptions = { | |
/([\w-]+\.)?unstyled-list($|\()/, | ||
/([\w-]+\.)?range-thumb-selectors($|\()/, | ||
/([\w-]+\.)?range-track-selectors($|\()/, | ||
/([\w-]+\.)?state($|\()/, | ||
/([\w-]+\.)?visually-hidden($|\()/, | ||
], | ||
}, | ||
// Legacy functions | ||
'function-disallowed-list': [ | ||
/([\w-]+\.)?available-names/, | ||
/([\w-]+\.)?map-extend/, | ||
/([\w-]+\.)?control-backdrop($|\()/, | ||
/([\w-]+\.)?list-selected-indicator($|\()/, | ||
/([\w-]+\.)?state($|\()/, | ||
], | ||
'stylelint-polaris/global-disallowed-list': [ | ||
// Legacy variables | ||
/ \* \$/, | ||
// Legacy custom properties | ||
/--p-override-none/, | ||
/--p-override-one/, | ||
/--p-override-zero/, | ||
/--p-non-null-content/, | ||
], | ||
}, | ||
}; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
mediaQueries
may be more appropriate as this category can lint more than Polaris breakpoints e.g. media types, media features, media conditions/operators, etc. Thoughts?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.
@aaronccasanova What do you think about re-categorizing the non-breakpoint related options in the breakpoints category media-query-allowed-list over to conventions? It seems like that would be a better fit so the coverage site can map the results related to breakpoints to the breakpoints token coverage.