Skip to content

Commit

Permalink
Require Node.js 18, Stylelint 16, and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 1, 2024
1 parent bdcc388 commit bf8832a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

module.exports = {
const config = {
extends: 'stylelint-config-xo',
rules: {
indentation: [
2,
{
baseIndentLevel: 1
}
]
}
baseIndentLevel: 1,
},
],
},
};

export default config;
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"email": "[email protected]",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"sideEffects": false,
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
Expand Down Expand Up @@ -46,14 +49,14 @@
"simple"
],
"dependencies": {
"stylelint-config-xo": "^0.21.0"
"stylelint-config-xo": "^1.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"stylelint": "^14.5.3",
"xo": "^0.33.1"
"ava": "^6.1.2",
"stylelint": "^16.4.0",
"xo": "^0.58.0"
},
"peerDependencies": {
"stylelint": ">=14"
"stylelint": ">=16"
}
}
12 changes: 6 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import test from 'ava';
import stylelint from 'stylelint';
import config from '..';
import config from '../index.js';

const hasRule = (errors, ruleId) => errors.some(x => x.rule === ruleId);

const runStylelint = async code => {
const {results} = await stylelint.lint({
code,
config
config,
});

for (const result of results) {
if (result.deprecations.length !== 0) {
if (result.deprecations.length > 0) {
throw new Error(`Deprecations:\n${result.deprecations.join('\n')}`);
}

if (result.invalidOptionWarnings.length !== 0) {
if (result.invalidOptionWarnings.length > 0) {
const warnings = result.invalidOptionWarnings.map(x => x.text).join('\n');
throw new Error(`Invalid options:\n${warnings}`);
}
Expand All @@ -29,8 +29,8 @@ test('main', async t => {
`div {
left: .2em;
}
`
`,
);

t.true(hasRule(results[0].warnings, 'number-leading-zero'));
t.true(hasRule(results[0].warnings, '@stylistic/number-leading-zero'));
});

0 comments on commit bf8832a

Please sign in to comment.