@stratawp/stylelint-config 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/README.md +34 -2
  2. package/index.js +48 -0
  3. package/package.json +39 -4
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @stratawp/stylelint-config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Strict, performance-minded Stylelint preset for StrataWP themes.
4
+
5
+ ```bash
6
+ pnpm add -D stylelint @stratawp/stylelint-config
7
+ ```
8
+
9
+ ```js
10
+ // stylelint.config.js
11
+ export { default } from '@stratawp/stylelint-config'
12
+ ```
13
+
14
+ ## Rules
15
+
16
+ | Rule | Default | Why |
17
+ | -------------------------- | ---------------------------------------------- | ---------------------------------------------------- |
18
+ | `max-nesting-depth` | 3 levels (pseudo-classes and at-rules ignored) | Deep nesting compiles to long, brittle selectors |
19
+ | `selector-max-specificity` | `0,3,1` | Low specificity keeps overrides cheap; blocks ids |
20
+ | `custom-property-pattern` | kebab-case, WordPress `--` ok | Consistent token names, compatible with `theme.json` |
21
+
22
+ Nested selectors are resolved before `selector-max-specificity` is applied, so a deeply nested rule can trigger both rules.
23
+
24
+ Files matching `*woocommerce*.{css,scss}` use a higher `selector-max-specificity` cap of `0,5,2`. Overrides of WooCommerce core selectors must match WooCommerce's own specificity to win the cascade, so they cannot stay under the global cap. The exception applies only to those files.
25
+
26
+ `.scss` files are parsed with `postcss-scss`.
27
+
28
+ ## Overriding
29
+
30
+ ```js
31
+ export default {
32
+ extends: ['@stratawp/stylelint-config'],
33
+ rules: { 'max-nesting-depth': [4] },
34
+ }
35
+ ```
package/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import postcssScss from 'postcss-scss'
2
+
3
+ /**
4
+ * Default thresholds. Override a rule in your own config to change one:
5
+ * { extends: ['@stratawp/stylelint-config'], rules: { 'max-nesting-depth': [4] } }
6
+ */
7
+ export const thresholds = {
8
+ // Deep nesting compiles to long, brittle selectors.
9
+ maxNestingDepth: 3,
10
+ // 0 ids, 3 classes, 1 type. Low specificity keeps overrides cheap and
11
+ // cascade layers predictable.
12
+ maxSpecificity: '0,3,1',
13
+ }
14
+
15
+ // Overrides of WooCommerce core selectors (e.g. `.woocommerce table.cart
16
+ // .actions .coupon input[type="text"]`) must match WooCommerce's own
17
+ // specificity to win, so WooCommerce override files get a higher cap.
18
+ // Measured maximum across the shipped store theme stylesheets.
19
+ const woocommerceMaxSpecificity = '0,5,2'
20
+
21
+ export default {
22
+ rules: {
23
+ 'max-nesting-depth': [
24
+ thresholds.maxNestingDepth,
25
+ {
26
+ ignore: ['blockless-at-rules', 'pseudo-classes'],
27
+ ignoreAtRules: ['media', 'supports', 'container', 'include'],
28
+ },
29
+ ],
30
+ 'selector-max-specificity': thresholds.maxSpecificity,
31
+ // kebab-case, with the double-dash segments WordPress generates
32
+ // (--wp--preset--color--primary).
33
+ 'custom-property-pattern': [
34
+ '^[a-z][a-z0-9]*(?:-{1,2}[a-z0-9]+)*$',
35
+ { message: 'Custom properties must be kebab-case (WordPress "--" segments allowed)' },
36
+ ],
37
+ },
38
+ overrides: [
39
+ {
40
+ files: ['**/*.scss'],
41
+ customSyntax: postcssScss,
42
+ },
43
+ {
44
+ files: ['**/*woocommerce*.{css,scss}'],
45
+ rules: { 'selector-max-specificity': woocommerceMaxSpecificity },
46
+ },
47
+ ],
48
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@stratawp/stylelint-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Strict, performance-minded Stylelint preset for StrataWP themes",
5
+ "author": "Jon Imms",
6
+ "license": "GPL-3.0-or-later",
7
+ "type": "module",
8
+ "keywords": [
9
+ "stylelint",
10
+ "stylelint-config",
11
+ "wordpress",
12
+ "scss",
13
+ "stratawp"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/JonImmsWordpressDev/StrataWP.git",
18
+ "directory": "packages/stylelint-config"
19
+ },
20
+ "main": "./index.js",
21
+ "exports": {
22
+ ".": "./index.js"
23
+ },
24
+ "files": [
25
+ "index.js",
26
+ "README.md"
27
+ ],
28
+ "scripts": {
29
+ "test": "vitest run"
30
+ },
31
+ "dependencies": {
32
+ "postcss-scss": "^4.0.9"
33
+ },
34
+ "peerDependencies": {
35
+ "stylelint": "^16.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "stylelint": "^16.0.0",
39
+ "vitest": "^1.0.4"
40
+ }
41
+ }