Skip to content
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 TypeError for spaceless condition in media-feature-name-value-allowed-list #5581

Merged
merged 4 commits into from Oct 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/rules/media-feature-name-allowed-list/__tests__/index.js
Expand Up @@ -39,6 +39,9 @@ testRule({
{
code: '@media (color) { }',
},
{
code: '@media only screen and(min-width: 640px) { }',
},
],

reject: [
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/media-feature-name-value-allowed-list/index.js
Expand Up @@ -31,6 +31,8 @@ const rule = (primary) => {

root.walkAtRules(/^media$/i, (atRule) => {
mediaParser(atRule.params).walk(/^media-feature-expression$/i, (node) => {
if (!node.nodes) return;

const mediaFeatureRangeContext = isRangeContextMediaFeature(node.parent.value);

// Ignore boolean
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-duplicate-at-import-rules/index.js
Expand Up @@ -38,8 +38,8 @@ const rule = (primary) => {
: firstParam.value;

// extract media queries if any
const media = mediaParser(valueParser.stringify(restParams))
.nodes.map((n) => n.value.replace(/\s/g, ''))
const media = (mediaParser(valueParser.stringify(restParams)).nodes || [])
.map((n) => n.value.replace(/\s/g, ''))
.filter((n) => n.length);

const isDuplicate = media.length
Expand Down
2 changes: 1 addition & 1 deletion types/postcss-media-query-parser/index.d.ts
Expand Up @@ -7,7 +7,7 @@ declare module 'postcss-media-query-parser' {
after: string;
before: string;
sourceIndex: number;
nodes: Child[];
nodes?: Child[];
walk: Walker;
};

Expand Down