-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Stylelint and Configs to Latest Versions (#438)
- Updated `stylelint-config-suitcss` to v21 - Updated `stylelint-config-standard-scss` to v13 - Updated `stylelint` peer dependency to v16 - Refactored tests to use node:test, to match the core configs
- Loading branch information
1 parent
d3aa55b
commit 0dc6951
Showing
25 changed files
with
1,449 additions
and
3,599 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 was deleted.
Oops, something went wrong.
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,102 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../../index.js'; | ||
|
||
const validScss = readFileSync('./__tests__/cloudfour/valid.scss', 'utf-8'); | ||
const invalidScss = readFileSync('./__tests__/cloudfour/invalid.scss', 'utf-8'); | ||
|
||
describe('cloudfour test', () => { | ||
describe('flags no warnings with valid css', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('has no errors', () => { | ||
assert.equal(result.errored, false); | ||
}); | ||
|
||
it('flags no warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 0); | ||
}); | ||
|
||
// Useful for logging when unexpected warning text is flagged. | ||
it('no warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[], | ||
); | ||
}); | ||
|
||
// Useful for logging when unexpected rules are flagged. | ||
it('no rules flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[], | ||
); | ||
}); | ||
}); | ||
|
||
describe('flags warnings with invalid css', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('includes an error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 4); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Unnecessary nesting selector (&) (scss/selector-no-redundant-nesting-selector)', | ||
'Prefer @use and @forward rather than @import.', | ||
'Prefer @use and @forward rather than @import.', | ||
'Unexpected unknown property "weight" (property-no-unknown)', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'scss/selector-no-redundant-nesting-selector', | ||
'at-rule-disallowed-list', | ||
'at-rule-disallowed-list', | ||
'property-no-unknown', | ||
], | ||
); | ||
}); | ||
|
||
it('corrects severity flagged', () => { | ||
assert.equal(result.results[0].warnings[0].severity, 'error'); | ||
}); | ||
|
||
it('corrects line number', () => { | ||
assert.equal(result.results[0].warnings[0].line, 10); | ||
}); | ||
|
||
it('corrects column number', () => { | ||
assert.equal(result.results[0].warnings[0].column, 3); | ||
}); | ||
}); | ||
}); |
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,26 @@ | ||
import { describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
import { execFileSync } from 'node:child_process'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')); | ||
|
||
describe('engines.node', () => { | ||
it("is the same as stylelint's one", () => { | ||
const stylelintVersion = pkg.peerDependencies.stylelint; | ||
const nodeVersion = JSON.parse( | ||
execFileSync('npm', [ | ||
'view', | ||
'--json', | ||
`stylelint@${stylelintVersion}`, | ||
'engines.node', | ||
]).toString(), | ||
); | ||
|
||
// `^x.y.z` range can return multiple versions. | ||
const nodeVersions = Array.isArray(nodeVersion) ? [...new Set(nodeVersion)] : [nodeVersion]; | ||
|
||
assert.equal(nodeVersions.length, 1); | ||
assert.ok(nodeVersions.includes(pkg.engines.node)); | ||
}); | ||
}); |
74 changes: 0 additions & 74 deletions
74
__tests__/high-performance-animation/high-performance-animation.test.js
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
__tests__/high-performance-animation/high-performance-animation.test.mjs
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,92 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../../index.js'; | ||
|
||
const validCss = readFileSync('./__tests__/high-performance-animation/valid.css', 'utf-8'); | ||
const invalidCss = readFileSync('./__tests__/high-performance-animation/invalid.css', 'utf-8'); | ||
|
||
describe('stylelint-high-performance-animation', () => { | ||
describe('flags no warnings with valid css', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('has no errors', () => { | ||
assert.equal(result.errored, false); | ||
}); | ||
|
||
it('flags no warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 0); | ||
}); | ||
|
||
// Useful for logging when unexpected warning text is flagged. | ||
it('no warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[], | ||
); | ||
}); | ||
|
||
// Useful for logging when unexpected rules are flagged. | ||
it('no rules flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[], | ||
); | ||
}); | ||
}); | ||
|
||
describe('flags warnings with invalid css', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('includes an error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags one warning', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('corrects warning text', () => { | ||
assert.equal( | ||
result.results[0].warnings[0].text, | ||
'Unexpected use of low performance transition property (margin-left). (plugin/no-low-performance-animation-properties)', | ||
); | ||
}); | ||
|
||
it('corrects rule flagged', () => { | ||
assert.equal( | ||
result.results[0].warnings[0].rule, | ||
'plugin/no-low-performance-animation-properties', | ||
); | ||
}); | ||
|
||
it('corrects severity flagged', () => { | ||
assert.equal(result.results[0].warnings[0].severity, 'error'); | ||
}); | ||
|
||
it('corrects line number', () => { | ||
assert.equal(result.results[0].warnings[0].line, 2); | ||
}); | ||
|
||
it('corrects column number', () => { | ||
assert.equal(result.results[0].warnings[0].column, 15); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.