-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d8d64d
commit efba8bd
Showing
6 changed files
with
1,306 additions
and
4,269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# Changelog | ||
|
||
## 35.0.0 | ||
|
||
- Removed: `stylelint` less than `16.0.0` from peer dependencies. | ||
- Removed: Node.js less than `18.12.0` support. | ||
- Changed: updated to [`[email protected]`](https://github.com/stylelint/stylelint-config-recommended/releases/tag/14.0.0). | ||
|
||
## 34.0.0 | ||
|
||
- Removed: `stylelint` less than `15.10.0` from peer dependencies | ||
|
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,100 @@ | ||
import { describe, it, beforeEach } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
import fs from 'node:fs'; | ||
|
||
import stylelint from 'stylelint'; | ||
import config from '../index.js'; | ||
|
||
describe('flags no warnings with valid css', () => { | ||
const validCss = fs.readFileSync('./__tests__/valid.css', 'utf-8'); | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did not error', () => { | ||
assert.equal(result.errored, false); | ||
}); | ||
|
||
it('flags no warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 0); | ||
}); | ||
}); | ||
|
||
describe('flags warnings with invalid css', () => { | ||
const invalidCss = fs.readFileSync('./__tests__/invalid.css', 'utf-8'); | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 5); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.text), | ||
[ | ||
'Expected custom media query name "--FOO" to be kebab-case', | ||
'Expected custom property name "--FOO" to be kebab-case', | ||
'Expected keyframe name "FOO" to be kebab-case', | ||
'Expected class selector ".FOO" to be kebab-case', | ||
'Expected id selector "#FOO" to be kebab-case', | ||
], | ||
); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.deepEqual( | ||
result.results[0].warnings.map((w) => w.rule), | ||
[ | ||
'custom-media-pattern', | ||
'custom-property-pattern', | ||
'keyframes-name-pattern', | ||
'selector-class-pattern', | ||
'selector-id-pattern', | ||
], | ||
); | ||
}); | ||
|
||
it('correct severity flagged', () => { | ||
assert.equal(result.results[0].warnings[0].severity, 'error'); | ||
}); | ||
|
||
it('correct line number', () => { | ||
assert.equal(result.results[0].warnings[0].line, 1); | ||
}); | ||
|
||
it('correct column number', () => { | ||
assert.equal(result.results[0].warnings[0].column, 15); | ||
}); | ||
}); | ||
|
||
describe('deprecated rules are excluded', () => { | ||
const ruleNames = Object.keys(config.rules); | ||
|
||
it('is not empty', () => { | ||
assert.ok(ruleNames.length > 0); | ||
}); | ||
|
||
for (const ruleName of ruleNames) { | ||
it(`${ruleName}`, async () => { | ||
const rule = await stylelint.rules[ruleName]; | ||
|
||
assert.ok(!rule.meta.deprecated); | ||
}); | ||
} | ||
}); |
Oops, something went wrong.