-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from suitcss/v21
Updates for v21 release
- Loading branch information
Showing
8 changed files
with
5,704 additions
and
4,511 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,37 +1,52 @@ | ||
const config = require("../"); | ||
const fs = require("fs"); | ||
const stylelint = require("stylelint"); | ||
|
||
const validCss = fs.readFileSync(`${__dirname}/valid.css`, "utf-8"); | ||
const invalidCss = ( | ||
`a {} | ||
`); | ||
|
||
test("no warnings with valid css", () => | ||
stylelint.lint({ | ||
code: validCss, | ||
config, | ||
}) | ||
.then(data => { | ||
const { errored, results } = data; | ||
import config from '../index.js'; | ||
import stylelint from 'stylelint'; | ||
|
||
describe('stylelint-config-suitcss', () => { | ||
const lint = async (css) => { | ||
const result = await stylelint.lint({ | ||
code: css, | ||
config, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
test('should not allow block-no-empty', async () => { | ||
const { results } = await lint(`a {}`); | ||
const { warnings } = results[0]; | ||
|
||
expect(errored).toBeFalsy(); | ||
expect(warnings).toHaveLength(0); | ||
}) | ||
); | ||
|
||
test("a warning with invalid css", () => | ||
stylelint.lint({ | ||
code: invalidCss, | ||
config, | ||
}) | ||
.then(data => { | ||
const { errored, results } = data; | ||
expect(warnings).toHaveLength(1); | ||
expect(warnings[0].text).toContain('block-no-empty'); | ||
}); | ||
|
||
test('should enforce color-hex-length to be short', async () => { | ||
const { results } = await lint(`a { color: #ffffff; }`); | ||
const { warnings } = results[0]; | ||
|
||
expect(warnings).toHaveLength(1); | ||
expect(warnings[0].text).toContain('color-hex-length'); | ||
}); | ||
|
||
test('should not allow at-rule-no-vendor-prefix', async () => { | ||
const { results } = await lint(`@-webkit-keyframes slide { from { top: 0; } to { top: 100%; } }`); | ||
const { warnings } = results[0]; | ||
|
||
expect(warnings).toHaveLength(1); | ||
expect(warnings[0].text).toContain('at-rule-no-vendor-prefix'); | ||
}); | ||
|
||
test('should enforce function-url-quotes', async () => { | ||
const { results } = await lint(`a { background: url(unquoted-url.jpg); }`); | ||
const { warnings } = results[0]; | ||
|
||
expect(errored).toBeTruthy(); | ||
expect(warnings).toHaveLength(1); | ||
expect(warnings[0].text).toBe("Unexpected empty block (block-no-empty)"); | ||
}) | ||
); | ||
expect(warnings[0].text).toContain('function-url-quotes'); | ||
}); | ||
|
||
test('should allow correct SUIT custom properties usage', async () => { | ||
const { results } = await lint(`:root { --mainColor: #123456; }`); | ||
const { warnings } = results[0]; | ||
|
||
expect(warnings).toHaveLength(0); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
export default { | ||
"plugins": [ | ||
"stylelint-order", | ||
"stylelint-suitcss", | ||
|
Oops, something went wrong.