From 0079b71799178a832cea42e5801381b6ad497115 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Fri, 19 May 2023 20:42:48 +0900 Subject: [PATCH] Change more suitable examples in `unit-no-unknown` doc The `unit-no-unknown` rule handles the `image-set()` function and the `x` unit. So, specifying `image-set` to the `ignoreFunctions` option doesn't make sense. Additionally, this change removes duplication in the test for `unit-no-unknown`. See also the demo: https://stylelint.io/demo/#N4Igxg9gJgpiBcICGACYAdAdilAjJYA1gOYBOEArplALQCWAtksTPCo8zDQM4wAuACiw4cAcgD0HFt3HcIDLlK4BGAB4A6AFYAHYqJRqANMJESlMuQvpMWNAEwadelA+PZTkmzAvzFXmgDMjrr6QSYAlADcWAC+IIYgAGZ0ADYwAHJICgggMKpZ2mnqYNzc8eAQmMnEORju6CCkFGncDWx1IigNVHR8NJgQNFSEAwDumG0ofE0wJjGx5ZBVdMQAYhCkTHw5mnKY5bDaZYgdXSDcfACeaSl0mHyTDSlIfN4P8SYNF9cwt-c0S2qPD4SGoSFIUEeIGerwuDQWMSAA --- lib/rules/unit-no-unknown/README.md | 20 ++-------- lib/rules/unit-no-unknown/__tests__/index.js | 41 ++------------------ 2 files changed, 8 insertions(+), 53 deletions(-) diff --git a/lib/rules/unit-no-unknown/README.md b/lib/rules/unit-no-unknown/README.md index c6b70f503b..4221adb1b1 100644 --- a/lib/rules/unit-no-unknown/README.md +++ b/lib/rules/unit-no-unknown/README.md @@ -94,7 +94,7 @@ a { Given: ```json -["image-set", "/^my-/", "/^YOUR-/i"] +["foo", "/^my-/", "/^YOUR-/i"] ``` The following patterns are _not_ considered problems: @@ -102,32 +102,20 @@ The following patterns are _not_ considered problems: ```css a { - background-image: image-set( - '/images/some-image-1x.jpg' 1x, - '/images/some-image-2x.jpg' 2x, - '/images/some-image-3x.jpg' 3x - ); + width: foo(1x); } ``` ```css a { - background-image: my-image-set( - '/images/some-image-1x.jpg' 1x, - '/images/some-image-2x.jpg' 2x, - '/images/some-image-3x.jpg' 3x - ); + width: my-func(1x); } ``` ```css a { - background-image: YoUr-image-set( - '/images/some-image-1x.jpg' 1x, - '/images/some-image-2x.jpg' 2x, - '/images/some-image-3x.jpg' 3x - ); + width: YoUr-func(1x); } ``` diff --git a/lib/rules/unit-no-unknown/__tests__/index.js b/lib/rules/unit-no-unknown/__tests__/index.js index c78cceeb72..12ade3fc03 100644 --- a/lib/rules/unit-no-unknown/__tests__/index.js +++ b/lib/rules/unit-no-unknown/__tests__/index.js @@ -597,50 +597,17 @@ testRule({ testRule({ ruleName, - config: [true, { ignoreFunctions: ['image-set', '/^my-/', '/^YOUR-/i'] }], + config: [true, { ignoreFunctions: ['foo', '/^my-/', '/^YOUR-/i'] }], accept: [ { - code: "a { background-image: image-set('/images/some-image-1x.jpg' 1x,'/images/some-image-2x.jpg' 2x,'/images/some-image-3x.jpg' 3x,); }", + code: 'a { width: foo(1x); }', }, { - code: "a { background-image: my-image-set('/images/some-image-1x.jpg' 1x,'/images/some-image-2x.jpg' 2x,'/images/some-image-3x.jpg' 3x,); }", + code: 'a { width: my-func(1x); }', }, { - code: "a { background-image: YoUr-image-set('/images/some-image-1x.jpg' 1x,'/images/some-image-2x.jpg' 2x,'/images/some-image-3x.jpg' 3x,); }", - }, - ], - - reject: [ - { - code: 'a { margin: calc(10pixels + 1pixels); }', - warnings: [ - { - message: messages.rejected('pixels'), - line: 1, - column: 20, - endLine: 1, - endColumn: 26, - }, - { - message: messages.rejected('pixels'), - line: 1, - column: 30, - endLine: 1, - endColumn: 36, - }, - ], - }, - ], -}); - -testRule({ - ruleName, - config: [true, { ignoreFunctions: [/^my-/] }], - - accept: [ - { - code: "a { background-image: my-image-set('/images/some-image-1x.jpg' 1x,'/images/some-image-2x.jpg' 2x,'/images/some-image-3x.jpg' 3x,); }", + code: 'a { width: YoUr-func(1x); }', }, ],