@icebreakers/stylelint-config 1.1.5 → 1.2.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/README.md +49 -4
- package/dist/cli.cjs +13 -334
- package/dist/cli.js +13 -327
- package/dist/index.cjs +153 -118
- package/dist/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +151 -125
- package/package.json +9 -3
- package/dist/chunk-JCOMXB4R.js +0 -43
package/dist/cli.js
CHANGED
|
@@ -1,297 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__toESM,
|
|
4
|
-
init_esm_shims
|
|
5
|
-
} from "./chunk-JCOMXB4R.js";
|
|
6
|
-
|
|
7
|
-
// ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
|
|
8
|
-
var require_is_primitive = __commonJS({
|
|
9
|
-
"../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
|
|
10
|
-
"use strict";
|
|
11
|
-
init_esm_shims();
|
|
12
|
-
module.exports = function isPrimitive(val) {
|
|
13
|
-
if (typeof val === "object") {
|
|
14
|
-
return val === null;
|
|
15
|
-
}
|
|
16
|
-
return typeof val !== "function";
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
|
|
22
|
-
var require_isobject = __commonJS({
|
|
23
|
-
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
|
|
24
|
-
"use strict";
|
|
25
|
-
init_esm_shims();
|
|
26
|
-
module.exports = function isObject2(val) {
|
|
27
|
-
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
33
|
-
var require_is_plain_object = __commonJS({
|
|
34
|
-
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
|
|
35
|
-
"use strict";
|
|
36
|
-
init_esm_shims();
|
|
37
|
-
var isObject2 = require_isobject();
|
|
38
|
-
function isObjectObject(o) {
|
|
39
|
-
return isObject2(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
40
|
-
}
|
|
41
|
-
module.exports = function isPlainObject(o) {
|
|
42
|
-
var ctor, prot;
|
|
43
|
-
if (isObjectObject(o) === false) return false;
|
|
44
|
-
ctor = o.constructor;
|
|
45
|
-
if (typeof ctor !== "function") return false;
|
|
46
|
-
prot = ctor.prototype;
|
|
47
|
-
if (isObjectObject(prot) === false) return false;
|
|
48
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
|
|
57
|
-
var require_set_value = __commonJS({
|
|
58
|
-
"../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
|
|
59
|
-
"use strict";
|
|
60
|
-
init_esm_shims();
|
|
61
|
-
var { deleteProperty } = Reflect;
|
|
62
|
-
var isPrimitive = require_is_primitive();
|
|
63
|
-
var isPlainObject = require_is_plain_object();
|
|
64
|
-
var isObject2 = (value) => {
|
|
65
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
66
|
-
};
|
|
67
|
-
var isUnsafeKey = (key) => {
|
|
68
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
69
|
-
};
|
|
70
|
-
var validateKey = (key) => {
|
|
71
|
-
if (!isPrimitive(key)) {
|
|
72
|
-
throw new TypeError("Object keys must be strings or symbols");
|
|
73
|
-
}
|
|
74
|
-
if (isUnsafeKey(key)) {
|
|
75
|
-
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
var toStringKey = (input) => {
|
|
79
|
-
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
80
|
-
};
|
|
81
|
-
var createMemoKey = (input, options) => {
|
|
82
|
-
if (typeof input !== "string" || !options) return input;
|
|
83
|
-
let key = input + ";";
|
|
84
|
-
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
85
|
-
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
86
|
-
if (options.split !== void 0) key += `split=${options.split};`;
|
|
87
|
-
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
88
|
-
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
89
|
-
return key;
|
|
90
|
-
};
|
|
91
|
-
var memoize = (input, options, fn) => {
|
|
92
|
-
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
93
|
-
validateKey(key);
|
|
94
|
-
const value = setValue.cache.get(key) || fn();
|
|
95
|
-
setValue.cache.set(key, value);
|
|
96
|
-
return value;
|
|
97
|
-
};
|
|
98
|
-
var splitString = (input, options = {}) => {
|
|
99
|
-
const sep = options.separator || ".";
|
|
100
|
-
const preserve = sep === "/" ? false : options.preservePaths;
|
|
101
|
-
if (typeof input === "string" && preserve !== false && /\//.test(input)) {
|
|
102
|
-
return [input];
|
|
103
|
-
}
|
|
104
|
-
const parts = [];
|
|
105
|
-
let part = "";
|
|
106
|
-
const push = (part2) => {
|
|
107
|
-
let number;
|
|
108
|
-
if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
|
|
109
|
-
parts.push(number);
|
|
110
|
-
} else {
|
|
111
|
-
parts.push(part2);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
for (let i = 0; i < input.length; i++) {
|
|
115
|
-
const value = input[i];
|
|
116
|
-
if (value === "\\") {
|
|
117
|
-
part += input[++i];
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (value === sep) {
|
|
121
|
-
push(part);
|
|
122
|
-
part = "";
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
part += value;
|
|
126
|
-
}
|
|
127
|
-
if (part) {
|
|
128
|
-
push(part);
|
|
129
|
-
}
|
|
130
|
-
return parts;
|
|
131
|
-
};
|
|
132
|
-
var split2 = (input, options) => {
|
|
133
|
-
if (options && typeof options.split === "function") return options.split(input);
|
|
134
|
-
if (typeof input === "symbol") return [input];
|
|
135
|
-
if (Array.isArray(input)) return input;
|
|
136
|
-
return memoize(input, options, () => splitString(input, options));
|
|
137
|
-
};
|
|
138
|
-
var assignProp = (obj, prop, value, options) => {
|
|
139
|
-
validateKey(prop);
|
|
140
|
-
if (value === void 0) {
|
|
141
|
-
deleteProperty(obj, prop);
|
|
142
|
-
} else if (options && options.merge) {
|
|
143
|
-
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
144
|
-
if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
|
|
145
|
-
obj[prop] = merge(obj[prop], value);
|
|
146
|
-
} else {
|
|
147
|
-
obj[prop] = value;
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
obj[prop] = value;
|
|
151
|
-
}
|
|
152
|
-
return obj;
|
|
153
|
-
};
|
|
154
|
-
var setValue = (target, path, value, options) => {
|
|
155
|
-
if (!path || !isObject2(target)) return target;
|
|
156
|
-
const keys = split2(path, options);
|
|
157
|
-
let obj = target;
|
|
158
|
-
for (let i = 0; i < keys.length; i++) {
|
|
159
|
-
const key = keys[i];
|
|
160
|
-
const next = keys[i + 1];
|
|
161
|
-
validateKey(key);
|
|
162
|
-
if (next === void 0) {
|
|
163
|
-
assignProp(obj, key, value, options);
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
167
|
-
obj = obj[key] = [];
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (!isObject2(obj[key])) {
|
|
171
|
-
obj[key] = {};
|
|
172
|
-
}
|
|
173
|
-
obj = obj[key];
|
|
174
|
-
}
|
|
175
|
-
return target;
|
|
176
|
-
};
|
|
177
|
-
setValue.split = split2;
|
|
178
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
179
|
-
setValue.clear = () => {
|
|
180
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
181
|
-
};
|
|
182
|
-
module.exports = setValue;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
1
|
// src/cli.ts
|
|
187
|
-
init_esm_shims();
|
|
188
2
|
import fs from "fs";
|
|
189
3
|
import { resolve } from "path";
|
|
190
4
|
import process from "process";
|
|
191
5
|
import jsonc from "comment-json";
|
|
192
6
|
|
|
193
7
|
// src/shared.ts
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
init_esm_shims();
|
|
198
|
-
var __defProp = Object.defineProperty;
|
|
199
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
200
|
-
var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
|
|
201
|
-
var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
202
|
-
if (typeof options.join === "function") {
|
|
203
|
-
return options.join(segs);
|
|
204
|
-
}
|
|
205
|
-
return segs[0] + joinChar + segs[1];
|
|
206
|
-
}, "join");
|
|
207
|
-
var split = /* @__PURE__ */ __name((path, splitChar, options) => {
|
|
208
|
-
if (typeof options.split === "function") {
|
|
209
|
-
return options.split(path);
|
|
8
|
+
function asStringArray(value) {
|
|
9
|
+
if (!Array.isArray(value)) {
|
|
10
|
+
return [];
|
|
210
11
|
}
|
|
211
|
-
return
|
|
212
|
-
}
|
|
213
|
-
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
214
|
-
if (typeof options?.isValid === "function") {
|
|
215
|
-
return options.isValid(key, target);
|
|
216
|
-
}
|
|
217
|
-
return true;
|
|
218
|
-
}, "isValid");
|
|
219
|
-
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
220
|
-
return isObject(v) || typeof v === "function";
|
|
221
|
-
}, "isValidObject");
|
|
222
|
-
var getValue = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
223
|
-
if (!isObject(options)) {
|
|
224
|
-
options = { default: options };
|
|
225
|
-
}
|
|
226
|
-
if (!isValidObject(target)) {
|
|
227
|
-
return typeof options.default !== "undefined" ? options.default : target;
|
|
228
|
-
}
|
|
229
|
-
if (typeof path === "number") {
|
|
230
|
-
path = String(path);
|
|
231
|
-
}
|
|
232
|
-
const pathIsArray = Array.isArray(path);
|
|
233
|
-
const pathIsString = typeof path === "string";
|
|
234
|
-
const splitChar = options.separator || ".";
|
|
235
|
-
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
236
|
-
if (!pathIsString && !pathIsArray) {
|
|
237
|
-
return target;
|
|
238
|
-
}
|
|
239
|
-
if (target[path] !== void 0) {
|
|
240
|
-
return isValid(path, target, options) ? target[path] : options.default;
|
|
241
|
-
}
|
|
242
|
-
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
243
|
-
const len = segs.length;
|
|
244
|
-
let idx = 0;
|
|
245
|
-
do {
|
|
246
|
-
let prop = segs[idx];
|
|
247
|
-
if (typeof prop !== "string") {
|
|
248
|
-
prop = String(prop);
|
|
249
|
-
}
|
|
250
|
-
while (prop && prop.slice(-1) === "\\") {
|
|
251
|
-
prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
252
|
-
}
|
|
253
|
-
if (target[prop] !== void 0) {
|
|
254
|
-
if (!isValid(prop, target, options)) {
|
|
255
|
-
return options.default;
|
|
256
|
-
}
|
|
257
|
-
target = target[prop];
|
|
258
|
-
} else {
|
|
259
|
-
let hasProp = false;
|
|
260
|
-
let n = idx + 1;
|
|
261
|
-
while (n < len) {
|
|
262
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
263
|
-
if (hasProp = target[prop] !== void 0) {
|
|
264
|
-
if (!isValid(prop, target, options)) {
|
|
265
|
-
return options.default;
|
|
266
|
-
}
|
|
267
|
-
target = target[prop];
|
|
268
|
-
idx = n - 1;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (!hasProp) {
|
|
273
|
-
return options.default;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
} while (++idx < len && isValidObject(target));
|
|
277
|
-
if (idx === len) {
|
|
278
|
-
return target;
|
|
279
|
-
}
|
|
280
|
-
return options.default;
|
|
281
|
-
}, "getValue");
|
|
282
|
-
var index_default = getValue;
|
|
283
|
-
|
|
284
|
-
// src/shared.ts
|
|
285
|
-
var import_set_value = __toESM(require_set_value(), 1);
|
|
12
|
+
return value.filter((entry) => typeof entry === "string");
|
|
13
|
+
}
|
|
286
14
|
function setVscodeSettingsJson(json2 = {}) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
15
|
+
json2["css.validate"] = false;
|
|
16
|
+
json2["less.validate"] = false;
|
|
17
|
+
json2["scss.validate"] = false;
|
|
18
|
+
const existing = new Set(asStringArray(json2["stylelint.validate"]));
|
|
19
|
+
existing.add("vue");
|
|
20
|
+
existing.add("css");
|
|
21
|
+
existing.add("scss");
|
|
22
|
+
json2["stylelint.validate"] = Array.from(existing);
|
|
295
23
|
return json2;
|
|
296
24
|
}
|
|
297
25
|
|
|
@@ -312,45 +40,3 @@ if (isExisted) {
|
|
|
312
40
|
setVscodeSettingsJson(json);
|
|
313
41
|
fs.writeFileSync(vscodeSettingsFilename, jsonc.stringify(json, void 0, 2), "utf8");
|
|
314
42
|
console.info(`[@icebreakers/stylelint-config] ${isExisted ? "update" : "init"} '.vscode/settings.json' finished`);
|
|
315
|
-
/*! Bundled license information:
|
|
316
|
-
|
|
317
|
-
is-primitive/index.js:
|
|
318
|
-
(*!
|
|
319
|
-
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
|
320
|
-
*
|
|
321
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
322
|
-
* Released under the MIT License.
|
|
323
|
-
*)
|
|
324
|
-
|
|
325
|
-
isobject/index.js:
|
|
326
|
-
(*!
|
|
327
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
328
|
-
*
|
|
329
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
330
|
-
* Released under the MIT License.
|
|
331
|
-
*)
|
|
332
|
-
|
|
333
|
-
is-plain-object/index.js:
|
|
334
|
-
(*!
|
|
335
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
336
|
-
*
|
|
337
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
338
|
-
* Released under the MIT License.
|
|
339
|
-
*)
|
|
340
|
-
|
|
341
|
-
set-value/index.js:
|
|
342
|
-
(*!
|
|
343
|
-
* set-value <https://github.com/jonschlinkert/set-value>
|
|
344
|
-
*
|
|
345
|
-
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
346
|
-
* Released under the MIT License.
|
|
347
|
-
*)
|
|
348
|
-
|
|
349
|
-
get-value/dist/index.mjs:
|
|
350
|
-
(*!
|
|
351
|
-
* get-value <https://github.com/jonschlinkert/get-value>
|
|
352
|
-
*
|
|
353
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
354
|
-
* Released under the MIT License.
|
|
355
|
-
*)
|
|
356
|
-
*/
|
package/dist/index.cjs
CHANGED
|
@@ -20,81 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
createStylelintConfig: () => createIcebreakerStylelintConfig,
|
|
23
24
|
icebreaker: () => icebreaker
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_exports);
|
|
26
27
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const prototype = Object.getPrototypeOf(value);
|
|
33
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (Symbol.iterator in value) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
if (Symbol.toStringTag in value) {
|
|
40
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
45
|
-
if (!isPlainObject(defaults)) {
|
|
46
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
47
|
-
}
|
|
48
|
-
const object = Object.assign({}, defaults);
|
|
49
|
-
for (const key in baseObject) {
|
|
50
|
-
if (key === "__proto__" || key === "constructor") {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const value = baseObject[key];
|
|
54
|
-
if (value === null || value === void 0) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
61
|
-
object[key] = [...value, ...object[key]];
|
|
62
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
63
|
-
object[key] = _defu(
|
|
64
|
-
value,
|
|
65
|
-
object[key],
|
|
66
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
67
|
-
merger
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
object[key] = value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return object;
|
|
74
|
-
}
|
|
75
|
-
function createDefu(merger) {
|
|
76
|
-
return (...arguments_) => (
|
|
77
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
78
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
var defu = createDefu();
|
|
82
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
83
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
84
|
-
object[key] = currentValue(object[key]);
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
89
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
90
|
-
object[key] = currentValue(object[key]);
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// src/index.ts
|
|
96
|
-
var ignoreAtRules = [
|
|
97
|
-
// tailwindcss
|
|
28
|
+
// src/constants.ts
|
|
29
|
+
var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
30
|
+
var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
31
|
+
var PRESET_RECESS_ORDER = "stylelint-config-recess-order";
|
|
32
|
+
var DEFAULT_IGNORE_AT_RULES = [
|
|
98
33
|
"tailwind",
|
|
99
34
|
"theme",
|
|
100
35
|
"apply",
|
|
@@ -105,64 +40,164 @@ var ignoreAtRules = [
|
|
|
105
40
|
"reference",
|
|
106
41
|
"config",
|
|
107
42
|
"plugin",
|
|
108
|
-
// unocss
|
|
109
43
|
"unocss"
|
|
110
44
|
];
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
45
|
+
var DEFAULT_IGNORE_TYPES = [
|
|
46
|
+
"page"
|
|
47
|
+
];
|
|
48
|
+
var DEFAULT_IGNORE_UNITS = [
|
|
49
|
+
"rpx"
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// src/utils.ts
|
|
53
|
+
var IGNORE_DEFAULTS = {
|
|
54
|
+
atRules: DEFAULT_IGNORE_AT_RULES,
|
|
55
|
+
types: DEFAULT_IGNORE_TYPES,
|
|
56
|
+
units: DEFAULT_IGNORE_UNITS
|
|
57
|
+
};
|
|
58
|
+
var IGNORE_REPLACE_KEYS = {
|
|
59
|
+
atRules: "atRules",
|
|
60
|
+
types: "types",
|
|
61
|
+
units: "units"
|
|
62
|
+
};
|
|
63
|
+
var IGNORE_APPEND_KEYS = {
|
|
64
|
+
atRules: "addAtRules",
|
|
65
|
+
types: "addTypes",
|
|
66
|
+
units: "addUnits"
|
|
67
|
+
};
|
|
68
|
+
function toArray(value) {
|
|
69
|
+
if (value == null) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return Array.isArray(value) ? value : [value];
|
|
73
|
+
}
|
|
74
|
+
function unique(values) {
|
|
75
|
+
const result = [];
|
|
76
|
+
const seen = /* @__PURE__ */ new Set();
|
|
77
|
+
for (const value of values) {
|
|
78
|
+
if (seen.has(value)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
seen.add(value);
|
|
82
|
+
result.push(value);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function resolveIgnoreList(kind, options) {
|
|
87
|
+
const replaceKey = IGNORE_REPLACE_KEYS[kind];
|
|
88
|
+
const appendKey = IGNORE_APPEND_KEYS[kind];
|
|
89
|
+
const base = options?.[replaceKey];
|
|
90
|
+
const extras = options?.[appendKey];
|
|
91
|
+
const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
|
|
92
|
+
if (!extras || extras.length === 0) {
|
|
93
|
+
return unique(initial);
|
|
94
|
+
}
|
|
95
|
+
return unique([...initial, ...extras]);
|
|
96
|
+
}
|
|
97
|
+
function normalizeExtends(base) {
|
|
98
|
+
if (!base || Array.isArray(base) && base.length === 0) {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(base)) {
|
|
102
|
+
return base.length === 1 ? base[0] : base;
|
|
103
|
+
}
|
|
104
|
+
return base;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/config.ts
|
|
108
|
+
function resolvePresetExtends(presets) {
|
|
109
|
+
const entries = [];
|
|
110
|
+
if (presets?.scss !== false) {
|
|
111
|
+
entries.push(PRESET_STANDARD_SCSS);
|
|
112
|
+
}
|
|
113
|
+
if (presets?.vue !== false) {
|
|
114
|
+
entries.push(PRESET_VUE_SCSS);
|
|
115
|
+
}
|
|
116
|
+
if (presets?.order !== false) {
|
|
117
|
+
entries.push(PRESET_RECESS_ORDER);
|
|
118
|
+
}
|
|
119
|
+
return entries;
|
|
120
|
+
}
|
|
121
|
+
function resolveExtends(options) {
|
|
122
|
+
const presets = resolvePresetExtends(options?.presets);
|
|
123
|
+
const extras = toArray(options?.extends);
|
|
124
|
+
const values = unique([...presets, ...extras]);
|
|
125
|
+
return normalizeExtends(values);
|
|
126
|
+
}
|
|
127
|
+
function resolveOverrides(options) {
|
|
128
|
+
const overrides = options?.overrides;
|
|
129
|
+
if (!overrides || overrides.length === 0) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
return [...overrides];
|
|
133
|
+
}
|
|
134
|
+
function resolveRules(options) {
|
|
135
|
+
const ignoreUnits = resolveIgnoreList("units", options?.ignores);
|
|
136
|
+
const ignoreTypes = resolveIgnoreList("types", options?.ignores);
|
|
137
|
+
const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
|
|
138
|
+
const rules = {
|
|
139
|
+
"unit-no-unknown": [
|
|
140
|
+
true,
|
|
141
|
+
{
|
|
142
|
+
ignoreUnits
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"selector-type-no-unknown": [
|
|
146
|
+
true,
|
|
147
|
+
{
|
|
148
|
+
ignoreTypes
|
|
149
|
+
}
|
|
121
150
|
],
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// 'unit-allowed-list': ['em', 'rem', 's'],
|
|
128
|
-
// },
|
|
129
|
-
// },
|
|
151
|
+
"at-rule-no-deprecated": [
|
|
152
|
+
true,
|
|
153
|
+
{
|
|
154
|
+
ignoreAtRules
|
|
155
|
+
}
|
|
130
156
|
],
|
|
157
|
+
"scss/selector-no-redundant-nesting-selector": true,
|
|
158
|
+
"scss/at-rule-no-unknown": [
|
|
159
|
+
true,
|
|
160
|
+
{
|
|
161
|
+
ignoreAtRules
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
};
|
|
165
|
+
if (options?.rules) {
|
|
166
|
+
return {
|
|
167
|
+
...rules,
|
|
168
|
+
...options.rules
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return rules;
|
|
172
|
+
}
|
|
173
|
+
function createIcebreakerStylelintConfig(options = {}) {
|
|
174
|
+
return {
|
|
175
|
+
extends: resolveExtends(options),
|
|
176
|
+
overrides: resolveOverrides(options),
|
|
177
|
+
rules: resolveRules(options)
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/index.ts
|
|
182
|
+
function mergeConfigs(base, overrides) {
|
|
183
|
+
if (!overrides) {
|
|
184
|
+
return base;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
...base,
|
|
188
|
+
...overrides,
|
|
131
189
|
rules: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
true,
|
|
135
|
-
{
|
|
136
|
-
ignoreUnits: ["rpx"]
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
// https://stylelint.io/user-guide/rules/selector-type-no-unknown/
|
|
140
|
-
"selector-type-no-unknown": [
|
|
141
|
-
true,
|
|
142
|
-
{
|
|
143
|
-
ignoreTypes: ["page"]
|
|
144
|
-
}
|
|
145
|
-
],
|
|
146
|
-
"at-rule-no-deprecated": [
|
|
147
|
-
true,
|
|
148
|
-
{
|
|
149
|
-
ignoreAtRules
|
|
150
|
-
}
|
|
151
|
-
],
|
|
152
|
-
"scss/selector-no-redundant-nesting-selector": true,
|
|
153
|
-
"scss/at-rule-no-unknown": [
|
|
154
|
-
true,
|
|
155
|
-
{
|
|
156
|
-
ignoreAtRules
|
|
157
|
-
}
|
|
158
|
-
]
|
|
190
|
+
...base.rules ?? {},
|
|
191
|
+
...overrides.rules ?? {}
|
|
159
192
|
}
|
|
160
193
|
};
|
|
161
194
|
}
|
|
162
195
|
function icebreaker(config) {
|
|
163
|
-
|
|
196
|
+
const base = createIcebreakerStylelintConfig();
|
|
197
|
+
return mergeConfigs(base, config);
|
|
164
198
|
}
|
|
165
199
|
// Annotate the CommonJS export names for ESM import in node:
|
|
166
200
|
0 && (module.exports = {
|
|
201
|
+
createStylelintConfig,
|
|
167
202
|
icebreaker
|
|
168
203
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
import { Config } from 'stylelint';
|
|
2
2
|
|
|
3
|
+
interface PresetToggles {
|
|
4
|
+
/** Include rules for SCSS syntax. Enabled by default. */
|
|
5
|
+
scss?: boolean;
|
|
6
|
+
/** Include Vue-specific recommendations. Enabled by default. */
|
|
7
|
+
vue?: boolean;
|
|
8
|
+
/** Enforce property ordering via recess-order. Enabled by default. */
|
|
9
|
+
order?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface IgnoreListOptions {
|
|
12
|
+
/** Replace the default ignore-at-rules list. */
|
|
13
|
+
atRules?: string[];
|
|
14
|
+
/** Replace the default ignore selector types list. */
|
|
15
|
+
types?: string[];
|
|
16
|
+
/** Replace the default ignore units list. */
|
|
17
|
+
units?: string[];
|
|
18
|
+
/** Additional at-rules to ignore. */
|
|
19
|
+
addAtRules?: string[];
|
|
20
|
+
/** Additional selector types to ignore. */
|
|
21
|
+
addTypes?: string[];
|
|
22
|
+
/** Additional units to ignore. */
|
|
23
|
+
addUnits?: string[];
|
|
24
|
+
}
|
|
25
|
+
interface IcebreakerStylelintOptions {
|
|
26
|
+
/** Toggle built-in preset bundles. */
|
|
27
|
+
presets?: PresetToggles;
|
|
28
|
+
/** Append extra extends entries. */
|
|
29
|
+
extends?: Config['extends'];
|
|
30
|
+
/** Append override entries. */
|
|
31
|
+
overrides?: Config['overrides'];
|
|
32
|
+
/** Provide additional or replacement rule ignore lists. */
|
|
33
|
+
ignores?: IgnoreListOptions;
|
|
34
|
+
/** Override or add rules. */
|
|
35
|
+
rules?: Config['rules'];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare function createIcebreakerStylelintConfig(options?: IcebreakerStylelintOptions): Config;
|
|
39
|
+
|
|
3
40
|
declare function icebreaker(config?: Config): Config;
|
|
4
41
|
|
|
5
|
-
export { icebreaker };
|
|
42
|
+
export { type IcebreakerStylelintOptions, type IgnoreListOptions, type PresetToggles, createIcebreakerStylelintConfig as createStylelintConfig, icebreaker };
|