@benhigham/stylelint-config 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +83 -0
- package/package.json +91 -0
- package/src/index.js +97 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Benjamin Higham
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @benhigham/stylelint-config
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@benhigham/stylelint-config)
|
|
4
|
+
[](https://www.npmjs.com/package/@benhigham/stylelint-config)
|
|
5
|
+
[](LICENSE.md)
|
|
6
|
+
|
|
7
|
+
My personal [Stylelint](https://stylelint.io/) configuration for maintaining consistent, high-quality CSS/SCSS code.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
This configuration:
|
|
12
|
+
|
|
13
|
+
- Extends [`stylelint-config-standard-scss`](https://github.com/stylelint-scss/stylelint-config-standard-scss) for SCSS support and best practices
|
|
14
|
+
- Uses [`stylelint-config-recess-order`](https://github.com/stormwarning/stylelint-config-recess-order) for consistent property ordering
|
|
15
|
+
- Enforces strict value usage for colors, font-sizes, and z-indices
|
|
16
|
+
- Prevents performance issues with animations
|
|
17
|
+
- Requires proper use of custom media queries and nesting
|
|
18
|
+
- Enforces BEM naming conventions with SUIT CSS methodology
|
|
19
|
+
- Ensures browser compatibility with [Baseline](https://web.dev/baseline) requirements
|
|
20
|
+
- Includes accessibility checks for better a11y compliance
|
|
21
|
+
- Detects and prevents indistinguishable colors and out-of-gamut colors
|
|
22
|
+
- Provides special handling for CSS modules
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# npm
|
|
28
|
+
npm install --save-dev @benhigham/stylelint-config
|
|
29
|
+
|
|
30
|
+
# yarn
|
|
31
|
+
yarn add --dev @benhigham/stylelint-config
|
|
32
|
+
|
|
33
|
+
# pnpm
|
|
34
|
+
pnpm add --save-dev @benhigham/stylelint-config
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Create a `stylelint.config.js` file in your project root and extend this configuration:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
/** @type {import('stylelint').Config} */
|
|
43
|
+
export default {
|
|
44
|
+
extends: ['@benhigham/stylelint-config'],
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Configuration Details
|
|
49
|
+
|
|
50
|
+
### Extended Configs
|
|
51
|
+
|
|
52
|
+
- [`stylelint-config-standard-scss`](https://github.com/stylelint-scss/stylelint-config-standard-scss): Provides standard rules for SCSS files
|
|
53
|
+
- [`stylelint-config-recess-order`](https://github.com/stormwarning/stylelint-config-recess-order): Enforces a consistent property ordering based on the Recess methodology
|
|
54
|
+
|
|
55
|
+
### Plugins
|
|
56
|
+
|
|
57
|
+
This configuration includes several plugins:
|
|
58
|
+
|
|
59
|
+
- [`stylelint-declaration-block-no-ignored-properties`](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties): Prevents using ignored or overridden properties
|
|
60
|
+
- [`stylelint-declaration-strict-value`](https://github.com/AndyOGo/stylelint-declaration-strict-value): Enforces the use of variables, functions or custom CSS for specific properties
|
|
61
|
+
- [`stylelint-high-performance-animation`](https://github.com/kristerkari/stylelint-high-performance-animation): Prevents using low-performance animation properties
|
|
62
|
+
- [`stylelint-media-use-custom-media`](https://github.com/csstools/stylelint-media-use-custom-media): Enforces the use of custom media queries
|
|
63
|
+
- [`stylelint-use-nesting`](https://github.com/csstools/stylelint-use-nesting): Enforces proper CSS nesting
|
|
64
|
+
- [`stylelint-plugin-require-baseline`](https://github.com/ryo-manba/stylelint-plugin-require-baseline): Disallow CSS features not in [Baseline](https://web.dev/baseline)
|
|
65
|
+
- [`stylelint-no-unresolved-module`](https://github.com/niksy/stylelint-no-unresolved-module): Ensures all imported modules can be resolved
|
|
66
|
+
- [`stylelint-no-indistinguishable-colors`](https://github.com/ierhyna/stylelint-no-indistinguishable-colors): Prevents colors that are too similar
|
|
67
|
+
- [`stylelint-gamut`](https://github.com/csstools/stylelint-gamut): Prevents colors outside of supported gamut range
|
|
68
|
+
- [`stylelint-selector-bem-pattern`](https://github.com/simonsmith/stylelint-selector-bem-pattern): Enforces BEM naming convention
|
|
69
|
+
- [`stylelint-no-browser-hacks`](https://github.com/stylelint/stylelint-no-browser-hacks): Disallows browser hacks
|
|
70
|
+
- [`stylelint-no-unsupported-browser-features`](https://github.com/ismay/stylelint-no-unsupported-browser-features): Warns about unsupported browser features
|
|
71
|
+
- [`stylelint-a11y`](https://github.com/YozhikM/stylelint-a11y): Ensures CSS is accessible
|
|
72
|
+
|
|
73
|
+
### Key Rules
|
|
74
|
+
|
|
75
|
+
- **Browser Compatibility**: Enforces only widely supported CSS features
|
|
76
|
+
- **SCSS Best Practices**: Limits nesting depth, enforces consistent naming patterns
|
|
77
|
+
- **BEM Pattern**: Uses SUIT CSS methodology for class naming
|
|
78
|
+
- **Accessibility**: Ensures focus styles, supports reduced motion, and more
|
|
79
|
+
- **CSS Modules**: Special handling for `.module.scss` files with relaxed naming rules
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
This project is licensed under the [MIT License](LICENSE.md).
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@benhigham/stylelint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "My personal Stylelint configuration.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/benhigham/stylelint-config#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/benhigham/stylelint-config/issues/new"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/benhigham/stylelint-config.git"
|
|
13
|
+
},
|
|
14
|
+
"funding": "https://github.com/sponsors/benhigham",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Ben Higham",
|
|
17
|
+
"url": "https://benhigham.com"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"module": "./src/index.js",
|
|
21
|
+
"exports": "./src/index.js",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "^18.20.0 || ^20.10.0 || >=21.0.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"src"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"stylelint",
|
|
31
|
+
"stylelint-config",
|
|
32
|
+
"check",
|
|
33
|
+
"checker",
|
|
34
|
+
"code",
|
|
35
|
+
"codeguide",
|
|
36
|
+
"config",
|
|
37
|
+
"css",
|
|
38
|
+
"csslint",
|
|
39
|
+
"enforce",
|
|
40
|
+
"formatting",
|
|
41
|
+
"lint",
|
|
42
|
+
"linter",
|
|
43
|
+
"quality",
|
|
44
|
+
"standard",
|
|
45
|
+
"strict",
|
|
46
|
+
"style",
|
|
47
|
+
"styleguide",
|
|
48
|
+
"stylistic",
|
|
49
|
+
"validate",
|
|
50
|
+
"verify"
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"stylelint-a11y": "^1.2.3",
|
|
54
|
+
"stylelint-config-recess-order": "^6.0.0",
|
|
55
|
+
"stylelint-config-standard-scss": "^14.0.0",
|
|
56
|
+
"stylelint-declaration-block-no-ignored-properties": "^2.8.0",
|
|
57
|
+
"stylelint-declaration-strict-value": "^1.10.11",
|
|
58
|
+
"stylelint-gamut": "^1.3.4",
|
|
59
|
+
"stylelint-high-performance-animation": "^1.11.0",
|
|
60
|
+
"stylelint-media-use-custom-media": "^4.0.0",
|
|
61
|
+
"stylelint-no-browser-hacks": "^1.3.0",
|
|
62
|
+
"stylelint-no-indistinguishable-colors": "^2.3.1",
|
|
63
|
+
"stylelint-no-unresolved-module": "^2.3.0",
|
|
64
|
+
"stylelint-no-unsupported-browser-features": "^8.0.4",
|
|
65
|
+
"stylelint-plugin-require-baseline": "^0.1.1",
|
|
66
|
+
"stylelint-selector-bem-pattern": "^4.0.1",
|
|
67
|
+
"stylelint-use-nesting": "^6.0.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@benhigham/commitlint-config": "^0.1.2",
|
|
71
|
+
"@benhigham/prettier-config": "^0.1.0",
|
|
72
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
73
|
+
"@changesets/cli": "^2.28.1",
|
|
74
|
+
"@commitlint/cli": "^19.8.0",
|
|
75
|
+
"lefthook": "^1.11.9",
|
|
76
|
+
"prettier": "^3.5.3",
|
|
77
|
+
"stylelint": "^16.18.0",
|
|
78
|
+
"stylelint-find-new-rules": "^5.0.0"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"stylelint": ">=16.0.0"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"format": "prettier --write .",
|
|
85
|
+
"format:check": "prettier --check .",
|
|
86
|
+
"changeset": "changeset",
|
|
87
|
+
"changeset:status": "changeset status",
|
|
88
|
+
"version": "changeset version",
|
|
89
|
+
"release": "changeset publish"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** @import { Config } from 'stylelint' */
|
|
2
|
+
|
|
3
|
+
/** @type {Config} */
|
|
4
|
+
const config = {
|
|
5
|
+
extends: ['stylelint-config-standard-scss', 'stylelint-config-recess-order'],
|
|
6
|
+
plugins: [
|
|
7
|
+
'stylelint-declaration-block-no-ignored-properties',
|
|
8
|
+
'stylelint-declaration-strict-value',
|
|
9
|
+
'stylelint-no-unresolved-module',
|
|
10
|
+
'stylelint-high-performance-animation',
|
|
11
|
+
'stylelint-no-indistinguishable-colors',
|
|
12
|
+
'stylelint-gamut',
|
|
13
|
+
'stylelint-selector-bem-pattern',
|
|
14
|
+
'stylelint-media-use-custom-media',
|
|
15
|
+
'stylelint-use-nesting',
|
|
16
|
+
'stylelint-plugin-require-baseline',
|
|
17
|
+
'stylelint-no-browser-hacks',
|
|
18
|
+
'stylelint-no-unsupported-browser-features',
|
|
19
|
+
'stylelint-a11y',
|
|
20
|
+
],
|
|
21
|
+
rules: {
|
|
22
|
+
// Browser compatibility
|
|
23
|
+
'plugin/require-baseline': [true, { available: 'widely' }],
|
|
24
|
+
'plugin/no-browser-hacks': true,
|
|
25
|
+
'plugin/no-unsupported-browser-features': true,
|
|
26
|
+
|
|
27
|
+
// SCSS-specific rules
|
|
28
|
+
'scss/at-rule-no-unknown': true,
|
|
29
|
+
'scss/selector-no-redundant-nesting-selector': true,
|
|
30
|
+
'scss/dollar-variable-pattern': '^[a-z][a-zA-Z0-9]+$',
|
|
31
|
+
'scss/at-extend-no-missing-placeholder': true,
|
|
32
|
+
'scss/at-import-partial-extension': 'never',
|
|
33
|
+
'scss/at-mixin-pattern': '^[a-z][a-zA-Z0-9]+$',
|
|
34
|
+
'scss/max-nesting-depth': 3,
|
|
35
|
+
|
|
36
|
+
// Selector and class naming
|
|
37
|
+
'plugin/selector-bem-pattern': { preset: 'suit' },
|
|
38
|
+
'selector-max-id': 0,
|
|
39
|
+
'selector-max-specificity': '0,3,2',
|
|
40
|
+
|
|
41
|
+
// General consistency
|
|
42
|
+
'color-named': 'never',
|
|
43
|
+
'scale-unlimited/declaration-strict-value': [
|
|
44
|
+
['/color$/', 'font-size', 'z-index'],
|
|
45
|
+
{ ignoreValues: ['currentColor', 'inherit', 'transparent'] },
|
|
46
|
+
],
|
|
47
|
+
'declaration-property-unit-allowed-list': {
|
|
48
|
+
'font-size': ['rem', '%'],
|
|
49
|
+
'/^margin|^padding/': ['rem', '%', 'vw', 'vh'],
|
|
50
|
+
'/^border|^outline/': ['px'],
|
|
51
|
+
'line-height': ['none', ''],
|
|
52
|
+
},
|
|
53
|
+
'unit-allowed-list': [
|
|
54
|
+
['%', 'deg', 'rem', 'ms', 's', 'vw', 'vh'],
|
|
55
|
+
{
|
|
56
|
+
ignoreProperties: { px: ['border', 'outline'] },
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
'length-zero-no-unit': true,
|
|
60
|
+
'shorthand-property-no-redundant-values': true,
|
|
61
|
+
'plugin/declaration-block-no-ignored-properties': true,
|
|
62
|
+
'csstools/media-use-custom-media': 'always',
|
|
63
|
+
'csstools/use-nesting': ['always', { syntax: 'scss' }],
|
|
64
|
+
'plugin/stylelint-no-indistinguishable-colors': true,
|
|
65
|
+
'gamut/color-no-out-gamut-range': true,
|
|
66
|
+
'plugin/no-low-performance-animation-properties': true,
|
|
67
|
+
'plugin/no-unresolved-module': { modules: ['node_modules'] },
|
|
68
|
+
|
|
69
|
+
// Accessibility
|
|
70
|
+
'a11y/media-prefers-reduced-motion': true,
|
|
71
|
+
'a11y/no-outline-none': true,
|
|
72
|
+
'a11y/selector-pseudo-class-focus': true,
|
|
73
|
+
'a11y/no-obsolete-attribute': true,
|
|
74
|
+
'a11y/no-obsolete-element': true,
|
|
75
|
+
},
|
|
76
|
+
overrides: [
|
|
77
|
+
{
|
|
78
|
+
files: ['**/*.module.{css,scss}'],
|
|
79
|
+
rules: {
|
|
80
|
+
// More permissive rules for CSS modules
|
|
81
|
+
'selector-class-pattern': null,
|
|
82
|
+
'plugin/selector-bem-pattern': {
|
|
83
|
+
preset: 'suit',
|
|
84
|
+
presetOptions: {
|
|
85
|
+
namespace: false,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
reportDescriptionlessDisables: true,
|
|
92
|
+
reportInvalidScopeDisables: true,
|
|
93
|
+
reportNeedlessDisables: true,
|
|
94
|
+
reportUnscopedDisables: true,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default config;
|