Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back stylistic rules removed in v10
- Loading branch information
Showing
59 changed files
with
1,740 additions
and
141 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,8 +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.test.mjs` | ||
* Create your test file named after the scss lint your you are adding a stylelint rule for. For example, `__tests___/color-hex-case.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 | ||
* Update the test so you have SCSS code that will produce lint you want to test for | ||
* Look for warnings it generates | ||
* Copy expected text to test file | ||
* Run tests again and refine until they pass |
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 |
---|---|---|
@@ -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 at-rule-no-unknown lint', () => { | ||
const invalidScss = ( | ||
`@unknown { color: #fff; } | ||
`); | ||
|
||
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 unknown at-rule "@unknown" (scss/at-rule-no-unknown)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'scss/at-rule-no-unknown', | ||
], | ||
); | ||
}); | ||
}); |
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 at-rule-no-vendor-prefix lint', () => { | ||
const invalidScss = ( | ||
`@-webkit-keyframes anim { | ||
0% { | ||
opacity: 0; | ||
} | ||
} | ||
`); | ||
|
||
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 vendor-prefixed at-rule "@-webkit-keyframes" (at-rule-no-vendor-prefix)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'at-rule-no-vendor-prefix', | ||
], | ||
); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 block-opening-brace-space-before lint', () => { | ||
const invalidScss = ( | ||
`.test-selector{ color: #fff; } | ||
.test-selector | ||
{ color: #fff; } | ||
`); | ||
|
||
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 single space before "{" (@stylistic/block-opening-brace-space-before)', | ||
'Expected single space before "{" (@stylistic/block-opening-brace-space-before)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'@stylistic/block-opening-brace-space-before', | ||
'@stylistic/block-opening-brace-space-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,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 color-hex-case lint', () => { | ||
const invalidScss = ( | ||
`.test-selector { | ||
color: #FFF; | ||
} | ||
`); | ||
|
||
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 "#FFF" to be "#fff" (@stylistic/color-hex-case)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'@stylistic/color-hex-case', | ||
], | ||
); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 declaration-bang-space-after lint', () => { | ||
const invalidScss = ( | ||
`.test-selector { color: #fff ! important; } | ||
.test-selector { color: #fff! important; } | ||
`); | ||
|
||
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, 3); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unexpected whitespace after "!" (@stylistic/declaration-bang-space-after)', | ||
'Unexpected whitespace after "!" (@stylistic/declaration-bang-space-after)', | ||
'Expected single space before "!" (@stylistic/declaration-bang-space-before)' | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'@stylistic/declaration-bang-space-after', | ||
'@stylistic/declaration-bang-space-after', | ||
'@stylistic/declaration-bang-space-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,50 @@ | ||
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 declaration-bang-space-before lint', () => { | ||
const invalidScss = ( | ||
`.test-selector { color: #fff!important; } | ||
.test-selector { color: #fff !important; } | ||
`); | ||
|
||
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 single space before "!" (@stylistic/declaration-bang-space-before)', | ||
'Expected single space before "!" (@stylistic/declaration-bang-space-before)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'@stylistic/declaration-bang-space-before', | ||
'@stylistic/declaration-bang-space-before', | ||
], | ||
); | ||
}); | ||
}); |
Oops, something went wrong.