-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
d0c62e5
commit f829725
Showing
7 changed files
with
1,188 additions
and
4,200 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 |
---|---|---|
|
@@ -5,8 +5,6 @@ on: | |
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
lint: | ||
|
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 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,86 @@ | ||
import { describe, it, beforeEach } 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__/valid.css', 'utf-8'); | ||
const invalidCss = readFileSync('./__tests__/invalid.css', 'utf-8'); | ||
|
||
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); | ||
}); | ||
}); | ||
|
||
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 unknown type selector "madeup" (selector-type-no-unknown)', | ||
); | ||
}); | ||
|
||
it('corrects rule flagged', () => { | ||
assert.equal(result.results[0].warnings[0].rule, 'selector-type-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, 1); | ||
}); | ||
|
||
it('corrects column number', () => { | ||
assert.equal(result.results[0].warnings[0].column, 1); | ||
}); | ||
}); | ||
|
||
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.