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 39dcb56 commit c955302
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 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
31 changes: 20 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
import postcssScss from 'postcss-scss';

const reLowercase = /^[a-z]+(-[a-z\d]+)*$/;

module.exports = {
const config = {
extends: 'stylelint-config-xo',
customSyntax: require('postcss-scss'),
customSyntax: postcssScss,
plugins: [
'stylelint-scss'
'stylelint-scss',
],
rules: {
'at-rule-no-unknown': null,
Expand All @@ -15,26 +15,27 @@ module.exports = {
true,
{
ignoreAtRules: [
'use'
]
}
'use',
],
},
],
'property-no-unknown': null,

'scss/at-each-key-value-single-line': true,
'scss/at-else-if-parentheses-space-before': 'always',
'scss/at-extend-no-missing-placeholder': true,
'scss/at-function-parentheses-space-before': 'never',
'scss/at-function-pattern': reLowercase,
'scss/at-if-no-null': true,
'scss/at-import-no-partial-leading-underscore': true,
'scss/at-import-partial-extension': 'never',
'scss/at-mixin-argumentless-call-parentheses': 'never',
'scss/at-mixin-parentheses-space-before': 'never',
'scss/at-mixin-pattern': reLowercase,
'scss/at-root-no-redundant': true,
'scss/at-rule-conditional-no-parentheses': true,
'scss/at-rule-no-unknown': true,
'scss/at-use-no-unnamespaced': true,
// Disabled because of https://github.com/kristerkari/stylelint-scss/issues/203
// Disabled because of https://github.com/stylelint-scss/stylelint-scss/issues/172#issuecomment-363594714
// 'scss/dollar-variable-colon-newline-after': 'always-multi-line',
'scss/dollar-variable-colon-space-after': 'always-single-line',
'scss/dollar-variable-colon-space-before': 'never',
Expand All @@ -56,6 +57,14 @@ module.exports = {
'scss/partial-no-import': true,
'scss/selector-no-redundant-nesting-selector': true,
'scss/no-duplicate-dollar-variables': true,
'scss/no-duplicate-mixins': true
}
'scss/no-duplicate-mixins': true,
'scss/property-no-unknown': true,
'scss/at-use-no-redundant-alias': true,
'scss/function-calculation-no-interpolation': true,
'scss/block-no-redundant-nesting': true,
'scss/load-no-partial-leading-underscore': true,
'scss/no-unused-private-members': true,
},
};

export default config;
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"sideEffects": false,
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -31,16 +34,16 @@
"linter"
],
"dependencies": {
"postcss-scss": "^4.0.3",
"stylelint-config-xo": "^0.21.0",
"stylelint-scss": "^4.2.0"
"postcss-scss": "^4.0.9",
"stylelint-config-xo": "^1.0.0",
"stylelint-scss": "^6.2.1"
},
"devDependencies": {
"ava": "^2.4.0",
"stylelint": "^14.5.3",
"xo": "^0.32.0"
"ava": "^6.1.2",
"stylelint": "^16.4.0",
"xo": "^0.58.0"
},
"peerDependencies": {
"stylelint": ">=14.5.1"
"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 c955302

Please sign in to comment.