@atomicsmash/coding-standards 18.0.0-beta.6 → 18.0.0-beta.7
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/CHANGELOG.md +15 -0
- package/dist/cspell/index.d.ts +15 -0
- package/dist/cspell/index.d.ts.map +1 -0
- package/dist/cspell/index.js +133 -0
- package/dist/eslint/index.d.ts +4 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +198 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/prettier/index.d.ts +13 -0
- package/dist/prettier/index.d.ts.map +1 -0
- package/dist/prettier/index.js +32 -0
- package/dist/stylelint/base.d.ts +69 -0
- package/dist/stylelint/base.d.ts.map +1 -0
- package/dist/stylelint/base.js +86 -0
- package/dist/stylelint/classic.d.ts +69 -0
- package/dist/stylelint/classic.d.ts.map +1 -0
- package/dist/stylelint/classic.js +2 -0
- package/dist/stylelint/index.d.ts +161 -0
- package/dist/stylelint/index.d.ts.map +1 -0
- package/dist/stylelint/index.js +4 -0
- package/dist/stylelint/tailwind.d.ts +21 -0
- package/dist/stylelint/tailwind.d.ts.map +1 -0
- package/dist/stylelint/tailwind.js +38 -0
- package/dist/stylelint/theme-json.d.ts +73 -0
- package/dist/stylelint/theme-json.d.ts.map +1 -0
- package/dist/stylelint/theme-json.js +169 -0
- package/package.json +49 -12
- package/typescript/base.json +2 -1
- package/typescript/cypress.json +1 -1
- package/.eslintrc.cjs +0 -8
- package/beta/README.md +0 -3
- package/beta/eslint/index.js +0 -200
- package/cspell/index.cjs +0 -142
- package/cspell/index.js +0 -1
- package/cspell/index.mjs +0 -142
- package/index.d.ts +0 -7
- package/index.js +0 -5
- package/index.mjs +0 -4
- package/prettier/index.cjs +0 -35
- package/prettier/index.js +0 -1
- package/prettier/index.mjs +0 -35
- package/stylelint/base.cjs +0 -91
- package/stylelint/base.js +0 -1
- package/stylelint/base.mjs +0 -91
- package/stylelint/classic.cjs +0 -3
- package/stylelint/classic.js +0 -1
- package/stylelint/classic.mjs +0 -2
- package/stylelint/index.cjs +0 -5
- package/stylelint/index.mjs +0 -4
- package/stylelint/tailwind.cjs +0 -38
- package/stylelint/tailwind.js +0 -1
- package/stylelint/tailwind.mjs +0 -38
- package/stylelint/theme-json.cjs +0 -189
- package/stylelint/theme-json.js +0 -1
- package/stylelint/theme-json.mjs +0 -189
package/stylelint/base.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const commonRules = {
|
|
2
|
-
"custom-property-pattern": null,
|
|
3
|
-
"function-url-quotes": ["always"],
|
|
4
|
-
"rule-empty-line-before": [
|
|
5
|
-
"always",
|
|
6
|
-
{
|
|
7
|
-
except: ["first-nested"],
|
|
8
|
-
ignore: ["after-comment"],
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
"comment-empty-line-before": [
|
|
12
|
-
"always",
|
|
13
|
-
{
|
|
14
|
-
except: ["first-nested"],
|
|
15
|
-
ignore: ["stylelint-commands"],
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
"order/order": [
|
|
19
|
-
{
|
|
20
|
-
type: "at-rule",
|
|
21
|
-
hasBlock: false,
|
|
22
|
-
},
|
|
23
|
-
"custom-properties",
|
|
24
|
-
"dollar-variables",
|
|
25
|
-
"declarations",
|
|
26
|
-
{
|
|
27
|
-
type: "at-rule",
|
|
28
|
-
hasBlock: true,
|
|
29
|
-
},
|
|
30
|
-
"rules",
|
|
31
|
-
],
|
|
32
|
-
"plugin/no-restricted-syntax": [
|
|
33
|
-
[
|
|
34
|
-
{
|
|
35
|
-
selector:
|
|
36
|
-
"rule :matches(atrule[name=media], atrule[name=container]) rule",
|
|
37
|
-
message:
|
|
38
|
-
"Don't nest rules inside of media/container blocks. Instead, nest the rule and use the at rule within that.",
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
],
|
|
42
|
-
"selector-class-pattern": [
|
|
43
|
-
"^([a-z][a-z0-9]*)([_-]+[a-z0-9]+)*$",
|
|
44
|
-
{
|
|
45
|
-
message:
|
|
46
|
-
"Selector should use lowercase and separate words with hyphens or underscores (selector-class-pattern)",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
"at-rule-empty-line-before": [
|
|
50
|
-
"always",
|
|
51
|
-
{
|
|
52
|
-
ignore: ["blockless-after-blockless", "first-nested", "after-comment"],
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/** @type {import('stylelint').Config} */
|
|
58
|
-
export default {
|
|
59
|
-
reportDescriptionlessDisables: true,
|
|
60
|
-
reportInvalidScopeDisables: true,
|
|
61
|
-
reportNeedlessDisables: true,
|
|
62
|
-
plugins: ["stylelint-order", "stylelint-no-restricted-syntax"],
|
|
63
|
-
rules: commonRules,
|
|
64
|
-
overrides: [
|
|
65
|
-
{
|
|
66
|
-
files: ["*.css", "**/*.css"],
|
|
67
|
-
extends: ["stylelint-config-standard", "@wordpress/stylelint-config"],
|
|
68
|
-
rules: {
|
|
69
|
-
"at-rule-no-unknown": [true, { ignoreAtRules: "context" }],
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
files: ["*.scss", "**/*.scss"],
|
|
74
|
-
extends: [
|
|
75
|
-
"stylelint-config-standard-scss",
|
|
76
|
-
"@wordpress/stylelint-config/scss",
|
|
77
|
-
],
|
|
78
|
-
rules: {
|
|
79
|
-
"scss/operator-no-newline-after": null,
|
|
80
|
-
"no-descending-specificity": null,
|
|
81
|
-
"scss/at-rule-no-unknown": [true, { ignoreAtRules: "context" }],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
files: ["**/editor-style?(s).?(s)css"],
|
|
86
|
-
rules: {
|
|
87
|
-
"declaration-property-value-allowed-list": null,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
};
|
package/stylelint/classic.cjs
DELETED
package/stylelint/classic.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./classic.mjs";
|
package/stylelint/classic.mjs
DELETED
package/stylelint/index.cjs
DELETED
package/stylelint/index.mjs
DELETED
package/stylelint/tailwind.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
overrides: [
|
|
3
|
-
{
|
|
4
|
-
files: ["*.css", "**/*.css"],
|
|
5
|
-
rules: {
|
|
6
|
-
'at-rule-no-unknown': [
|
|
7
|
-
true,
|
|
8
|
-
{
|
|
9
|
-
ignoreAtRules: [
|
|
10
|
-
'tailwind',
|
|
11
|
-
'apply',
|
|
12
|
-
'variants',
|
|
13
|
-
'responsive',
|
|
14
|
-
'screen',
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
files: ["*.scss", "**/*.scss"],
|
|
22
|
-
rules: {
|
|
23
|
-
'scss/at-rule-no-unknown': [
|
|
24
|
-
true,
|
|
25
|
-
{
|
|
26
|
-
ignoreAtRules: [
|
|
27
|
-
'tailwind',
|
|
28
|
-
'apply',
|
|
29
|
-
'variants',
|
|
30
|
-
'responsive',
|
|
31
|
-
'screen',
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
};
|
package/stylelint/tailwind.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./tailwind.mjs";
|
package/stylelint/tailwind.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
overrides: [
|
|
3
|
-
{
|
|
4
|
-
files: ["*.css", "**/*.css"],
|
|
5
|
-
rules: {
|
|
6
|
-
'at-rule-no-unknown': [
|
|
7
|
-
true,
|
|
8
|
-
{
|
|
9
|
-
ignoreAtRules: [
|
|
10
|
-
'tailwind',
|
|
11
|
-
'apply',
|
|
12
|
-
'variants',
|
|
13
|
-
'responsive',
|
|
14
|
-
'screen',
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
files: ["*.scss", "**/*.scss"],
|
|
22
|
-
rules: {
|
|
23
|
-
'scss/at-rule-no-unknown': [
|
|
24
|
-
true,
|
|
25
|
-
{
|
|
26
|
-
ignoreAtRules: [
|
|
27
|
-
'tailwind',
|
|
28
|
-
'apply',
|
|
29
|
-
'variants',
|
|
30
|
-
'responsive',
|
|
31
|
-
'screen',
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
};
|
package/stylelint/theme-json.cjs
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
const baseConfig = require("./base.cjs");
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {({property: string|RegExp, varInfo: {type: "custom"|"preset", slug:string},shorthand?: 1 | 2 | 3 | 4 , additionalAllowedValues?: (string|RegExp)[]})[]} values
|
|
6
|
-
*/
|
|
7
|
-
function createAllowedPropertyList(values) {
|
|
8
|
-
/**
|
|
9
|
-
* @type {Record<string,string[]>}
|
|
10
|
-
*/
|
|
11
|
-
const allowedPropertyList = {};
|
|
12
|
-
for (const {
|
|
13
|
-
property,
|
|
14
|
-
varInfo,
|
|
15
|
-
shorthand = 1,
|
|
16
|
-
additionalAllowedValues = [],
|
|
17
|
-
} of values) {
|
|
18
|
-
const isRegexProperty = property instanceof RegExp;
|
|
19
|
-
const possibleValues = [];
|
|
20
|
-
const possibleVars = [
|
|
21
|
-
...additionalAllowedValues.map((value) =>
|
|
22
|
-
value instanceof RegExp ? value.toString() : value,
|
|
23
|
-
),
|
|
24
|
-
`(var\\([\\s]*--wp--${varInfo.type}--${varInfo.slug}--([a-z-0-9]+[\\s]*)\\))`,
|
|
25
|
-
];
|
|
26
|
-
if (isRegexProperty) {
|
|
27
|
-
possibleVars.push(
|
|
28
|
-
`(var\\([\\s]*--[a-z-0-9]*${property.toString().slice(1, -1)}[a-z-0-9]*[\\s]*\\))`,
|
|
29
|
-
);
|
|
30
|
-
} else if (property) {
|
|
31
|
-
possibleVars.push(
|
|
32
|
-
`(var\\([\\s]*--[a-z-0-9]*${property}[a-z-0-9]*[\\s]*\\))`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
possibleValues.push(
|
|
36
|
-
// For each shorthand value, allow one of the possible values followed by a space, or allow it to be blank
|
|
37
|
-
`/^${shorthand > 1 ? `((${possibleVars.join("|")})[\\s]*){0,${shorthand - 1}}` : ""}(${possibleVars.join("|")})$/`,
|
|
38
|
-
);
|
|
39
|
-
allowedPropertyList[property.toString()] = possibleValues;
|
|
40
|
-
if (!isRegexProperty) {
|
|
41
|
-
allowedPropertyList[`/--[a-z-0-9]*${property}[a-z-0-9]*/`] =
|
|
42
|
-
possibleValues;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return allowedPropertyList;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const rules = {
|
|
49
|
-
"declaration-property-value-allowed-list": [
|
|
50
|
-
createAllowedPropertyList([
|
|
51
|
-
{
|
|
52
|
-
property: /border((-top|-bottom)(-left|-right))?-radius/,
|
|
53
|
-
varInfo: {
|
|
54
|
-
type: "custom",
|
|
55
|
-
slug: "radius",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
property: "border-radius",
|
|
60
|
-
varInfo: {
|
|
61
|
-
type: "custom",
|
|
62
|
-
slug: "radius",
|
|
63
|
-
},
|
|
64
|
-
shorthand: 4,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
property: "box-shadow",
|
|
68
|
-
varInfo: {
|
|
69
|
-
type: "preset",
|
|
70
|
-
slug: "shadow",
|
|
71
|
-
},
|
|
72
|
-
additionalAllowedValues: ["none", "unset"],
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
property: /color/,
|
|
76
|
-
varInfo: {
|
|
77
|
-
type: "preset",
|
|
78
|
-
slug: "color",
|
|
79
|
-
},
|
|
80
|
-
additionalAllowedValues: ["inherit", "currentcolor"],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
property: "background-color",
|
|
84
|
-
varInfo: {
|
|
85
|
-
type: "preset",
|
|
86
|
-
slug: "color",
|
|
87
|
-
},
|
|
88
|
-
additionalAllowedValues: ["transparent"],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
property: "font-family",
|
|
92
|
-
varInfo: {
|
|
93
|
-
type: "preset",
|
|
94
|
-
slug: "font-family",
|
|
95
|
-
},
|
|
96
|
-
additionalAllowedValues: ["inherit"],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
property: "font-size",
|
|
100
|
-
varInfo: {
|
|
101
|
-
type: "preset",
|
|
102
|
-
slug: "font-size",
|
|
103
|
-
},
|
|
104
|
-
additionalAllowedValues: ["inherit"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
property: /(?<!scroll-)margin/,
|
|
108
|
-
varInfo: {
|
|
109
|
-
type: "preset",
|
|
110
|
-
slug: "spacing",
|
|
111
|
-
},
|
|
112
|
-
shorthand: 4,
|
|
113
|
-
additionalAllowedValues: ["auto", "var\\(--wp--style--block-gap\\)"],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
property: /padding/,
|
|
117
|
-
varInfo: {
|
|
118
|
-
type: "preset",
|
|
119
|
-
slug: "spacing",
|
|
120
|
-
},
|
|
121
|
-
shorthand: 4,
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
property: "z-index",
|
|
125
|
-
varInfo: {
|
|
126
|
-
type: "custom",
|
|
127
|
-
slug: "z-index",
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
]),
|
|
131
|
-
{
|
|
132
|
-
severity: "warning",
|
|
133
|
-
message: (property, value) => {
|
|
134
|
-
// Until updated, property and value will always return undefined.
|
|
135
|
-
return `Most values for this type of property should be defined in theme.json. (declaration-property-value-allowed-list)`;
|
|
136
|
-
// The following code is not complete, it has been left to show how this function could provide more helpful error
|
|
137
|
-
// messages once an update to stylelint is possible.
|
|
138
|
-
/* eslint-disable no-unreachable -- See above */
|
|
139
|
-
let message = `Invalid property provided for ${property}.`;
|
|
140
|
-
let ruleKey;
|
|
141
|
-
if (new RegExp(/color/).test(property)) {
|
|
142
|
-
ruleKey = "/color/";
|
|
143
|
-
} else if (new RegExp(/margin/).test(property)) {
|
|
144
|
-
ruleKey = "/margin/";
|
|
145
|
-
} else if (new RegExp(/padding/).test(property)) {
|
|
146
|
-
ruleKey = "/padding/";
|
|
147
|
-
} else {
|
|
148
|
-
ruleKey = property;
|
|
149
|
-
}
|
|
150
|
-
switch (ruleKey) {
|
|
151
|
-
case "z-index": {
|
|
152
|
-
message = `z-index must use one of the values specified in the theme.json file under \`settings.custom.z-index\`.`;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case "/color/": {
|
|
156
|
-
message = `Colour values must use one of the values specified in the theme.json file under \`settings.color.palette\`.`;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case "/margin/": {
|
|
160
|
-
message = `Margin values must use one of the values specified in the theme.json file under \`settings.spacing.spacingSizes\`.`;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case "/padding/": {
|
|
164
|
-
message = `Padding values must use one of the values specified in the theme.json file under \`settings.spacing.spacingSizes\`.`;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case "font-size": {
|
|
168
|
-
message = `Font size values must use one of the values specified in the theme.json file under \`settings.typography.fontSizes\`.`;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
case "font-family": {
|
|
172
|
-
message = `Font family values must use one of the values specified in the theme.json file under \`settings.typography.fontFamilies\`.`;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return `${message} Value provided: ${value} (declaration-property-value-allowed-list)`;
|
|
177
|
-
/* eslint-enable no-unreachable */
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
module.exports = {
|
|
184
|
-
...baseConfig,
|
|
185
|
-
rules: {
|
|
186
|
-
...baseConfig.rules,
|
|
187
|
-
...rules,
|
|
188
|
-
},
|
|
189
|
-
};
|
package/stylelint/theme-json.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./theme-json.mjs";
|
package/stylelint/theme-json.mjs
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import baseConfig from "./base.mjs";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {({property: string|RegExp, varInfo: {type: "custom"|"preset", slug:string},shorthand?: 1 | 2 | 3 | 4 , additionalAllowedValues?: (string|RegExp)[]})[]} values
|
|
6
|
-
*/
|
|
7
|
-
function createAllowedPropertyList(values) {
|
|
8
|
-
/**
|
|
9
|
-
* @type {Record<string,string[]>}
|
|
10
|
-
*/
|
|
11
|
-
const allowedPropertyList = {};
|
|
12
|
-
for (const {
|
|
13
|
-
property,
|
|
14
|
-
varInfo,
|
|
15
|
-
shorthand = 1,
|
|
16
|
-
additionalAllowedValues = [],
|
|
17
|
-
} of values) {
|
|
18
|
-
const isRegexProperty = property instanceof RegExp;
|
|
19
|
-
const possibleValues = [];
|
|
20
|
-
const possibleVars = [
|
|
21
|
-
...additionalAllowedValues.map((value) =>
|
|
22
|
-
value instanceof RegExp ? value.toString() : value,
|
|
23
|
-
),
|
|
24
|
-
`(var\\([\\s]*--wp--${varInfo.type}--${varInfo.slug}--([a-z-0-9]+[\\s]*)\\))`,
|
|
25
|
-
];
|
|
26
|
-
if (isRegexProperty) {
|
|
27
|
-
possibleVars.push(
|
|
28
|
-
`(var\\([\\s]*--[a-z-0-9]*${property.toString().slice(1, -1)}[a-z-0-9]*[\\s]*\\))`,
|
|
29
|
-
);
|
|
30
|
-
} else if (property) {
|
|
31
|
-
possibleVars.push(
|
|
32
|
-
`(var\\([\\s]*--[a-z-0-9]*${property}[a-z-0-9]*[\\s]*\\))`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
possibleValues.push(
|
|
36
|
-
// For each shorthand value, allow one of the possible values followed by a space, or allow it to be blank
|
|
37
|
-
`/^${shorthand > 1 ? `((${possibleVars.join("|")})[\\s]*){0,${shorthand - 1}}` : ""}(${possibleVars.join("|")})$/`,
|
|
38
|
-
);
|
|
39
|
-
allowedPropertyList[property.toString()] = possibleValues;
|
|
40
|
-
if (!isRegexProperty) {
|
|
41
|
-
allowedPropertyList[`/--[a-z-0-9]*${property}[a-z-0-9]*/`] =
|
|
42
|
-
possibleValues;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return allowedPropertyList;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const rules = {
|
|
49
|
-
"declaration-property-value-allowed-list": [
|
|
50
|
-
createAllowedPropertyList([
|
|
51
|
-
{
|
|
52
|
-
property: /border((-top|-bottom)(-left|-right))?-radius/,
|
|
53
|
-
varInfo: {
|
|
54
|
-
type: "custom",
|
|
55
|
-
slug: "radius",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
property: "border-radius",
|
|
60
|
-
varInfo: {
|
|
61
|
-
type: "custom",
|
|
62
|
-
slug: "radius",
|
|
63
|
-
},
|
|
64
|
-
shorthand: 4,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
property: "box-shadow",
|
|
68
|
-
varInfo: {
|
|
69
|
-
type: "preset",
|
|
70
|
-
slug: "shadow",
|
|
71
|
-
},
|
|
72
|
-
additionalAllowedValues: ["none", "unset"],
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
property: /color/,
|
|
76
|
-
varInfo: {
|
|
77
|
-
type: "preset",
|
|
78
|
-
slug: "color",
|
|
79
|
-
},
|
|
80
|
-
additionalAllowedValues: ["inherit", "currentcolor"],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
property: "background-color",
|
|
84
|
-
varInfo: {
|
|
85
|
-
type: "preset",
|
|
86
|
-
slug: "color",
|
|
87
|
-
},
|
|
88
|
-
additionalAllowedValues: ["transparent"],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
property: "font-family",
|
|
92
|
-
varInfo: {
|
|
93
|
-
type: "preset",
|
|
94
|
-
slug: "font-family",
|
|
95
|
-
},
|
|
96
|
-
additionalAllowedValues: ["inherit"],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
property: "font-size",
|
|
100
|
-
varInfo: {
|
|
101
|
-
type: "preset",
|
|
102
|
-
slug: "font-size",
|
|
103
|
-
},
|
|
104
|
-
additionalAllowedValues: ["inherit"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
property: /(?<!scroll-)margin/,
|
|
108
|
-
varInfo: {
|
|
109
|
-
type: "preset",
|
|
110
|
-
slug: "spacing",
|
|
111
|
-
},
|
|
112
|
-
shorthand: 4,
|
|
113
|
-
additionalAllowedValues: ["auto", "var\\(--wp--style--block-gap\\)"],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
property: /padding/,
|
|
117
|
-
varInfo: {
|
|
118
|
-
type: "preset",
|
|
119
|
-
slug: "spacing",
|
|
120
|
-
},
|
|
121
|
-
shorthand: 4,
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
property: "z-index",
|
|
125
|
-
varInfo: {
|
|
126
|
-
type: "custom",
|
|
127
|
-
slug: "z-index",
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
]),
|
|
131
|
-
{
|
|
132
|
-
severity: "warning",
|
|
133
|
-
message: (property, value) => {
|
|
134
|
-
// Until updated, property and value will always return undefined.
|
|
135
|
-
return `Most values for this type of property should be defined in theme.json. (declaration-property-value-allowed-list)`;
|
|
136
|
-
// The following code is not complete, it has been left to show how this function could provide more helpful error
|
|
137
|
-
// messages once an update to stylelint is possible.
|
|
138
|
-
/* eslint-disable no-unreachable -- See above */
|
|
139
|
-
let message = `Invalid property provided for ${property}.`;
|
|
140
|
-
let ruleKey;
|
|
141
|
-
if (new RegExp(/color/).test(property)) {
|
|
142
|
-
ruleKey = "/color/";
|
|
143
|
-
} else if (new RegExp(/margin/).test(property)) {
|
|
144
|
-
ruleKey = "/margin/";
|
|
145
|
-
} else if (new RegExp(/padding/).test(property)) {
|
|
146
|
-
ruleKey = "/padding/";
|
|
147
|
-
} else {
|
|
148
|
-
ruleKey = property;
|
|
149
|
-
}
|
|
150
|
-
switch (ruleKey) {
|
|
151
|
-
case "z-index": {
|
|
152
|
-
message = `z-index must use one of the values specified in the theme.json file under \`settings.custom.z-index\`.`;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case "/color/": {
|
|
156
|
-
message = `Colour values must use one of the values specified in the theme.json file under \`settings.color.palette\`.`;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case "/margin/": {
|
|
160
|
-
message = `Margin values must use one of the values specified in the theme.json file under \`settings.spacing.spacingSizes\`.`;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case "/padding/": {
|
|
164
|
-
message = `Padding values must use one of the values specified in the theme.json file under \`settings.spacing.spacingSizes\`.`;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case "font-size": {
|
|
168
|
-
message = `Font size values must use one of the values specified in the theme.json file under \`settings.typography.fontSizes\`.`;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
case "font-family": {
|
|
172
|
-
message = `Font family values must use one of the values specified in the theme.json file under \`settings.typography.fontFamilies\`.`;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return `${message} Value provided: ${value} (declaration-property-value-allowed-list)`;
|
|
177
|
-
/* eslint-enable no-unreachable */
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
export default {
|
|
184
|
-
...baseConfig,
|
|
185
|
-
rules: {
|
|
186
|
-
...baseConfig.rules,
|
|
187
|
-
...rules,
|
|
188
|
-
},
|
|
189
|
-
};
|