Skip to content

Commit 8f43313

Browse files
authored
Update stylelint config (#33419)
- Inherit stylelint config from [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended), removed all stylelint core rule options that were either already in their config or disabled. - `no-descending-specificity` diverges from their config, seems to much work currently. - Tweaked a few rules. - Added [`stylelint-define-config`](https://github.com/stylelint-types/stylelint-define-config) so that typescript can validate the config.
1 parent 121e4c9 commit 8f43313

File tree

3 files changed

+63
-116
lines changed

3 files changed

+63
-116
lines changed

package-lock.json

Lines changed: 49 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@
102102
"markdownlint-cli": "0.43.0",
103103
"nolyfill": "1.0.43",
104104
"postcss-html": "1.8.0",
105-
"stylelint": "16.13.2",
105+
"stylelint": "16.14.1",
106+
"stylelint-config-recommended": "15.0.0",
106107
"stylelint-declaration-block-no-ignored-properties": "2.8.0",
107108
"stylelint-declaration-strict-value": "1.10.7",
109+
"stylelint-define-config": "16.14.0",
108110
"stylelint-value-no-unknown-custom-properties": "6.0.1",
109111
"svgo": "3.3.2",
110112
"type-fest": "4.33.0",

stylelint.config.js

Lines changed: 11 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-check
2+
import {defineConfig} from 'stylelint-define-config';
13
import {fileURLToPath} from 'node:url';
24

35
const cssVarFiles = [
@@ -6,8 +8,8 @@ const cssVarFiles = [
68
fileURLToPath(new URL('web_src/css/themes/theme-gitea-dark.css', import.meta.url)),
79
];
810

9-
/** @type {import('stylelint').Config} */
10-
export default {
11+
export default defineConfig({
12+
extends: 'stylelint-config-recommended',
1113
plugins: [
1214
'stylelint-declaration-strict-value',
1315
'stylelint-declaration-block-no-ignored-properties',
@@ -67,7 +69,7 @@ export default {
6769
'@stylistic/function-comma-space-after': null,
6870
'@stylistic/function-comma-space-before': null,
6971
'@stylistic/function-max-empty-lines': 0,
70-
'@stylistic/function-parentheses-newline-inside': 'never-multi-line',
72+
'@stylistic/function-parentheses-newline-inside': null,
7173
'@stylistic/function-parentheses-space-inside': null,
7274
'@stylistic/function-whitespace-after': null,
7375
'@stylistic/indentation': 2,
@@ -114,134 +116,34 @@ export default {
114116
'@stylistic/value-list-comma-space-after': null,
115117
'@stylistic/value-list-comma-space-before': null,
116118
'@stylistic/value-list-max-empty-lines': 0,
117-
'alpha-value-notation': null,
118-
'annotation-no-unknown': true,
119-
'at-rule-allowed-list': null,
120-
'at-rule-disallowed-list': null,
121-
'at-rule-empty-line-before': null,
122119
'at-rule-no-unknown': [true, {ignoreAtRules: ['tailwind']}],
123120
'at-rule-no-vendor-prefix': true,
124-
'at-rule-property-required-list': null,
125-
'block-no-empty': true,
126-
'color-function-notation': null,
127-
'color-hex-alpha': null,
128-
'color-hex-length': null,
129-
'color-named': null,
130-
'color-no-hex': null,
131-
'color-no-invalid-hex': true,
132-
'comment-empty-line-before': null,
133-
'comment-no-empty': true,
134-
'comment-pattern': null,
135-
'comment-whitespace-inside': null,
136-
'comment-word-disallowed-list': null,
137121
'csstools/value-no-unknown-custom-properties': [true, {importFrom: cssVarFiles}],
138-
'custom-media-pattern': null,
139-
'custom-property-empty-line-before': null,
140-
'custom-property-no-missing-var-function': true,
141-
'custom-property-pattern': null,
142-
'declaration-block-no-duplicate-custom-properties': true,
143122
'declaration-block-no-duplicate-properties': [true, {ignore: ['consecutive-duplicates-with-different-values']}],
144-
'declaration-block-no-redundant-longhand-properties': [true, {ignoreShorthands: ['flex-flow', 'overflow']}],
145-
'declaration-block-no-shorthand-property-overrides': null,
146-
'declaration-block-single-line-max-declarations': null,
147-
'declaration-empty-line-before': null,
148-
'declaration-no-important': null,
149-
'declaration-property-max-values': null,
150-
'declaration-property-unit-allowed-list': null,
123+
'declaration-block-no-redundant-longhand-properties': [true, {ignoreShorthands: ['flex-flow', 'overflow', 'grid-template']}],
124+
// @ts-expect-error - https://github.com/stylelint-types/stylelint-define-config/issues/1
151125
'declaration-property-unit-disallowed-list': {'line-height': ['em']},
152-
'declaration-property-value-allowed-list': null,
126+
// @ts-expect-error - https://github.com/stylelint-types/stylelint-define-config/issues/1
153127
'declaration-property-value-disallowed-list': {'word-break': ['break-word']},
154-
'declaration-property-value-no-unknown': true,
155128
'font-family-name-quotes': 'always-where-recommended',
156-
'font-family-no-duplicate-names': true,
157-
'font-family-no-missing-generic-family-keyword': true,
158-
'font-weight-notation': null,
159-
'function-allowed-list': null,
160-
'function-calc-no-unspaced-operator': true,
161-
'function-disallowed-list': null,
162-
'function-linear-gradient-no-nonstandard-direction': true,
163129
'function-name-case': 'lower',
164-
'function-no-unknown': true,
165-
'function-url-no-scheme-relative': null,
166130
'function-url-quotes': 'always',
167-
'function-url-scheme-allowed-list': null,
168-
'function-url-scheme-disallowed-list': null,
169-
'hue-degree-notation': null,
170131
'import-notation': 'string',
171-
'keyframe-block-no-duplicate-selectors': true,
172-
'keyframe-declaration-no-important': true,
173-
'keyframe-selector-notation': null,
174-
'keyframes-name-pattern': null,
175-
'length-zero-no-unit': [true, {ignore: ['custom-properties']}, {ignoreFunctions: ['var']}],
176-
'max-nesting-depth': null,
177-
'media-feature-name-allowed-list': null,
178-
'media-feature-name-disallowed-list': null,
179-
'media-feature-name-no-unknown': true,
132+
'length-zero-no-unit': [true, {ignore: ['custom-properties'], ignoreFunctions: ['var']}],
180133
'media-feature-name-no-vendor-prefix': true,
181-
'media-feature-name-unit-allowed-list': null,
182-
'media-feature-name-value-allowed-list': null,
183-
'media-feature-name-value-no-unknown': true,
184-
'media-feature-range-notation': null,
185-
'media-query-no-invalid': true,
186-
'named-grid-areas-no-invalid': true,
187134
'no-descending-specificity': null,
188-
'no-duplicate-at-import-rules': true,
189-
'no-duplicate-selectors': true,
190-
'no-empty-source': true,
191-
'no-invalid-double-slash-comments': true,
192135
'no-invalid-position-at-import-rule': [true, {ignoreAtRules: ['tailwind']}],
193-
'no-irregular-whitespace': true,
194136
'no-unknown-animations': null, // disabled until stylelint supports multi-file linting
195137
'no-unknown-custom-media': null, // disabled until stylelint supports multi-file linting
196138
'no-unknown-custom-properties': null, // disabled until stylelint supports multi-file linting
197-
'number-max-precision': null,
198139
'plugin/declaration-block-no-ignored-properties': true,
199-
'property-allowed-list': null,
200-
'property-disallowed-list': null,
201-
'property-no-unknown': true,
202-
'property-no-vendor-prefix': null,
203-
'rule-empty-line-before': null,
204-
'rule-selector-property-disallowed-list': null,
205-
'scale-unlimited/declaration-strict-value': [['/color$/', 'font-weight'], {ignoreValues: '/^(inherit|transparent|unset|initial|currentcolor|none)$/', ignoreFunctions: false, disableFix: true, expandShorthand: true}],
206-
'selector-anb-no-unmatchable': true,
207-
'selector-attribute-name-disallowed-list': null,
208-
'selector-attribute-operator-allowed-list': null,
209-
'selector-attribute-operator-disallowed-list': null,
140+
'scale-unlimited/declaration-strict-value': [['/color$/', 'font-weight'], {ignoreValues: '/^(inherit|transparent|unset|initial|currentcolor|none)$/', ignoreFunctions: true, disableFix: true, expandShorthand: true}],
210141
'selector-attribute-quotes': 'always',
211-
'selector-class-pattern': null,
212-
'selector-combinator-allowed-list': null,
213-
'selector-combinator-disallowed-list': null,
214-
'selector-disallowed-list': null,
215-
'selector-id-pattern': null,
216-
'selector-max-attribute': null,
217-
'selector-max-class': null,
218-
'selector-max-combinators': null,
219-
'selector-max-compound-selectors': null,
220-
'selector-max-id': null,
221-
'selector-max-pseudo-class': null,
222-
'selector-max-specificity': null,
223-
'selector-max-type': null,
224-
'selector-max-universal': null,
225-
'selector-nested-pattern': null,
226-
'selector-no-qualifying-type': null,
227142
'selector-no-vendor-prefix': true,
228-
'selector-not-notation': null,
229-
'selector-pseudo-class-allowed-list': null,
230-
'selector-pseudo-class-disallowed-list': null,
231-
'selector-pseudo-class-no-unknown': true,
232-
'selector-pseudo-element-allowed-list': null,
233143
'selector-pseudo-element-colon-notation': 'double',
234-
'selector-pseudo-element-disallowed-list': null,
235-
'selector-pseudo-element-no-unknown': true,
236144
'selector-type-case': 'lower',
237145
'selector-type-no-unknown': [true, {ignore: ['custom-elements']}],
238146
'shorthand-property-no-redundant-values': true,
239-
'string-no-newline': true,
240-
'time-min-milliseconds': null,
241-
'unit-allowed-list': null,
242-
'unit-disallowed-list': null,
243-
'unit-no-unknown': true,
244-
'value-keyword-case': null,
245147
'value-no-vendor-prefix': [true, {ignoreValues: ['box', 'inline-box']}],
246148
},
247-
};
149+
});

0 commit comments

Comments
 (0)