Skip to content

Commit

Permalink
Merge pull request #63 from suitcss/v21
Browse files Browse the repository at this point in the history
Updates for v21 release
  • Loading branch information
AlecRust authored Feb 4, 2024
2 parents e04f63e + 068e5b0 commit 6cb089d
Show file tree
Hide file tree
Showing 8 changed files with 5,704 additions and 4,511 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '16', '18', '20' ]
node: [ '18', '20', '21' ]
name: Run tests on Node ${{ matrix.node }}
steps:
- name: Checkout repository
Expand All @@ -21,6 +21,6 @@ jobs:
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: yarn install
run: npm ci
- name: Run tests
run: yarn test
run: npm test
79 changes: 47 additions & 32 deletions __tests__/index.js
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);
});
});
68 changes: 0 additions & 68 deletions __tests__/valid.css

This file was deleted.

3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
"plugins": [
"stylelint-order",
"stylelint-suitcss",
Expand Down
Loading

0 comments on commit 6cb089d

Please sign in to comment.