Skip to content

Commit

Permalink
Disallow unknown custom media queries (#4)
Browse files Browse the repository at this point in the history
Resolves #3
  • Loading branch information
firefoxic authored May 17, 2024
1 parent 0770fbf commit 841b5ea
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and 

## [Unreleased]

### Changed

- The custom media queries should now be defined within the same source.

### Fixed

- Zero length value no longer requires no units in all cases.
Expand Down
1 change: 1 addition & 0 deletions stylelint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default {
"no-invalid-double-slash-comments": true,
"no-invalid-position-at-import-rule": true,
"no-irregular-whitespace": true,
"no-unknown-custom-media": true,
"number-max-precision": [
3,
{
Expand Down
43 changes: 43 additions & 0 deletions test/no-unknown-custom-media.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { testRule } from "../utils/testRule.js"

let rule = `no-unknown-custom-media`

let code = `
@custom-media --any-valid (width >= 40rem);
@media (--any-valid), (height < 40rem) {}
@media (--another-valid) {}
@custom-media --another-valid (width >= 60rem);
@media (--invalid) {}
@media (--invalid), (height < 40rem) {}
`

testRule({
description: `Custom media queries should be known`,
rule,
code,
expectedWarnings: [
{
line: 10,
column: 9,
endLine: 10,
endColumn: 18,
rule,
severity: `error`,
text: `Unexpected unknown custom media "--invalid" (${rule})`,
},
{
line: 12,
column: 9,
endLine: 12,
endColumn: 18,
rule,
severity: `error`,
text: `Unexpected unknown custom media "--invalid" (${rule})`,
},
],
})

0 comments on commit 841b5ea

Please sign in to comment.