@servicetitan/stylelint-config 30.3.1 → 31.0.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/dist/function-url-no-absolute.js +25 -17
- package/dist/function-url-no-absolute.js.map +1 -1
- package/dist/index.js +72 -48
- package/dist/index.js.map +1 -1
- package/dist/use-tokens/index.js +75 -67
- package/dist/use-tokens/index.js.map +1 -1
- package/dist/use-tokens/values.js +64 -31
- package/dist/use-tokens/values.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const _stylelint = require("stylelint");
|
|
3
|
+
const _trim = /*#__PURE__*/ _interop_require_default(require("lodash/trim"));
|
|
4
|
+
function _interop_require_default(obj) {
|
|
5
|
+
return obj && obj.__esModule ? obj : {
|
|
6
|
+
default: obj
|
|
7
|
+
};
|
|
8
|
+
}
|
|
7
9
|
const functionArgumentsSearch = require('stylelint/lib/utils/functionArgumentsSearch.cjs');
|
|
8
|
-
const isAbsoluteUrl = (url)
|
|
10
|
+
const isAbsoluteUrl = (url)=>/^\//.test(url) && !/^\/\//.test(url);
|
|
9
11
|
const ruleName = '@servicetitan/function-url-no-absolute';
|
|
10
|
-
const messages =
|
|
11
|
-
rejected: 'Unexpected absolute url'
|
|
12
|
+
const messages = _stylelint.utils.ruleMessages(ruleName, {
|
|
13
|
+
rejected: 'Unexpected absolute url'
|
|
12
14
|
});
|
|
13
|
-
const plugin = actual
|
|
14
|
-
return (root, result)
|
|
15
|
-
const validOptions =
|
|
15
|
+
const plugin = (actual)=>{
|
|
16
|
+
return (root, result)=>{
|
|
17
|
+
const validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
|
18
|
+
actual
|
|
19
|
+
});
|
|
16
20
|
if (!validOptions) {
|
|
17
21
|
return;
|
|
18
22
|
}
|
|
19
|
-
root.walkDecls(decl
|
|
20
|
-
functionArgumentsSearch(decl.toString().toLowerCase(), 'url', (args, index)
|
|
21
|
-
const url = (0,
|
|
23
|
+
root.walkDecls((decl)=>{
|
|
24
|
+
functionArgumentsSearch(decl.toString().toLowerCase(), 'url', (args, index)=>{
|
|
25
|
+
const url = (0, _trim.default)(args, ' \'"');
|
|
22
26
|
if (!isAbsoluteUrl(url)) {
|
|
23
27
|
return;
|
|
24
28
|
}
|
|
25
|
-
|
|
29
|
+
_stylelint.utils.report({
|
|
26
30
|
message: messages.rejected,
|
|
27
31
|
node: decl,
|
|
28
32
|
index,
|
|
29
33
|
result,
|
|
30
|
-
ruleName
|
|
34
|
+
ruleName
|
|
31
35
|
});
|
|
32
36
|
});
|
|
33
37
|
});
|
|
@@ -35,5 +39,9 @@ const plugin = actual => {
|
|
|
35
39
|
};
|
|
36
40
|
plugin.ruleName = ruleName;
|
|
37
41
|
plugin.messages = messages;
|
|
38
|
-
module.exports = Object.assign((0,
|
|
42
|
+
module.exports = Object.assign((0, _stylelint.createPlugin)(ruleName, plugin), {
|
|
43
|
+
ruleName,
|
|
44
|
+
messages
|
|
45
|
+
});
|
|
46
|
+
|
|
39
47
|
//# sourceMappingURL=function-url-no-absolute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/function-url-no-absolute.ts"],"sourcesContent":["import { Rule, createPlugin, utils } from 'stylelint';\n\nimport trim from 'lodash/trim';\n\nconst functionArgumentsSearch = require('stylelint/lib/utils/functionArgumentsSearch.cjs') as (\n source: string,\n functionName: string,\n callback: (args: string, index: number) => void\n) => void;\n\nconst isAbsoluteUrl = (url: string) => /^\\//.test(url) && !/^\\/\\//.test(url);\n\nconst ruleName = '@servicetitan/function-url-no-absolute';\nconst messages = utils.ruleMessages(ruleName, {\n rejected: 'Unexpected absolute url',\n});\n\nconst plugin: Rule = actual => {\n return (root, result) => {\n const validOptions = utils.validateOptions(result, ruleName, { actual });\n\n if (!validOptions) {\n return;\n }\n\n root.walkDecls(decl => {\n functionArgumentsSearch(decl.toString().toLowerCase(), 'url', (args, index) => {\n const url = trim(args, ' \\'\"');\n\n if (!isAbsoluteUrl(url)) {\n return;\n }\n\n utils.report({\n message: messages.rejected,\n node: decl,\n index,\n result,\n ruleName,\n });\n });\n });\n };\n};\n\nplugin.ruleName = ruleName;\nplugin.messages = messages;\n\nexport = Object.assign(createPlugin(ruleName, plugin), { ruleName, messages });\n"],"names":["functionArgumentsSearch","require","isAbsoluteUrl","url","test","ruleName","messages","utils","ruleMessages","rejected","plugin","actual","root","result","validOptions","validateOptions","walkDecls","decl","toString","toLowerCase","args","index","trim","report","message","node","Object","assign","createPlugin"],"mappings":";2BAA0C;6DAEzB;;;;;;AAEjB,MAAMA,0BAA0BC,QAAQ;AAMxC,MAAMC,gBAAgB,CAACC,MAAgB,MAAMC,IAAI,CAACD,QAAQ,CAAC,QAAQC,IAAI,CAACD;AAExE,MAAME,WAAW;AACjB,MAAMC,WAAWC,gBAAK,CAACC,YAAY,CAACH,UAAU;IAC1CI,UAAU;AACd;AAEA,MAAMC,SAAeC,CAAAA;IACjB,OAAO,CAACC,MAAMC;QACV,MAAMC,eAAeP,gBAAK,CAACQ,eAAe,CAACF,QAAQR,UAAU;YAAEM;QAAO;QAEtE,IAAI,CAACG,cAAc;YACf;QACJ;QAEAF,KAAKI,SAAS,CAACC,CAAAA;YACXjB,wBAAwBiB,KAAKC,QAAQ,GAAGC,WAAW,IAAI,OAAO,CAACC,MAAMC;gBACjE,MAAMlB,MAAMmB,IAAAA,aAAI,EAACF,MAAM;gBAEvB,IAAI,CAAClB,cAAcC,MAAM;oBACrB;gBACJ;gBAEAI,gBAAK,CAACgB,MAAM,CAAC;oBACTC,SAASlB,SAASG,QAAQ;oBAC1BgB,MAAMR;oBACNI;oBACAR;oBACAR;gBACJ;YACJ;QACJ;IACJ;AACJ;AAEAK,OAAOL,QAAQ,GAAGA;AAClBK,OAAOJ,QAAQ,GAAGA;iBAEToB,OAAOC,MAAM,CAACC,IAAAA,uBAAY,EAACvB,UAAUK,SAAS;IAAEL;IAAUC;AAAS"}
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
module.exports = {
|
|
3
|
-
extends: [
|
|
4
|
-
|
|
3
|
+
extends: [
|
|
4
|
+
'stylelint-config-standard',
|
|
5
|
+
'stylelint-prettier/recommended'
|
|
6
|
+
],
|
|
7
|
+
plugins: [
|
|
8
|
+
'./function-url-no-absolute',
|
|
9
|
+
'./use-tokens'
|
|
10
|
+
],
|
|
5
11
|
overrides: [
|
|
6
12
|
{
|
|
7
|
-
files: [
|
|
8
|
-
|
|
13
|
+
files: [
|
|
14
|
+
'*.scss',
|
|
15
|
+
'**/*.scss'
|
|
16
|
+
],
|
|
17
|
+
extends: [
|
|
18
|
+
'stylelint-config-standard-scss'
|
|
19
|
+
],
|
|
9
20
|
rules: {
|
|
10
21
|
'at-rule-descriptor-no-unknown': null,
|
|
11
22
|
'at-rule-descriptor-value-no-unknown': null,
|
|
12
23
|
'at-rule-prelude-no-invalid': null,
|
|
13
|
-
'declaration-property-value-no-unknown': null
|
|
14
|
-
}
|
|
24
|
+
'declaration-property-value-no-unknown': null
|
|
25
|
+
}
|
|
15
26
|
},
|
|
16
27
|
{
|
|
17
|
-
files: [
|
|
18
|
-
|
|
28
|
+
files: [
|
|
29
|
+
'*.less',
|
|
30
|
+
'**/*.less'
|
|
31
|
+
],
|
|
32
|
+
extends: [
|
|
33
|
+
'stylelint-config-standard-less'
|
|
34
|
+
],
|
|
19
35
|
rules: {
|
|
20
36
|
'at-rule-descriptor-no-unknown': null,
|
|
21
37
|
'at-rule-descriptor-value-no-unknown': null,
|
|
22
38
|
'at-rule-prelude-no-invalid': null,
|
|
23
|
-
'declaration-property-value-no-unknown': null
|
|
24
|
-
}
|
|
25
|
-
}
|
|
39
|
+
'declaration-property-value-no-unknown': null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
26
42
|
],
|
|
27
43
|
rules: {
|
|
28
44
|
'function-no-unknown': [
|
|
@@ -31,8 +47,7 @@ module.exports = {
|
|
|
31
47
|
/*
|
|
32
48
|
* these are all less functions at the moment, see the full list here https://lesscss.org/functions/
|
|
33
49
|
* 'extend' and '-' are also added to the list as they are identified as functions thought they are not
|
|
34
|
-
*/
|
|
35
|
-
ignoreFunctions: [
|
|
50
|
+
*/ ignoreFunctions: [
|
|
36
51
|
'extend',
|
|
37
52
|
'-',
|
|
38
53
|
'if',
|
|
@@ -123,47 +138,56 @@ module.exports = {
|
|
|
123
138
|
'difference',
|
|
124
139
|
'exclusion',
|
|
125
140
|
'average',
|
|
126
|
-
'negation'
|
|
127
|
-
]
|
|
128
|
-
}
|
|
141
|
+
'negation'
|
|
142
|
+
]
|
|
143
|
+
}
|
|
129
144
|
],
|
|
130
145
|
'selector-pseudo-class-no-unknown': [
|
|
131
146
|
true,
|
|
132
147
|
{
|
|
133
|
-
ignorePseudoClasses: [
|
|
134
|
-
|
|
148
|
+
ignorePseudoClasses: [
|
|
149
|
+
'global',
|
|
150
|
+
'local'
|
|
151
|
+
]
|
|
152
|
+
}
|
|
135
153
|
],
|
|
136
154
|
'@servicetitan/function-url-no-absolute': true,
|
|
137
155
|
'@servicetitan/use-tokens': true,
|
|
138
|
-
'no-invalid-position-at-import-rule': null,
|
|
139
|
-
'at-rule-empty-line-before': null,
|
|
140
|
-
'alpha-value-notation': null,
|
|
141
|
-
'color-function-notation': null,
|
|
142
|
-
'color-hex-length': null,
|
|
143
|
-
'comment-whitespace-inside': null,
|
|
144
|
-
'custom-property-pattern': null,
|
|
145
|
-
'declaration-block-no-shorthand-property-overrides': [
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
'
|
|
155
|
-
'
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
164
|
-
'
|
|
165
|
-
'
|
|
166
|
-
'
|
|
167
|
-
|
|
156
|
+
'no-invalid-position-at-import-rule': null,
|
|
157
|
+
'at-rule-empty-line-before': null,
|
|
158
|
+
'alpha-value-notation': null,
|
|
159
|
+
'color-function-notation': null,
|
|
160
|
+
'color-hex-length': null,
|
|
161
|
+
'comment-whitespace-inside': null,
|
|
162
|
+
'custom-property-pattern': null,
|
|
163
|
+
'declaration-block-no-shorthand-property-overrides': [
|
|
164
|
+
true,
|
|
165
|
+
{
|
|
166
|
+
severity: 'warning'
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
'declaration-empty-line-before': null,
|
|
170
|
+
'declaration-block-no-redundant-longhand-properties': null,
|
|
171
|
+
'font-family-name-quotes': null,
|
|
172
|
+
'function-url-quotes': null,
|
|
173
|
+
'hue-degree-notation': null,
|
|
174
|
+
'import-notation': null,
|
|
175
|
+
'keyframes-name-pattern': null,
|
|
176
|
+
'length-zero-no-unit': null,
|
|
177
|
+
'media-feature-range-notation': null,
|
|
178
|
+
'media-query-no-invalid': null,
|
|
179
|
+
'number-max-precision': null,
|
|
180
|
+
'property-no-vendor-prefix': null,
|
|
181
|
+
'rule-empty-line-before': null,
|
|
182
|
+
'shorthand-property-no-redundant-values': null,
|
|
183
|
+
'selector-class-pattern': null,
|
|
184
|
+
'selector-id-pattern': null,
|
|
185
|
+
'selector-not-notation': null,
|
|
186
|
+
'selector-pseudo-element-colon-notation': null,
|
|
187
|
+
'value-keyword-case': null,
|
|
188
|
+
'value-no-vendor-prefix': null,
|
|
189
|
+
'color-function-alias-notation': null
|
|
190
|
+
}
|
|
168
191
|
};
|
|
192
|
+
|
|
169
193
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Config } from 'stylelint';\n\nexport = {\n extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'],\n plugins: ['./function-url-no-absolute', './use-tokens'],\n overrides: [\n {\n files: ['*.scss', '**/*.scss'],\n extends: ['stylelint-config-standard-scss'],\n rules: {\n 'at-rule-descriptor-no-unknown': null,\n 'at-rule-descriptor-value-no-unknown': null,\n 'at-rule-prelude-no-invalid': null,\n 'declaration-property-value-no-unknown': null,\n },\n },\n {\n files: ['*.less', '**/*.less'],\n extends: ['stylelint-config-standard-less'],\n rules: {\n 'at-rule-descriptor-no-unknown': null,\n 'at-rule-descriptor-value-no-unknown': null,\n 'at-rule-prelude-no-invalid': null,\n 'declaration-property-value-no-unknown': null,\n },\n },\n ],\n rules: {\n 'function-no-unknown': [\n true,\n {\n /*\n * these are all less functions at the moment, see the full list here https://lesscss.org/functions/\n * 'extend' and '-' are also added to the list as they are identified as functions thought they are not\n */\n ignoreFunctions: [\n 'extend',\n '-',\n 'if',\n 'boolean',\n 'escape',\n 'e',\n '%',\n 'replace',\n 'length',\n 'extract',\n 'range',\n 'each',\n 'ceil',\n 'floor',\n 'percentage',\n 'round',\n 'sqrt',\n 'abs',\n 'sin',\n 'asin',\n 'cos',\n 'acos',\n 'tan',\n 'atan',\n 'pi',\n 'pow',\n 'mod',\n 'min',\n 'max',\n 'isnumber',\n 'isstring',\n 'iscolor',\n 'iskeyword',\n 'isurl',\n 'ispixel',\n 'isem',\n 'ispercentage',\n 'isunit',\n 'isruleset',\n 'isdefined',\n 'color',\n 'image-size',\n 'image-width',\n 'image-height',\n 'convert',\n 'data-uri',\n 'default',\n 'unit',\n 'get-unit',\n 'svg-gradient',\n 'rgb',\n 'rgba',\n 'argb',\n 'hsl',\n 'hsla',\n 'hsv',\n 'hsva',\n 'hue',\n 'saturation',\n 'lightness',\n 'hsvhue',\n 'hsvsaturation',\n 'hsvvalue',\n 'red',\n 'green',\n 'blue',\n 'alpha',\n 'luma',\n 'luminance',\n 'saturate',\n 'desaturate',\n 'lighten',\n 'darken',\n 'fadein',\n 'fadeout',\n 'fade',\n 'spin',\n 'mix',\n 'tint',\n 'shade',\n 'greyscale',\n 'contrast',\n 'multiply',\n 'screen',\n 'overlay',\n 'softlight',\n 'hardlight',\n 'difference',\n 'exclusion',\n 'average',\n 'negation',\n ],\n },\n ],\n 'selector-pseudo-class-no-unknown': [\n true,\n {\n ignorePseudoClasses: ['global', 'local'],\n },\n ],\n '@servicetitan/function-url-no-absolute': true,\n '@servicetitan/use-tokens': true,\n 'no-invalid-position-at-import-rule': null, // Not supported for LESS/SASS. Enable for CSS when https://github.com/stylelint/stylelint/issues/3128 is implemented.\n 'at-rule-empty-line-before': null, // Require or disallow an empty line before at-rules\n 'alpha-value-notation': null, // Specify percentage or number notation for alpha-values\n 'color-function-notation': null, // Specify modern or legacy notation for color-functions\n 'color-hex-length': null, // Specify short or long notation for hex colors\n 'comment-whitespace-inside': null, // Require or disallow whitespace on the inside of comment markers\n 'custom-property-pattern': null, // Specify a pattern for custom properties\n 'declaration-block-no-shorthand-property-overrides': [true, { severity: 'warning' }], // Disallow shorthand properties that override related longhand properties\n 'declaration-empty-line-before': null, // Require or disallow an empty line before declarations\n 'declaration-block-no-redundant-longhand-properties': null, // Disallow redundant longhand properties within declaration-block\n 'font-family-name-quotes': null, // Require or disallow quotes for font family names\n 'function-url-quotes': null, // Require or disallow quotes for urls.\n 'hue-degree-notation': null, // Specify number or angle notation for degree hues\n 'import-notation': null, // Specify string or URL notation for @import rules\n 'keyframes-name-pattern': null, // Specify a pattern for keyframe names\n 'length-zero-no-unit': null, // Disallow units for zero lengths\n 'media-feature-range-notation': null, // Specify context or prefix notation for media feature ranges\n 'media-query-no-invalid': null, // Disallow invalid media queries (should not turn it on for CSS-like languages, such as Sass or Less)\n 'number-max-precision': null, // Limit the number of decimal places allowed in numbers\n 'property-no-vendor-prefix': null, // Disallow vendor prefixes for properties\n 'rule-empty-line-before': null, // Require or disallow an empty line before rules\n 'shorthand-property-no-redundant-values': null, // Disallow redundant values within shorthand properties\n 'selector-class-pattern': null, // Specify a pattern for class selectors\n 'selector-id-pattern': null, // Specify a pattern for ID selectors\n 'selector-not-notation': null, // Specify simple or complex notation for :not() pseudo-class selectors\n 'selector-pseudo-element-colon-notation': null, // Specify single or double colon notation for applicable pseudo-element selectors\n 'value-keyword-case': null, // Specify lowercase or uppercase for keywords values\n 'value-no-vendor-prefix': null, // Specify lowercase or uppercase for keywords values\n 'color-function-alias-notation': null, // Specify alias notation for color-functions.\n },\n} as Partial<Config>;\n"],"names":["extends","plugins","overrides","files","rules","ignoreFunctions","ignorePseudoClasses","severity"],"mappings":";iBAES;IACLA,SAAS;QAAC;QAA6B;KAAiC;IACxEC,SAAS;QAAC;QAA8B;KAAe;IACvDC,WAAW;QACP;YACIC,OAAO;gBAAC;gBAAU;aAAY;YAC9BH,SAAS;gBAAC;aAAiC;YAC3CI,OAAO;gBACH,iCAAiC;gBACjC,uCAAuC;gBACvC,8BAA8B;gBAC9B,yCAAyC;YAC7C;QACJ;QACA;YACID,OAAO;gBAAC;gBAAU;aAAY;YAC9BH,SAAS;gBAAC;aAAiC;YAC3CI,OAAO;gBACH,iCAAiC;gBACjC,uCAAuC;gBACvC,8BAA8B;gBAC9B,yCAAyC;YAC7C;QACJ;KACH;IACDA,OAAO;QACH,uBAAuB;YACnB;YACA;gBACI;;;iBAGC,GACDC,iBAAiB;oBACb;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;iBACH;YACL;SACH;QACD,oCAAoC;YAChC;YACA;gBACIC,qBAAqB;oBAAC;oBAAU;iBAAQ;YAC5C;SACH;QACD,0CAA0C;QAC1C,4BAA4B;QAC5B,sCAAsC;QACtC,6BAA6B;QAC7B,wBAAwB;QACxB,2BAA2B;QAC3B,oBAAoB;QACpB,6BAA6B;QAC7B,2BAA2B;QAC3B,qDAAqD;YAAC;YAAM;gBAAEC,UAAU;YAAU;SAAE;QACpF,iCAAiC;QACjC,sDAAsD;QACtD,2BAA2B;QAC3B,uBAAuB;QACvB,uBAAuB;QACvB,mBAAmB;QACnB,0BAA0B;QAC1B,uBAAuB;QACvB,gCAAgC;QAChC,0BAA0B;QAC1B,wBAAwB;QACxB,6BAA6B;QAC7B,0BAA0B;QAC1B,0CAA0C;QAC1C,0BAA0B;QAC1B,uBAAuB;QACvB,yBAAyB;QACzB,0CAA0C;QAC1C,sBAAsB;QACtB,0BAA0B;QAC1B,iCAAiC;IACrC;AACJ"}
|
package/dist/use-tokens/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const _stylelint = require("stylelint");
|
|
3
|
+
const _color = /*#__PURE__*/ _interop_require_default(require("color"));
|
|
4
|
+
const _values = require("./values");
|
|
5
|
+
function _interop_require_default(obj) {
|
|
6
|
+
return obj && obj.__esModule ? obj : {
|
|
7
|
+
default: obj
|
|
8
|
+
};
|
|
9
|
+
}
|
|
8
10
|
const ruleName = '@servicetitan/use-tokens';
|
|
9
|
-
const messages =
|
|
10
|
-
variableExpected: (expected, found)
|
|
11
|
+
const messages = _stylelint.utils.ruleMessages(ruleName, {
|
|
12
|
+
variableExpected: (expected, found)=>`You should use "${expected}" variable from the \`@servicetitan/tokens\` instead of "${found}".`
|
|
11
13
|
});
|
|
12
|
-
const plugin = (_0, _1, context)
|
|
13
|
-
return (root, result)
|
|
14
|
-
var
|
|
15
|
-
const extension = (
|
|
14
|
+
const plugin = (_0, _1, context)=>{
|
|
15
|
+
return (root, result)=>{
|
|
16
|
+
var _result_opts_from_split_pop, _result_opts_from, _result_opts;
|
|
17
|
+
const extension = (_result_opts = result.opts) === null || _result_opts === void 0 ? void 0 : (_result_opts_from = _result_opts.from) === null || _result_opts_from === void 0 ? void 0 : (_result_opts_from_split_pop = _result_opts_from.split('.').pop()) === null || _result_opts_from_split_pop === void 0 ? void 0 : _result_opts_from_split_pop.toLowerCase();
|
|
16
18
|
function convertToVariable(key) {
|
|
17
|
-
switch
|
|
19
|
+
switch(extension){
|
|
18
20
|
case 'less':
|
|
19
21
|
return `@${key}`;
|
|
20
22
|
case 'sass':
|
|
@@ -24,29 +26,29 @@ const plugin = (_0, _1, context) => {
|
|
|
24
26
|
return `var(--${key})`;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
root.walkDecls(decl
|
|
28
|
-
function lint(collection, { condition, transformer, solid
|
|
29
|
-
var _a;
|
|
29
|
+
root.walkDecls((decl)=>{
|
|
30
|
+
function lint(collection, { condition, transformer, solid } = {}) {
|
|
30
31
|
if (condition && !condition(decl.prop)) {
|
|
31
32
|
return true;
|
|
32
33
|
}
|
|
33
|
-
const values = !solid ? decl.value.split(' ') : [
|
|
34
|
+
const values = !solid ? decl.value.split(' ') : [
|
|
35
|
+
decl.value
|
|
36
|
+
];
|
|
34
37
|
let reported = false;
|
|
35
|
-
for (const rawValue of values)
|
|
36
|
-
|
|
38
|
+
for (const rawValue of values){
|
|
39
|
+
var _transformer;
|
|
40
|
+
const value = (_transformer = transformer === null || transformer === void 0 ? void 0 : transformer(rawValue)) !== null && _transformer !== void 0 ? _transformer : rawValue;
|
|
37
41
|
if (collection[value]) {
|
|
38
|
-
const variable = (rawValue.startsWith('-') ? '-' : '') +
|
|
39
|
-
convertToVariable(collection[value]);
|
|
42
|
+
const variable = (rawValue.startsWith('-') ? '-' : '') + convertToVariable(collection[value]);
|
|
40
43
|
if (context.fix) {
|
|
41
44
|
values[values.indexOf(rawValue)] = variable;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
stylelint_1.utils.report({
|
|
45
|
+
} else {
|
|
46
|
+
_stylelint.utils.report({
|
|
45
47
|
node: decl,
|
|
46
48
|
message: messages.variableExpected(variable, rawValue),
|
|
47
49
|
word: value,
|
|
48
50
|
ruleName,
|
|
49
|
-
result
|
|
51
|
+
result
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
reported = true;
|
|
@@ -58,49 +60,51 @@ const plugin = (_0, _1, context) => {
|
|
|
58
60
|
return !reported;
|
|
59
61
|
}
|
|
60
62
|
const linters = {
|
|
61
|
-
colors: ()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
colors: ()=>lint(_values.colors, {
|
|
64
|
+
transformer: (value)=>{
|
|
65
|
+
try {
|
|
66
|
+
return new _color.default(value).hex();
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
71
|
+
}),
|
|
72
|
+
typescales: ()=>lint(_values.typescales, {
|
|
73
|
+
condition: (property)=>property === 'font-size',
|
|
74
|
+
solid: true
|
|
75
|
+
}),
|
|
76
|
+
borderRadiuses: ()=>lint(_values.borderRadiuses, {
|
|
77
|
+
condition: (property)=>property.startsWith('border-') && property.endsWith('-radius'),
|
|
78
|
+
transformer: (value)=>value === '0px' ? '0' : value
|
|
79
|
+
}),
|
|
80
|
+
lintSpacings: ()=>lint(_values.spacings, {
|
|
81
|
+
// other spacings like "top"?
|
|
82
|
+
condition: (property)=>property.startsWith('margin') || property.startsWith('padding'),
|
|
83
|
+
transformer: (value)=>value === '0px' ? '0' : value.startsWith('-') ? value.slice(1) : value
|
|
84
|
+
}),
|
|
85
|
+
fontWeights: ()=>lint(_values.fontWeights, {
|
|
86
|
+
condition: (property)=>property === 'font-weight',
|
|
87
|
+
solid: true
|
|
88
|
+
}),
|
|
89
|
+
opacities: ()=>lint(_values.opacities, {
|
|
90
|
+
condition: (property)=>property === 'opacity',
|
|
91
|
+
transformer: (value)=>value.startsWith('0.') ? value.slice(1) : value,
|
|
92
|
+
solid: true
|
|
93
|
+
}),
|
|
94
|
+
zIndexes: ()=>lint(_values.zIndexes, {
|
|
95
|
+
condition: (property)=>property === 'z-index',
|
|
96
|
+
solid: true
|
|
97
|
+
}),
|
|
98
|
+
lineHeights: ()=>lint(_values.lineHeights, {
|
|
99
|
+
condition: (property)=>property === 'line-height',
|
|
100
|
+
solid: true
|
|
101
|
+
}),
|
|
102
|
+
fontFamilies: ()=>lint(_values.fontFamilies, {
|
|
103
|
+
condition: (property)=>property === 'font-family',
|
|
104
|
+
solid: true
|
|
105
|
+
})
|
|
102
106
|
};
|
|
103
|
-
for (const handler of Object.values(linters))
|
|
107
|
+
for (const handler of Object.values(linters)){
|
|
104
108
|
if (!handler()) {
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
@@ -110,5 +114,9 @@ const plugin = (_0, _1, context) => {
|
|
|
110
114
|
};
|
|
111
115
|
plugin.ruleName = ruleName;
|
|
112
116
|
plugin.messages = messages;
|
|
113
|
-
module.exports = Object.assign((0,
|
|
117
|
+
module.exports = Object.assign((0, _stylelint.createPlugin)(ruleName, plugin), {
|
|
118
|
+
ruleName,
|
|
119
|
+
messages
|
|
120
|
+
});
|
|
121
|
+
|
|
114
122
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/use-tokens/index.ts"],"sourcesContent":["import { Rule, createPlugin, utils } from 'stylelint';\n\nimport Color from 'color';\n\nimport {\n colors,\n typescales,\n borderRadiuses,\n spacings,\n fontWeights,\n opacities,\n zIndexes,\n lineHeights,\n fontFamilies,\n} from './values';\n\nconst ruleName = '@servicetitan/use-tokens';\nconst messages = utils.ruleMessages(ruleName, {\n variableExpected: (expected: string, found: string) =>\n `You should use \"${expected}\" variable from the \\`@servicetitan/tokens\\` instead of \"${found}\".`,\n});\n\nconst plugin: Rule = (_0, _1, context) => {\n return (root, result) => {\n const extension = result.opts?.from?.split('.').pop()?.toLowerCase();\n\n function convertToVariable(key: string) {\n switch (extension) {\n case 'less':\n return `@${key}`;\n\n case 'sass':\n case 'scss':\n return `$${key}`;\n\n default:\n return `var(--${key})`;\n }\n }\n\n root.walkDecls(decl => {\n function lint(\n collection: Record<string, string>,\n {\n condition,\n transformer,\n solid,\n }: {\n condition?: (property: string) => boolean;\n transformer?: (value: string) => string;\n solid?: boolean;\n } = {}\n ) {\n if (condition && !condition(decl.prop)) {\n return true;\n }\n\n const values = !solid ? decl.value.split(' ') : [decl.value];\n\n let reported = false;\n for (const rawValue of values) {\n const value = transformer?.(rawValue) ?? rawValue;\n if (collection[value]) {\n const variable =\n (rawValue.startsWith('-') ? '-' : '') +\n convertToVariable(collection[value]);\n\n if (context.fix) {\n values[values.indexOf(rawValue)] = variable;\n } else {\n utils.report({\n node: decl,\n message: messages.variableExpected(variable, rawValue),\n word: value,\n ruleName,\n result,\n });\n }\n reported = true;\n }\n }\n\n if (context.fix) {\n decl.value = values.join(' ');\n }\n\n return !reported;\n }\n\n const linters = {\n colors: () =>\n lint(colors, {\n transformer: value => {\n try {\n return new Color(value).hex();\n } catch {\n return '';\n }\n },\n }),\n\n typescales: () =>\n lint(typescales, {\n condition: property => property === 'font-size',\n solid: true,\n }),\n\n borderRadiuses: () =>\n lint(borderRadiuses, {\n condition: property =>\n property.startsWith('border-') && property.endsWith('-radius'),\n transformer: value => (value === '0px' ? '0' : value),\n }),\n\n lintSpacings: () =>\n lint(spacings, {\n // other spacings like \"top\"?\n condition: property =>\n property.startsWith('margin') || property.startsWith('padding'),\n transformer: value =>\n value === '0px' ? '0' : value.startsWith('-') ? value.slice(1) : value,\n }),\n\n fontWeights: () =>\n lint(fontWeights, {\n condition: property => property === 'font-weight',\n solid: true,\n }),\n\n opacities: () =>\n lint(opacities, {\n condition: property => property === 'opacity',\n transformer: value => (value.startsWith('0.') ? value.slice(1) : value),\n solid: true,\n }),\n\n zIndexes: () =>\n lint(zIndexes, { condition: property => property === 'z-index', solid: true }),\n\n lineHeights: () =>\n lint(lineHeights, {\n condition: property => property === 'line-height',\n solid: true,\n }),\n\n fontFamilies: () =>\n lint(fontFamilies, {\n condition: property => property === 'font-family',\n solid: true,\n }),\n };\n\n for (const handler of Object.values(linters)) {\n if (!handler()) {\n return;\n }\n }\n });\n };\n};\n\nplugin.ruleName = ruleName;\nplugin.messages = messages;\n\nexport = Object.assign(createPlugin(ruleName, plugin), { ruleName, messages });\n"],"names":["ruleName","messages","utils","ruleMessages","variableExpected","expected","found","plugin","_0","_1","context","root","result","extension","opts","from","split","pop","toLowerCase","convertToVariable","key","walkDecls","decl","lint","collection","condition","transformer","solid","prop","values","value","reported","rawValue","variable","startsWith","fix","indexOf","report","node","message","word","join","linters","colors","Color","hex","typescales","property","borderRadiuses","endsWith","lintSpacings","spacings","slice","fontWeights","op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AAa,IACT9B,KAAK8B,mBAAW,EAAE;wBACd5B,WAAWsB,CAAAA,WAAYA,aAAa;wBACpCpB,OAAO;oBACX;gBAEJ2B,WAAW,IACP/B,KAAK+B,iBAAS,EAAE;wBACZ7B,WAAWsB,CAAAA,WAAYA,aAAa;wBACpCrB,aAAaI,CAAAA,QAAUA,MAAMI,UAAU,CAAC,QAAQJ,MAAMsB,KAAK,CAAC,KAAKtB;wBACjEH,OAAO;oBACX;gBAEJ4B,UAAU,IACNhC,KAAKgC,gBAAQ,EAAE;wBAAE9B,WAAWsB,CAAAA,WAAYA,aAAa;wBAAWpB,OAAO;oBAAK;gBAEhF6B,aAAa,IACTjC,KAAKiC,mBAAW,EAAE;wBACd/B,WAAWsB,CAAAA,WAAYA,aAAa;wBACpCpB,OAAO;oBACX;gBAEJ8B,cAAc,IACVlC,KAAKkC,oBAAY,EAAE;wBACfhC,WAAWsB,CAAAA,WAAYA,aAAa;wBACpCpB,OAAO;oBACX;YACR;YAEA,KAAK,MAAM+B,WAAWC,OAAO9B,MAAM,CAACa,SAAU;gBAC1C,IAAI,CAACgB,WAAW;oBACZ;gBACJ;YACJ;QACJ;IACJ;AACJ;AAEAnD,OAAOP,QAAQ,GAAGA;AAClBO,OAAON,QAAQ,GAAGA;iBAET0D,OAAOC,MAAM,CAACC,IAAAA,uBAAY,EAAC7D,UAAUO,SAAS;IAAEP;IAAUC;AAAS"}
|
|
@@ -1,37 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get borderRadiuses () {
|
|
13
|
+
return borderRadiuses;
|
|
14
|
+
},
|
|
15
|
+
get colors () {
|
|
16
|
+
return colors;
|
|
17
|
+
},
|
|
18
|
+
get fontFamilies () {
|
|
19
|
+
return fontFamilies;
|
|
20
|
+
},
|
|
21
|
+
get fontWeights () {
|
|
22
|
+
return fontWeights;
|
|
23
|
+
},
|
|
24
|
+
get lineHeights () {
|
|
25
|
+
return lineHeights;
|
|
26
|
+
},
|
|
27
|
+
get opacities () {
|
|
28
|
+
return opacities;
|
|
29
|
+
},
|
|
30
|
+
get spacings () {
|
|
31
|
+
return spacings;
|
|
32
|
+
},
|
|
33
|
+
get typescales () {
|
|
34
|
+
return typescales;
|
|
35
|
+
},
|
|
36
|
+
get zIndexes () {
|
|
37
|
+
return zIndexes;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
41
|
+
const _color = /*#__PURE__*/ _interop_require_default(require("color"));
|
|
42
|
+
const _core = require("@servicetitan/tokens/core");
|
|
43
|
+
function _interop_require_default(obj) {
|
|
44
|
+
return obj && obj.__esModule ? obj : {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const toCamelCase = (str)=>str.replace(/(-[a-z])/g, ([, letter])=>letter.toUpperCase());
|
|
49
|
+
const toSnakeCase = (str)=>str.replace(/([A-Z]|[a-z][0-9])/g, ([letter, digit])=>digit === undefined ? `-${letter.toLowerCase()}` : `${letter}-${digit}`);
|
|
50
|
+
const aliases = _fs.default.readFileSync(require.resolve('@servicetitan/tokens/core/tokens.less'), 'utf8').split('\n').filter((row)=>row.startsWith('@') && row.endsWith('(alias)')).map((row)=>toCamelCase(row.split(':')[0].slice(1)));
|
|
17
51
|
function getValues(condition, transformer) {
|
|
18
|
-
return Object.entries(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _a;
|
|
22
|
-
return ({
|
|
52
|
+
return Object.entries(_core.tokens).filter(([variable])=>!aliases.includes(variable) && condition(variable)).reduce((result, [variable, value])=>{
|
|
53
|
+
var _transformer;
|
|
54
|
+
return {
|
|
23
55
|
...result,
|
|
24
|
-
[(
|
|
25
|
-
}
|
|
56
|
+
[(_transformer = transformer === null || transformer === void 0 ? void 0 : transformer(value)) !== null && _transformer !== void 0 ? _transformer : value]: toSnakeCase(variable)
|
|
57
|
+
};
|
|
26
58
|
}, {});
|
|
27
59
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
60
|
+
const colors = getValues((variable)=>variable.startsWith('color'), (value)=>new _color.default(value).hex());
|
|
61
|
+
const typescales = getValues((variable)=>variable.startsWith('typescale'));
|
|
62
|
+
const borderRadiuses = getValues((variable)=>variable.startsWith('borderRadius'));
|
|
63
|
+
const spacings = getValues((variable)=>variable.startsWith('spacing'));
|
|
64
|
+
const fontWeights = getValues((variable)=>variable.startsWith('fontWeight'));
|
|
65
|
+
const opacities = getValues((variable)=>variable.startsWith('opacity'));
|
|
66
|
+
const zIndexes = getValues((variable)=>variable.startsWith('zIndex'));
|
|
67
|
+
const lineHeights = getValues((variable)=>variable.endsWith('LineHeight'));
|
|
68
|
+
const fontFamilies = getValues((variable)=>variable.endsWith('FontFamily'), (value)=>value.replace(/'/g, "'"));
|
|
69
|
+
|
|
37
70
|
//# sourceMappingURL=values.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/use-tokens/values.ts"],"sourcesContent":["import fs from 'fs';\n\nimport Color from 'color';\n\nimport { tokens } from '@servicetitan/tokens/core';\n\nconst toCamelCase = (str: string) => str.replace(/(-[a-z])/g, ([, letter]) => letter.toUpperCase());\nconst toSnakeCase = (str: string) =>\n str.replace(/([A-Z]|[a-z][0-9])/g, ([letter, digit]) =>\n digit === undefined ? `-${letter.toLowerCase()}` : `${letter}-${digit}`\n );\n\nconst aliases = fs\n .readFileSync(require.resolve('@servicetitan/tokens/core/tokens.less'), 'utf8')\n .split('\\n')\n .filter(row => row.startsWith('@') && row.endsWith('(alias)'))\n .map(row => toCamelCase(row.split(':')[0].slice(1)));\n\nfunction getValues(\n condition: (variable: string) => boolean,\n transformer?: (value: string) => string\n) {\n return Object.entries(tokens)\n .filter(([variable]) => !aliases.includes(variable) && condition(variable))\n .reduce<Record<string, string>>(\n (result, [variable, value]) => ({\n ...result,\n [transformer?.(value) ?? value]: toSnakeCase(variable),\n }),\n {}\n );\n}\n\nexport const colors = getValues(\n variable => variable.startsWith('color'),\n value => new Color(value).hex()\n);\nexport const typescales = getValues(variable => variable.startsWith('typescale'));\nexport const borderRadiuses = getValues(variable => variable.startsWith('borderRadius'));\nexport const spacings = getValues(variable => variable.startsWith('spacing'));\nexport const fontWeights = getValues(variable => variable.startsWith('fontWeight'));\nexport const opacities = getValues(variable => variable.startsWith('opacity'));\nexport const zIndexes = getValues(variable => variable.startsWith('zIndex'));\nexport const lineHeights = getValues(variable => variable.endsWith('LineHeight'));\nexport const fontFamilies = getValues(\n variable => variable.endsWith('FontFamily'),\n value => value.replace(/'/g, \"'\")\n);\n"],"names":["borderRadiuses","colors","fontFamilies","fontWeights","lineHeights","opacities","spacings","typescales","zIndexes","toCamelCase","str","replace","letter","toUpperCase","toSnakeCase","digit","undefined","toLowerCase","aliases","fs","readFileSync","require","resolve","split","filter","row","startsWith","endsWith","map","slice","getValues","condition","transformer","Object","entries","tokens","variable","includes","reduce","result","value","Color","hex"],"mappings":";;;;;;;;;;;QAsCaA;eAAAA;;QALAC;eAAAA;;QAWAC;eAAAA;;QAJAC;eAAAA;;QAGAC;eAAAA;;QAFAC;eAAAA;;QAFAC;eAAAA;;QAFAC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AACjE,MAAMpB,WAAWwB,UAAUM,CAAAA,WAAYA,SAASV,UAAU,CAAC;AAC3D,MAAMvB,cAAc2B,UAAUM,CAAAA,WAAYA,SAASV,UAAU,CAAC;AAC9D,MAAMrB,YAAYyB,UAAUM,CAAAA,WAAYA,SAASV,UAAU,CAAC;AAC5D,MAAMlB,WAAWsB,UAAUM,CAAAA,WAAYA,SAASV,UAAU,CAAC;AAC3D,MAAMtB,cAAc0B,UAAUM,CAAAA,WAAYA,SAAST,QAAQ,CAAC;AAC5D,MAAMzB,eAAe4B,UACxBM,CAAAA,WAAYA,SAAST,QAAQ,CAAC,eAC9Ba,CAAAA,QAASA,MAAM7B,OAAO,CAAC,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/stylelint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/eslint-stylelint-configurations",
|
|
6
6
|
"repository": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@servicetitan/tokens": "~12.9.0",
|
|
27
27
|
"@types/color": "~3.0.3",
|
|
28
28
|
"@types/lodash": "~4.14.178",
|
|
29
|
-
"stylelint": "~16.
|
|
29
|
+
"stylelint": "~16.21.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@servicetitan/tokens": "^12.9.0",
|
|
33
|
-
"postcss": "^8.5.
|
|
34
|
-
"stylelint": "^16.
|
|
33
|
+
"postcss": "^8.5.6",
|
|
34
|
+
"stylelint": "^16.21.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"cli": {
|
|
40
40
|
"webpack": false
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c52e188a1217df74052774a2eea6a5126089e3d5"
|
|
43
43
|
}
|