From 83c71fc68478e3d3d180cf4cf2202a17abb2d89a Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 27 Jun 2023 09:18:27 +0200 Subject: [PATCH 1/2] Fix `function-linear-gradient-no-nonstandard-direction` false positives for `` --- .../__tests__/index.js | 16 ++++++++++++++++ .../index.js | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.js b/lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.js index 20980f0498..53219b51a7 100644 --- a/lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.js +++ b/lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.js @@ -55,6 +55,12 @@ testRule({ { code: '.foo { background: linear-gradient(black, white); }', }, + { + code: '.foo { background: linear-gradient(in srgb to top, #fff, #000); }', + }, + { + code: '.foo { background: linear-gradient(to top in srgb, #fff, #000); }', + }, { code: '.foo { background: linear-gradient(rgba(255, 255, 255, 0.5) 0%, #000); }', }, @@ -196,6 +202,16 @@ testRule({ endLine: 1, endColumn: 41, }, + { + code: '.foo { background: linear-gradient(topin, #fff, #000); }', + description: + 'An incorrect direction that contains the word "in", only "in" as a word on its own is ignored by this rule.', + message: messages.rejected, + line: 1, + column: 36, + endLine: 1, + endColumn: 41, + }, { code: '.foo { background: -webkit-linear-gradient(to bottom, #fff, #000 ); }', message: messages.rejected, diff --git a/lib/rules/function-linear-gradient-no-nonstandard-direction/index.js b/lib/rules/function-linear-gradient-no-nonstandard-direction/index.js index 850d40e46b..f97679b2af 100644 --- a/lib/rules/function-linear-gradient-no-nonstandard-direction/index.js +++ b/lib/rules/function-linear-gradient-no-nonstandard-direction/index.js @@ -29,6 +29,7 @@ const DIRECTION_WITHOUT_TO = new RegExp(`^(${DIRECTION.source})(?: (${DIRECTION. const DIGIT = /[\d.]/; const ANGLE = /^[\d.]+(?:deg|grad|rad|turn)$/; +const IN_KEYWORD = /\bin\b/i; /** * @param {string} source @@ -84,6 +85,11 @@ const rule = (primary) => { return; } + // Ignore gradients with modern syntax that have color space interpolation arguments + if (IN_KEYWORD.test(firstArg)) { + return; + } + // If the first character is a number, we can assume the user intends an angle if (DIGIT.test(firstArg.charAt(0))) { if (ANGLE.test(firstArg)) { From 274a7c7b3c97567fa7a929efb6a72f2cd5f14227 Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Tue, 27 Jun 2023 09:19:46 +0200 Subject: [PATCH 2/2] Create strong-cycles-raise.md --- .changeset/strong-cycles-raise.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/strong-cycles-raise.md diff --git a/.changeset/strong-cycles-raise.md b/.changeset/strong-cycles-raise.md new file mode 100644 index 0000000000..fe9a1987dd --- /dev/null +++ b/.changeset/strong-cycles-raise.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `function-linear-gradient-no-nonstandard-direction` false positives for ``