From d0b933fc3c223bd8abe580c6a3bf3f9d79428ccf Mon Sep 17 00:00:00 2001 From: Krister Kari Date: Wed, 7 May 2025 22:40:25 +0300 Subject: [PATCH] Enable scss/function-color-channel rule --- __tests__/index.test.mjs | 20 ++++++++++++++------ __tests__/invalid.scss | 4 ++++ __tests__/valid.scss | 4 ++++ index.js | 8 ++------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/__tests__/index.test.mjs b/__tests__/index.test.mjs index 8a96fbe..cdb5c09 100644 --- a/__tests__/index.test.mjs +++ b/__tests__/index.test.mjs @@ -42,30 +42,38 @@ describe('flags warnings with invalid scss', () => { assert.equal(result.errored, true); }); - it('flags one warning', () => { - assert.equal(result.results[0].warnings.length, 1); + it('flags two warnings', () => { + assert.equal(result.results[0].warnings.length, 2); }); - it('correct warning text', () => { + it('correct warning texts', () => { assert.equal( result.results[0].warnings[0].text, 'Expected @if not statement rather than @if statement == null (scss/at-if-no-null)', ); + assert.equal( + result.results[0].warnings[1].text, + 'Expected the color.channel function to be used (scss/function-color-channel)', + ); }); - it('correct rule flagged', () => { + it('correct rules flagged', () => { assert.equal(result.results[0].warnings[0].rule, 'scss/at-if-no-null'); + assert.equal(result.results[0].warnings[1].rule, 'scss/function-color-channel'); }); it('correct severity flagged', () => { assert.equal(result.results[0].warnings[0].severity, 'error'); + assert.equal(result.results[0].warnings[1].severity, 'error'); }); - it('correct line number', () => { + it('correct line numbers', () => { assert.equal(result.results[0].warnings[0].line, 1); + assert.equal(result.results[0].warnings[1].line, 4); }); - it('correct column number', () => { + it('correct column numbers', () => { assert.equal(result.results[0].warnings[0].column, 5); + assert.equal(result.results[0].warnings[1].column, 14); }); }); diff --git a/__tests__/invalid.scss b/__tests__/invalid.scss index 3b9e481..5b30c61 100644 --- a/__tests__/invalid.scss +++ b/__tests__/invalid.scss @@ -1 +1,5 @@ @if $x == null { color: red; } + +p { + opacity: color.alpha(rgb(210, 225, 221, 0.4)); +} diff --git a/__tests__/valid.scss b/__tests__/valid.scss index 7282be6..455722a 100644 --- a/__tests__/valid.scss +++ b/__tests__/valid.scss @@ -156,3 +156,7 @@ $global-variable: first global value; from { opacity: 0%; } to { opacity: 100%; } } + +p { + opacity: color.channel(rgb(210, 225, 221, 0.4), "alpha"); +} diff --git a/index.js b/index.js index 98dfa2e..17f87ff 100644 --- a/index.js +++ b/index.js @@ -19,12 +19,7 @@ module.exports = { 'function-no-unknown': null, 'media-feature-name-value-no-unknown': null, 'media-query-no-invalid': null, - 'no-invalid-position-at-import-rule': [ - true, - { - ignoreAtRules: ['use', 'forward'], - }, - ], + 'no-invalid-position-at-import-rule': [true, { ignoreAtRules: ['use', 'forward'] }], 'string-no-newline': true, 'unit-no-unknown': true, 'scss/at-extend-no-missing-placeholder': true, @@ -33,6 +28,7 @@ module.exports = { 'scss/comment-no-empty': true, 'scss/declaration-nested-properties-no-divided-groups': true, 'scss/dollar-variable-no-missing-interpolation': true, + 'scss/function-color-channel': true, 'scss/function-quote-no-quoted-strings-inside': true, 'scss/function-unquote-no-unquoted-strings-inside': true, 'scss/load-no-partial-leading-underscore': true,