Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/postcss-8.4.35
- Loading branch information
Showing
54 changed files
with
1,301 additions
and
3,736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
# How to add tests | ||
|
||
* Create your test file named after the scss lint your you are adding a stylelint rule for. For example, `__tests___/unit/bang-format.spec.js` | ||
* Create your test file named after the scss lint your you are adding a stylelint rule for. For example, `__tests___/unit/bang-format.test.mjs` | ||
* Copy the code from one of the other tests into your test new file | ||
* Update the test so you have .scss code that will produce lint you want to test for | ||
* Add a console.log statement within the checkResult function in the test file passing `result` to the log statement. e.g. `console.log(result)` | ||
* Look for warnings it generates | ||
* Copy expected text to test file | ||
* Escape quotes in your expected error text | ||
* Run tests again and refine until they pass | ||
* Update `t.plan(2)` to the number of tests you have |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with border none', () => { | ||
const invalidScss = ( | ||
`.borderzero { | ||
border: none; | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected value "none" for property "border" (declaration-property-value-disallowed-list)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'declaration-property-value-disallowed-list', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with named color keyword', () => { | ||
const invalidScss = ( | ||
`.colorkeyword { | ||
color: green; | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected named color "green" (color-named)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'color-named', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with debug statement scss', () => { | ||
const invalidScss = ( | ||
`$color-blue: #1c94c6; | ||
.debug { | ||
@debug $color-blue; | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected at-rule "debug" (at-rule-disallowed-list)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'at-rule-disallowed-list', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with missing empty line between blocks', () => { | ||
const invalidScss = ( | ||
`p { | ||
margin: 0; | ||
em { | ||
color: #f00; | ||
} | ||
} | ||
a { | ||
color: #f00; | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 2); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Expected empty line before rule (rule-empty-line-before)', | ||
'Expected empty line before rule (rule-empty-line-before)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'rule-empty-line-before', | ||
'rule-empty-line-before', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with empty rule', () => { | ||
const invalidScss = ( | ||
`.cat { | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected empty block (block-no-empty)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'block-no-empty', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with hex color length', () => { | ||
const invalidScss = ( | ||
`.hexlength { | ||
color: #ff22ee; | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Expected "#ff22ee" to be "#f2e" (color-hex-length)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'color-hex-length', | ||
], | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
describe('flags warnings with hex validation', () => { | ||
const invalidScss = ( | ||
`.hex-validation { | ||
background: #ab; // Clearly a typo | ||
} | ||
`); | ||
|
||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected invalid hex color "#ab" (color-no-invalid-hex)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'color-no-invalid-hex', | ||
], | ||
); | ||
}); | ||
}); |
Oops, something went wrong.