Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-trees-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/stylelint-polaris': minor
---

Allow polaris/media-query-allowed-list lint rule to be disabled
12 changes: 12 additions & 0 deletions stylelint-polaris/plugins/media-query-allowed-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
isString,
isRegExp,
matchesStringOrRegExp,
isBoolean,
} = require('../../utils');

const ruleName = 'polaris/media-query-allowed-list';
Expand All @@ -26,6 +27,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
* @property {AllowedPatterns} allowedMediaTypes
* @property {AllowedPatterns} allowedMediaFeatureNames
* @property {AllowedPatterns} allowedScssInterpolations
* @property {boolean} disabled
*/

const {rule} = stylelint.createPlugin(
Expand All @@ -51,6 +53,11 @@ const {rule} = stylelint.createPlugin(
possible: [isString, isRegExp],
optional: true,
},
{
actual: primary.disabled,
possible: [isBoolean],
optional: true,
},
);

if (!validOptions) {
Expand All @@ -63,8 +70,13 @@ const {rule} = stylelint.createPlugin(
allowedMediaTypes = [],
allowedMediaFeatureNames = [],
allowedScssInterpolations = [],
disabled,
} = primary;

if (disabled) {
return;
}

// Pass `primary.allowedMediaFeatureNames` to the
// built-in `media-feature-name-allowed-list` rule
stylelint.utils.checkAgainstRule(
Expand Down
16 changes: 16 additions & 0 deletions stylelint-polaris/plugins/media-query-allowed-list/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,19 @@ testRule({
},
],
});

testRule({
ruleName,
plugins: [__dirname],
config: {
disabled: true,
},
customSyntax: 'postcss-scss',
accept: [
{
code: '@media (width: 0px) {}',
description: 'Defining media queries with width when rule is disabled',
},
],
reject: [],
});