Skip to content

Commit

Permalink
Add Stylelint v16 support
Browse files Browse the repository at this point in the history
* Remove Node v14 and v16 support (EOL)
* Set minimum Node version required for Stylelint v16 in engines field
* Silence CJS deprecation warnings
* Fix segmentation fault with test runner
  • Loading branch information
cahamilton committed Dec 15, 2023
1 parent dd73f4b commit 5eee0eb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
stylelint: [14, 15]
node-version: [18, 20]
stylelint: [14, 15, 16]

steps:
- name: Checkout
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- name: Install dependencies
run: npm install
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ a {

Refer to [css-property-sort-order-smacss](https://github.com/cahamilton/css-property-sort-order-smacss/blob/v2.2.0/index.js) for the comprehensive list of property orders.

For more information on configuring Stylelint, check out the [configuration](https://github.com/stylelint/stylelint/blob/15.0.0/docs/user-guide/configure.md) guide.
For more information on configuring Stylelint, check out the [configuration](https://github.com/stylelint/stylelint/blob/16.0.0/docs/user-guide/configure.md) guide.

## Advanced

**This is currently only possible with an exported JavaScript configuration.**

The basic usage outlined above, will enforce that properties are **strictly** sorted within their groups (box, border, background etc). Given this configuration makes use of [stylelint-order](https://github.com/hudochenkov/stylelint-order/tree/5.0.0) under the hood, there's a couple extra bits of functionality that can be configured. This will require manually generating the configuration - but passing in extra options as seen fit. These will be applied to **each** property group.
The basic usage outlined above, will enforce that properties are **strictly** sorted within their groups (box, border, background etc). Given this configuration makes use of [stylelint-order](https://github.com/hudochenkov/stylelint-order/tree/6.0.4) under the hood, there's a couple extra bits of functionality that can be configured. This will require manually generating the configuration - but passing in extra options as seen fit. These will be applied to **each** property group.

### Options

Refer to the [properties-order](https://github.com/hudochenkov/stylelint-order/blob/5.0.0/rules/properties-order/README.md#options) documentation for a list of available options.
Refer to the [properties-order](https://github.com/hudochenkov/stylelint-order/blob/6.0.4/rules/properties-order/README.md#options) documentation for a list of available options.

All options except `properties` and `groupName` can be modified.

Expand Down
14 changes: 8 additions & 6 deletions __tests__/generate.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/** @format */

const generate = require('../generate');
const proxyquire = require('proxyquire');

jest.mock('css-property-sort-order-smacss', () => ({
groupA: [['prop1', 'prop2'], ['prop3']],
groupB: ['prop4', 'prop5', 'prop6', 'prop7'],
groupC: [['prop8', 'prop9', 'prop10']],
}));
const generate = proxyquire.noCallThru().load('../generate', {
'css-property-sort-order-smacss': {
groupA: [['prop1', 'prop2'], ['prop3']],
groupB: ['prop4', 'prop5', 'prop6', 'prop7'],
groupC: [['prop8', 'prop9', 'prop10']],
},
});

describe('generate options', () => {
it('should correctly group properties', () => {
Expand Down
6 changes: 5 additions & 1 deletion __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const index = require('../index');
* @return {Promise<{errored, invalidOptionWarnings, warnings}>}
*/
const lintCode = async ({ code, config }) => {
const actual = await stylelint.lint({ code, config });
const actual = await stylelint.lint({
code,
config,
quietDeprecationWarnings: true,
});

const { errored, results } = actual;
const { invalidOptionWarnings, warnings } = results[0];
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @format */

module.exports = {
runner: 'jest-light-runner',
cacheDirectory: '/tmp/jest/',
collectCoverage: true,
coverageDirectory: 'coverage',
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
"index.js",
"generate.js"
],
"engines": {
"node": ">=18.12.0"
},
"scripts": {
"coverage": "coveralls < coverage/lcov.info",
"eslint": "eslint .",
"jest": "jest",
"jest": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest",
"prettier": "prettier --check '**/*.js'",
"test": "npm run eslint && npm run prettier && npm run jest"
},
Expand All @@ -35,7 +38,7 @@
"homepage": "https://github.com/cahamilton/stylelint-config-property-sort-order-smacss#readme",
"dependencies": {
"css-property-sort-order-smacss": "~2.2.0",
"stylelint-order": "^6.0.2"
"stylelint-order": "^6.0.4"
},
"devDependencies": {
"coveralls": "^3.1.0",
Expand All @@ -44,10 +47,12 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.25.2",
"jest": "^29.0.1",
"jest-light-runner": "^0.6.0",
"prettier": "^3.0.0",
"stylelint": "^14.0.0 || ^15.0.0"
"proxyquire": "^2.0.0",
"stylelint": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"peerDependencies": {
"stylelint": "^14.0.0 || ^15.0.0"
"stylelint": "^14.0.0 || ^15.0.0 || ^16.0.0"
}
}

0 comments on commit 5eee0eb

Please sign in to comment.