diff --git a/__tests__/block-opening-brace-space-before.test.mjs b/__tests__/block-opening-brace-space-before.test.mjs index 7197736..9fcd1c7 100644 --- a/__tests__/block-opening-brace-space-before.test.mjs +++ b/__tests__/block-opening-brace-space-before.test.mjs @@ -50,3 +50,28 @@ describe('flags warnings with block-opening-brace-space-before lint', () => { ); }); }); + +describe('does not flag warnings with valid block-opening-brace-space-before', () => { + const validScss = ( +`.test-selector { + color: #fff; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); \ No newline at end of file diff --git a/__tests__/color-hex-case.test.mjs b/__tests__/color-hex-case.test.mjs index 97fd572..855fae6 100644 --- a/__tests__/color-hex-case.test.mjs +++ b/__tests__/color-hex-case.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with color-hex-case lint', () => { ); }); }); + +describe('does not flag warnings with valid color-hex-case', () => { + const validScss = ( +`.test-selector { + color: #fff; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/color-hex-length.test.mjs b/__tests__/color-hex-length.test.mjs index 0720d71..5694588 100644 --- a/__tests__/color-hex-length.test.mjs +++ b/__tests__/color-hex-length.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with color-hex-length lint', () => { ); }); }); + +describe('does not flag warnings with valid color-hex-length', () => { + const validScss = ( +`.test-selector { + color: #fff; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-bang-space-after.test.mjs b/__tests__/declaration-bang-space-after.test.mjs index 8dd5a1c..937e9a1 100644 --- a/__tests__/declaration-bang-space-after.test.mjs +++ b/__tests__/declaration-bang-space-after.test.mjs @@ -50,3 +50,28 @@ describe('flags warnings with declaration-bang-space-after lint', () => { ); }); }); + +describe('does not flag warnings with valid declaration-bang-space-after', () => { + const validScss = ( +`.test-selector { + color: #000 !important; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-bang-space-before.test.mjs b/__tests__/declaration-bang-space-before.test.mjs index 96b5e30..fe3f473 100644 --- a/__tests__/declaration-bang-space-before.test.mjs +++ b/__tests__/declaration-bang-space-before.test.mjs @@ -48,3 +48,28 @@ describe('flags warnings with declaration-bang-space-before lint', () => { ); }); }); + +describe('does not flag warnings with valid declaration-bang-space-before', () => { + const validScss = ( +`.test-selector { + color: #000 !important; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-block-semicolon-newline-after.test.mjs b/__tests__/declaration-block-semicolon-newline-after.test.mjs index 13acbe8..f6b5946 100644 --- a/__tests__/declaration-block-semicolon-newline-after.test.mjs +++ b/__tests__/declaration-block-semicolon-newline-after.test.mjs @@ -47,3 +47,30 @@ describe('flags warnings with declaration-block-semicolon-newline-after lint', ( ); }); }); + +describe('does not flag warnings with valid declaration-block-semicolon-newline-after', () => { + const validScss = ( +`.test-selector { + color: #fff; + border: 0; +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-block-single-line-max-declarations.test.mjs b/__tests__/declaration-block-single-line-max-declarations.test.mjs index 18da2ba..84e0dcb 100644 --- a/__tests__/declaration-block-single-line-max-declarations.test.mjs +++ b/__tests__/declaration-block-single-line-max-declarations.test.mjs @@ -48,3 +48,26 @@ describe('flags warnings with declaration-block-single-line-max-declarations lin ); }); }); + +describe('does not flag warnings with valid declaration-block-single-line-max-declarations', () => { + const validScss = ( +`.test-selector { color: #000; } +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-colon-space-after.test.mjs b/__tests__/declaration-colon-space-after.test.mjs index 9037b0f..a6b2030 100644 --- a/__tests__/declaration-colon-space-after.test.mjs +++ b/__tests__/declaration-colon-space-after.test.mjs @@ -47,3 +47,26 @@ describe('flags warnings with declaration-colon-space-after lint', () => { ); }); }); + +describe('does not flag warnings with valid declaration-colon-space-after', () => { + const validScss = ( +`.test-selector { color: #fff; } +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/declaration-colon-space-before.test.mjs b/__tests__/declaration-colon-space-before.test.mjs index 4c91099..af51eff 100644 --- a/__tests__/declaration-colon-space-before.test.mjs +++ b/__tests__/declaration-colon-space-before.test.mjs @@ -55,3 +55,26 @@ describe('flags warnings with declaration-colon-space-before lint', () => { ); }); }); + +describe('does not flag warnings with valid declaration-colon-space-before', () => { + const validScss = ( +`.test-selector { color: #fff; } +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); \ No newline at end of file diff --git a/__tests__/function-comma-space-after.test.mjs b/__tests__/function-comma-space-after.test.mjs index d7f9cdb..dce6441 100644 --- a/__tests__/function-comma-space-after.test.mjs +++ b/__tests__/function-comma-space-after.test.mjs @@ -48,3 +48,29 @@ describe('flags warnings with function-comma-space-after lint', () => { ); }); }); + +describe('does not flag warnings with valid function-comma-space-after', () => { + const validScss = ( +`.test-selector { + @include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2)); + color: rgba(0, 0, 0, 0.1); +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/function-parentheses-space-inside.test.mjs b/__tests__/function-parentheses-space-inside.test.mjs index 6b79ef3..c8c61b9 100644 --- a/__tests__/function-parentheses-space-inside.test.mjs +++ b/__tests__/function-parentheses-space-inside.test.mjs @@ -50,3 +50,29 @@ describe('flags warnings with function-parentheses-space-inside lint', () => { ); }); }); + +describe('does not flag warnings with valid function-parentheses-space-inside', () => { + const validScss = ( +`.test-selector { + @include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2)); + color: rgba(0, 0, 0, 0.1); +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); \ No newline at end of file diff --git a/__tests__/function-url-quotes.test.mjs b/__tests__/function-url-quotes.test.mjs index e4a90d1..437ebbd 100644 --- a/__tests__/function-url-quotes.test.mjs +++ b/__tests__/function-url-quotes.test.mjs @@ -47,3 +47,29 @@ describe('flags warnings with function-url-quotes lint', () => { ); }); }); + +describe('does not flag warnings with valid function-url-quotes', () => { + const validScss = ( +`.test-selector { + background: url('example.png'); +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/indentation.test.mjs b/__tests__/indentation.test.mjs index ac74957..aaa0e10 100644 --- a/__tests__/indentation.test.mjs +++ b/__tests__/indentation.test.mjs @@ -47,3 +47,28 @@ color: #fff; ); }); }); + +describe('does not flag warnings with valid indentation', () => { + const validScss = ( +`.test-selector { + color: #000; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/length-zero-no-unit.test.mjs b/__tests__/length-zero-no-unit.test.mjs index a2f1eac..8be249e 100644 --- a/__tests__/length-zero-no-unit.test.mjs +++ b/__tests__/length-zero-no-unit.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with length-zero-no-unit lint', () => { ); }); }); + +describe('does not flag warnings with valid length-zero-no-unit', () => { + const validScss = ( +`.test-selector { + margin: 0; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/media-feature-parentheses-space-inside.test.mjs b/__tests__/media-feature-parentheses-space-inside.test.mjs index 6e2073d..974fbd9 100644 --- a/__tests__/media-feature-parentheses-space-inside.test.mjs +++ b/__tests__/media-feature-parentheses-space-inside.test.mjs @@ -51,3 +51,30 @@ describe('flags warnings with media-feature-parentheses-space-inside lint', () = ); }); }); + +describe('does not flag warnings with valid media-feature-parentheses-space-inside', () => { + const validScss = ( +`@media (max-width: 300px) { + .media-parens { + margin: 0; + } +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/misc-valid-scss.test.mjs b/__tests__/misc-valid-scss.test.mjs new file mode 100644 index 0000000..2084755 --- /dev/null +++ b/__tests__/misc-valid-scss.test.mjs @@ -0,0 +1,101 @@ +import { beforeEach, describe, it } from 'node:test'; +import assert from 'node:assert/strict'; + +import stylelint from 'stylelint'; + +import config from '../index.js'; + +describe('does not error or warn on valid scss', () => { + const invalidScss = ( +`// DeclarationOrder test +// scss-lint:disable NestingDepth +.declarationorder { + @extend %error; + @include message-box(); + + color: #f00; + + p { + color: #f00; + } +} +// scss-lint:enable NestingDepth + +// ElsePlacement test +$width: auto; + +.elseplacement { + @if $width == 'auto' { + width: $width; + } @else { + display: inline-block; + width: $width; + } +} + +// EmptyLineBetweenBlocks test +// scss-lint:disable NestingDepth +p { + margin: 0; + + em { + color: #f00; + } +} + +a { + color: #f00; +} +// scss-lint:enable NestingDepth + + +// NameFormat Mixins test +// Mixins should be declared with all lowercase letters and hyphens instead of underscores. + +@mixin my-mixin() { + color: #fff; +} + +// Private Naming Convention test +// Enforces that functions, mixins, and variables that follow the private naming convention (default to underscore-prefixed, e.g. $_foo) are defined and used within the same file. + +$_foo: #f00; + +figure { + color: $_foo; +} + +// SpaceAroundOperator test +.spacearoundoperator { + margin: 5px + 10px; + padding: 5px + 10px; +} + +// Each loop test +.button { + @each $key, $value in $colors { + &-#{$key} { + background-color: $value; + } + } +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: invalidScss, + config, + }); + }); + + it('did not error', () => { + // console.log('result.results[0].warnings', result.results[0].warnings); + assert.equal(result.errored, false); + }); + + it('flags no warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/number-leading-zero.test.mjs b/__tests__/number-leading-zero.test.mjs index cd2802a..f4b6636 100644 --- a/__tests__/number-leading-zero.test.mjs +++ b/__tests__/number-leading-zero.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with number-leading-zero lint', () => { ); }); }); + +describe('does not flag warnings with valid number-leading-zero', () => { + const validScss = ( +`.test-selector { + line-height: 0.5em; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/number-no-trailing-zeros.test.mjs b/__tests__/number-no-trailing-zeros.test.mjs index 392eef0..94a19aa 100644 --- a/__tests__/number-no-trailing-zeros.test.mjs +++ b/__tests__/number-no-trailing-zeros.test.mjs @@ -47,3 +47,29 @@ describe('flags warnings with number-no-trailing-zeros lint', () => { ); }); }); + + +describe('does not flag warnings with valid number-no-trailing-zeros', () => { + const validScss = ( +`.test-selector { + top: 1px; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-at-function-pattern.test.mjs b/__tests__/scss-at-function-pattern.test.mjs index c7a1a3d..ca66bd2 100644 --- a/__tests__/scss-at-function-pattern.test.mjs +++ b/__tests__/scss-at-function-pattern.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with scss/at-function-pattern lint', () => { ); }); }); + +describe('does not flag warnings with valid scss/at-function-pattern', () => { + const validScss = ( +`@function calculation-function($some-number, $another-number) { + @return $some-number + $another-number; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-at-import-partial-extension-disallowed-list.test.mjs b/__tests__/scss-at-import-partial-extension-disallowed-list.test.mjs index 3df8c29..1321020 100644 --- a/__tests__/scss-at-import-partial-extension-disallowed-list.test.mjs +++ b/__tests__/scss-at-import-partial-extension-disallowed-list.test.mjs @@ -58,3 +58,27 @@ describe('flags warnings with scss/at-import-partial-extension-disallowed-list l ); }); }); + +describe('does not flag warnings with valid scss/at-import-partial-extension-disallowed-list lint', () => { + const validScss = ( +`@import 'foo/bar'; +@import 'bar'; +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-dollar-variable-colon-space-after.test.mjs b/__tests__/scss-dollar-variable-colon-space-after.test.mjs index bc0d3b1..59f0004 100644 --- a/__tests__/scss-dollar-variable-colon-space-after.test.mjs +++ b/__tests__/scss-dollar-variable-colon-space-after.test.mjs @@ -46,3 +46,27 @@ describe('flags warnings with scss/dollar-variable-colon-space-after lint', () = ); }); }); + +describe('does not flag warnings with valid scss/dollar-variable-colon-space-after', () => { + const validScss = ( +`a { $var: 10px;} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); \ No newline at end of file diff --git a/__tests__/scss-dollar-variable-colon-space-before.test.mjs b/__tests__/scss-dollar-variable-colon-space-before.test.mjs index d1ef046..49b5dc2 100644 --- a/__tests__/scss-dollar-variable-colon-space-before.test.mjs +++ b/__tests__/scss-dollar-variable-colon-space-before.test.mjs @@ -46,3 +46,27 @@ describe('flags warnings with scss/dollar-variable-colon-space-before lint', () ); }); }); + +describe('does not flag warnings with valid scss/dollar-variable-colon-space-after', () => { + const validScss = ( +`a { $var: 10px;} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-dollar-variable-pattern.test.mjs b/__tests__/scss-dollar-variable-pattern.test.mjs index baba25d..c0e67b9 100644 --- a/__tests__/scss-dollar-variable-pattern.test.mjs +++ b/__tests__/scss-dollar-variable-pattern.test.mjs @@ -45,3 +45,27 @@ describe('flags warnings with invalid scss/dollar-variable-pattern lint', () => ); }); }); + +describe('does not flag warnings with valid scss/dollar-variable-pattern lint', () => { + const validScss = ( +`$my-var: 10px; + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-percent-placeholder-pattern.mjs b/__tests__/scss-percent-placeholder-pattern.mjs index 3f40944..c07a37f 100644 --- a/__tests__/scss-percent-placeholder-pattern.mjs +++ b/__tests__/scss-percent-placeholder-pattern.mjs @@ -47,3 +47,29 @@ describe('flags warnings with scss/percent-placeholder-pattern lint', () => { ); }); }); + +describe('does not flag warnings with valid scss/percent-placeholder-pattern lint', () => { + const validScss = ( +`%place-holder { + color: #f00; +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/scss-selector-no-redundant-nesting-selector.test.mjs b/__tests__/scss-selector-no-redundant-nesting-selector.test.mjs index ff01f40..ecd6411 100644 --- a/__tests__/scss-selector-no-redundant-nesting-selector.test.mjs +++ b/__tests__/scss-selector-no-redundant-nesting-selector.test.mjs @@ -49,3 +49,31 @@ describe('flags warnings with scss/selector-no-redundant-nesting-selector lint', ); }); }); + +describe('does not flag warnings with valid scss/selector-no-redundant-nesting-selector lint', () => { + const validScss = ( +`.parentreference { + > .bar { + color: #f00; + } +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); \ No newline at end of file diff --git a/__tests__/selector-class-pattern.test.mjs b/__tests__/selector-class-pattern.test.mjs index abb05c3..4295dcc 100644 --- a/__tests__/selector-class-pattern.test.mjs +++ b/__tests__/selector-class-pattern.test.mjs @@ -71,3 +71,113 @@ describe('flags warnings with selector-class-pattern lint', () => { ); }); }); + +describe('does not flag warnings with valid selector-class-pattern', () => { + const validScss = ( +`.selector-format { + color: #f00; +} + +.foo { + color: #f00; +} + +.foo5 { + color: #f00; +} + +.foo-5 { + color: #f00; +} + +.foo--5 { + color: #f00; +} + +.foo-bar { + color: #f00; +} + +.foo--bar { + color: #f00; +} + +.foo-bar-5 { + color: #f00; +} + +.foo-bar-baz { + color: #f00; +} + +.foo-bar--baz { + color: #f00; +} + +.foo-bar-baz--qux { + color: #f00; +} + +.foo-bar--baz--qux { + color: #f00; +} + +.foo--bar--baz--qux { + color: #f00; +} + +.u-hidden { + color: #f00; +} + +.u-class-name { + color: #f00; +} + +.is-stateclass { + color: #f00; +} + +.has-state-class { + color: #f00; +} + +.js-dependantclass { + color: #f00; +} + +.namespace-u-text-center { + color: #f00; +} + +.namespace-u-sm-size11of12 { + color: #f00; +} + +.u-foobar17 { + color: #f00; +} + +.u-16by9 { + color: #f00; +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/selector-list-comma-newline-after.test.mjs b/__tests__/selector-list-comma-newline-after.test.mjs index 0d93c2e..619d37c 100644 --- a/__tests__/selector-list-comma-newline-after.test.mjs +++ b/__tests__/selector-list-comma-newline-after.test.mjs @@ -54,3 +54,30 @@ a ); }); }); + +describe('does not flag warnings with valid selector-list-comma-newline-after', () => { + const validScss = ( +`a, +b { + color: #fff; +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/selector-pseudo-element-colon-notation.test.mjs b/__tests__/selector-pseudo-element-colon-notation.test.mjs index e0f2a6b..e012235 100644 --- a/__tests__/selector-pseudo-element-colon-notation.test.mjs +++ b/__tests__/selector-pseudo-element-colon-notation.test.mjs @@ -53,3 +53,33 @@ p::hover { ); }); }); + +describe('does not flag warnings with valid selector-pseudo-element-colon-notation lint', () => { + const validScss = ( +`a::before { + content: '>'; +} + +a:hover { + color: #f00; +} + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/selector-pseudo-element-no-unknown.test.mjs b/__tests__/selector-pseudo-element-no-unknown.test.mjs index 6d3f2c1..4dac5a6 100644 --- a/__tests__/selector-pseudo-element-no-unknown.test.mjs +++ b/__tests__/selector-pseudo-element-no-unknown.test.mjs @@ -10,6 +10,7 @@ describe('flags warnings with selector-pseudo-element-no-unknown lint', () => { `p::hover { color: #f00; } + `); let result; diff --git a/__tests__/shorthand-property-no-redundant-values.test.mjs b/__tests__/shorthand-property-no-redundant-values.test.mjs index 2ee1235..fd7872a 100644 --- a/__tests__/shorthand-property-no-redundant-values.test.mjs +++ b/__tests__/shorthand-property-no-redundant-values.test.mjs @@ -47,3 +47,28 @@ describe('flags warnings with shorthand-property-no-redundant-values lint', () = ); }); }); + +describe('does not flag warnings with valid shorthand-property-no-redundant-values', () => { + const validScss = ( +`.shorthand { + margin: 1px; +} +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/string-quotes.test.mjs b/__tests__/string-quotes.test.mjs index c76de18..536df3b 100644 --- a/__tests__/string-quotes.test.mjs +++ b/__tests__/string-quotes.test.mjs @@ -49,3 +49,30 @@ describe('flags warnings with string-quotes lint', () => { ); }); }); + +describe('does not flag warnings with valid string-quotes', () => { + const validScss = ( +`.test-selector { + content: 'test'; +} + + +`); + + let result; + + beforeEach(async () => { + result = await stylelint.lint({ + code: validScss, + config, + }); + }); + + it('did not error', () => { + assert.equal(result.errored, false); + }); + + it('does not flag warnings', () => { + assert.equal(result.results[0].warnings.length, 0); + }); +}); diff --git a/__tests__/valid-scss.test.mjs b/__tests__/valid-scss.test.mjs deleted file mode 100644 index b84967c..0000000 --- a/__tests__/valid-scss.test.mjs +++ /dev/null @@ -1,356 +0,0 @@ -import { beforeEach, describe, it } from 'node:test'; -import assert from 'node:assert/strict'; - -import stylelint from 'stylelint'; - -import config from '../index.js'; - -describe('does not error or warn on valid scss', () => { - const invalidScss = ( -`// Bang Format test -.bangformat { - color: #000 !important; -} - -// BEM Depth test -// scss-lint:disable SelectorFormat -/* stylelint-disable selector-class-pattern */ -.block__element { - color: #f00; -} -/* stylelint-enable selector-class-pattern */ -// scss-lint:enable SelectorFormat - -// Border Zero test -.borderzero { - border: 0; -} - -// Color Keyword test -.colorkeyword { - color: #0f0; -} - -// Debug statement test - -// DeclarationOrder test -// scss-lint:disable NestingDepth -.declarationorder { - @extend %error; - @include message-box(); - - color: #f00; - - p { - color: #f00; - } -} -// scss-lint:enable NestingDepth - -// ElsePlacement test -$width: auto; - -.elseplacement { - @if $width == 'auto' { - width: $width; - } @else { - display: inline-block; - width: $width; - } -} - -// EmptyLineBetweenBlocks test -// scss-lint:disable NestingDepth -p { - margin: 0; - - em { - color: #f00; - } -} - -a { - color: #f00; -} -// scss-lint:enable NestingDepth - -// Hexlength test -.hexlength { - color: #f2e; -} - -// HexNotation test -.hexnotation { - color: #f00; -} - -// Import Path test -@import 'foo/bar'; -@import 'bar'; - -// Indentation test -.indentation { - color: #f00; -} -// No test for allow_non_nested_indentation - -// Leading Zero test -.leadingzero { - margin: 0.5em; -} - -// NameFormat test -// Functions, mixins, variables, and placeholders should be declared with all lowercase letters and hyphens instead of underscores. - -@function calculation-function($some-number, $another-number) { - @return $some-number + $another-number; -} - -@mixin my-mixin() { - color: #fff; -} - -$my-var: 10px; - -%place-holder { - color: #f00; -} - -// Private Naming Convention test -// Enforces that functions, mixins, and variables that follow the private naming convention (default to underscore-prefixed, e.g. $_foo) are defined and used within the same file. - -$_foo: #f00; - -figure { - color: $_foo; -} - -// PseudoElement test -a::before { - content: '>'; -} - -a:hover { - color: #f00; -} - -// Selector Format test -.selector-format { - color: #f00; -} - -.foo { - color: #f00; -} - -.foo5 { - color: #f00; -} - -.foo-5 { - color: #f00; -} - -.foo--5 { - color: #f00; -} - -.foo-bar { - color: #f00; -} - -.foo--bar { - color: #f00; -} - -.foo-bar-5 { - color: #f00; -} - -.foo-bar-baz { - color: #f00; -} - -.foo-bar--baz { - color: #f00; -} - -.foo-bar-baz--qux { - color: #f00; -} - -.foo-bar--baz--qux { - color: #f00; -} - -.foo--bar--baz--qux { - color: #f00; -} - -.u-hidden { - color: #f00; -} - -.u-class-name { - color: #f00; -} - -.is-stateclass { - color: #f00; -} - -.has-state-class { - color: #f00; -} - -.js-dependantclass { - color: #f00; -} - -.namespace-u-text-center { - color: #f00; -} - -.namespace-u-sm-size11of12 { - color: #f00; -} - -.u-foobar17 { - color: #f00; -} - -.u-16by9 { - color: #f00; -} - -// Shorthand test -.shorthand { - margin: 1px; -} - -// SingleLinePerProperty test -.singlelineproperty1 { - margin: 0; - padding: 0; -} - -// SingleLinePerSelector test -.error, -.explanation { - color: #f00; -} - -// SpaceAfterComma test -.spaceaftercomma { - @include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2)); - color: rgba(0, 0, 0, 0.1); -} - -// SpaceAfterPropertyColon test -.spaceafterpropertycolon { - margin: 0; - padding: 0; -} - -// SpaceAfterPropertyName test -.spaceafterpropertyname { - margin: 0; -} - -// SpaceAfterVariableColon test -$spaceaftervariblecolon: #fff; // No space - -// SpaceAfterVariableName test -$spaceaftervariblename: #f00; - -// SpaceAroundOperator test -.spacearoundoperator { - margin: 5px + 10px; - padding: 5px + 10px; -} - -// SpaceBeforeBrace test -.spacebeforebrace1 { - color: #f00; -} - -// SpaceBetweenParens test -.spacebetweenparens { - @include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2)); - color: rgba(0, 0, 0, 0.1); -} - -// StringQuotes test -.stringquotes { - content: 'hello'; -} - -// TrailingSemicolon test -.trailingsemicolon { - background-color: #fff; - color: #fff; -} - -// TrailingZero test -.trailingzero { - margin: 0.5em; -} - -// UnnecessaryMantissa test -.mantissa { - margin: 1em; -} - -// UnnecessaryParentReference test -// scss-lint:disable NestingDepth -.parentreference { - > .bar { - color: #f00; - } -} -// scss-lint:enable NestingDepth - -// UrlQuotes test -.quotes-url { - background: url('example.png'); -} - -// Zero Unit test -.zerounit { - margin: 0; -} - -// SpaceBetweenParens media query test -@media (max-width: 300px) { - .media-parens { - margin: 0; - } -} - -.button { - @each $key, $value in $colors { - &-#{$key} { - background-color: $value; - } - } -} -`); - - let result; - - beforeEach(async () => { - result = await stylelint.lint({ - code: invalidScss, - config, - }); - }); - - it('did not error', () => { - // console.log('result.results[0].warnings', result.results[0].warnings); - assert.equal(result.errored, false); - }); - - it('flags no warnings', () => { - assert.equal(result.results[0].warnings.length, 0); - }); -});