@icebreakers/stylelint-config 1.1.6 → 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 CHANGED
@@ -1,19 +1,64 @@
1
1
  # @icebreakers/stylelint-config
2
2
 
3
- Run `npx @icebreakers/stylelint-config` for init `.vscode/settings.json`
3
+ Reusable stylelint configuration with sensible defaults for Vue + SCSS projects and an opt-in API for tailoring the rule set.
4
4
 
5
- ## init
5
+ ## CLI helper
6
+
7
+ Bootstrap VS Code settings so diagnostics come from stylelint instead of the built-in CSS linters:
6
8
 
7
9
  ```sh
8
10
  npx @icebreakers/stylelint-config
9
11
  ```
10
12
 
11
- ## config
13
+ The command creates (or updates) `.vscode/settings.json` with the required `stylelint.validate` entries.
12
14
 
13
- create a `stylelint.config.[cm]js`:
15
+ ## Basic usage
14
16
 
15
17
  ```ts
18
+ // stylelint.config.ts
16
19
  import { icebreaker } from '@icebreakers/stylelint-config'
17
20
 
18
21
  export default icebreaker()
19
22
  ```
23
+
24
+ `icebreaker()` reflects the legacy behaviour: it returns the default preset and merges any partial stylelint config you pass in.
25
+
26
+ ## Advanced configuration
27
+
28
+ For granular control, use `createStylelintConfig` which exposes preset toggles and ignore list helpers:
29
+
30
+ ```ts
31
+ import { createStylelintConfig } from '@icebreakers/stylelint-config'
32
+
33
+ export default createStylelintConfig({
34
+ presets: {
35
+ vue: false, // drop vue-specific rules if you lint pure SCSS
36
+ },
37
+ ignores: {
38
+ units: [], // replace the default ignore list
39
+ addUnits: ['upx'],
40
+ },
41
+ extends: [
42
+ '@acme/stylelint-config-custom',
43
+ ],
44
+ rules: {
45
+ 'color-hex-length': 'long',
46
+ },
47
+ })
48
+ ```
49
+
50
+ Available options:
51
+
52
+ - `presets.scss` – include `stylelint-config-standard-scss` (default `true`)
53
+ - `presets.vue` – include `stylelint-config-recommended-vue/scss` (default `true`)
54
+ - `presets.order` – include `stylelint-config-recess-order` (default `true`)
55
+ - `ignores.atRules`, `ignores.types`, `ignores.units` – replace the defaults
56
+ - `ignores.addAtRules`, `ignores.addTypes`, `ignores.addUnits` – append extra entries
57
+ - `extends` – append custom configs after the presets
58
+ - `overrides` / `rules` – carried straight into the resulting Stylelint config
59
+
60
+ Both helpers share the same defaults:
61
+
62
+ - Allow the `rpx` unit to ease mini-program support
63
+ - Ignore custom at-rules used by Tailwind CSS and UnoCSS
64
+ - Ignore the `page` selector for platform-specific stylesheets
package/dist/cli.cjs CHANGED
@@ -5,12 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
8
  var __copyProps = (to, from, except, desc) => {
15
9
  if (from && typeof from === "object" || typeof from === "function") {
16
10
  for (let key of __getOwnPropNames(from))
@@ -28,301 +22,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
22
  mod
29
23
  ));
30
24
 
31
- // ../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
32
- var init_cjs_shims = __esm({
33
- "../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js"() {
34
- "use strict";
35
- }
36
- });
37
-
38
- // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
39
- var require_is_primitive = __commonJS({
40
- "../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports2, module2) {
41
- "use strict";
42
- init_cjs_shims();
43
- module2.exports = function isPrimitive(val) {
44
- if (typeof val === "object") {
45
- return val === null;
46
- }
47
- return typeof val !== "function";
48
- };
49
- }
50
- });
51
-
52
- // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
53
- var require_isobject = __commonJS({
54
- "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports2, module2) {
55
- "use strict";
56
- init_cjs_shims();
57
- module2.exports = function isObject2(val) {
58
- return val != null && typeof val === "object" && Array.isArray(val) === false;
59
- };
60
- }
61
- });
62
-
63
- // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
64
- var require_is_plain_object = __commonJS({
65
- "../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports2, module2) {
66
- "use strict";
67
- init_cjs_shims();
68
- var isObject2 = require_isobject();
69
- function isObjectObject(o) {
70
- return isObject2(o) === true && Object.prototype.toString.call(o) === "[object Object]";
71
- }
72
- module2.exports = function isPlainObject(o) {
73
- var ctor, prot;
74
- if (isObjectObject(o) === false) return false;
75
- ctor = o.constructor;
76
- if (typeof ctor !== "function") return false;
77
- prot = ctor.prototype;
78
- if (isObjectObject(prot) === false) return false;
79
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
80
- return false;
81
- }
82
- return true;
83
- };
84
- }
85
- });
86
-
87
- // ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
88
- var require_set_value = __commonJS({
89
- "../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports2, module2) {
90
- "use strict";
91
- init_cjs_shims();
92
- var { deleteProperty } = Reflect;
93
- var isPrimitive = require_is_primitive();
94
- var isPlainObject = require_is_plain_object();
95
- var isObject2 = (value) => {
96
- return typeof value === "object" && value !== null || typeof value === "function";
97
- };
98
- var isUnsafeKey = (key) => {
99
- return key === "__proto__" || key === "constructor" || key === "prototype";
100
- };
101
- var validateKey = (key) => {
102
- if (!isPrimitive(key)) {
103
- throw new TypeError("Object keys must be strings or symbols");
104
- }
105
- if (isUnsafeKey(key)) {
106
- throw new Error(`Cannot set unsafe key: "${key}"`);
107
- }
108
- };
109
- var toStringKey = (input) => {
110
- return Array.isArray(input) ? input.flat().map(String).join(",") : input;
111
- };
112
- var createMemoKey = (input, options) => {
113
- if (typeof input !== "string" || !options) return input;
114
- let key = input + ";";
115
- if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
116
- if (options.separator !== void 0) key += `separator=${options.separator};`;
117
- if (options.split !== void 0) key += `split=${options.split};`;
118
- if (options.merge !== void 0) key += `merge=${options.merge};`;
119
- if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
120
- return key;
121
- };
122
- var memoize = (input, options, fn) => {
123
- const key = toStringKey(options ? createMemoKey(input, options) : input);
124
- validateKey(key);
125
- const value = setValue.cache.get(key) || fn();
126
- setValue.cache.set(key, value);
127
- return value;
128
- };
129
- var splitString = (input, options = {}) => {
130
- const sep = options.separator || ".";
131
- const preserve = sep === "/" ? false : options.preservePaths;
132
- if (typeof input === "string" && preserve !== false && /\//.test(input)) {
133
- return [input];
134
- }
135
- const parts = [];
136
- let part = "";
137
- const push = (part2) => {
138
- let number;
139
- if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
140
- parts.push(number);
141
- } else {
142
- parts.push(part2);
143
- }
144
- };
145
- for (let i = 0; i < input.length; i++) {
146
- const value = input[i];
147
- if (value === "\\") {
148
- part += input[++i];
149
- continue;
150
- }
151
- if (value === sep) {
152
- push(part);
153
- part = "";
154
- continue;
155
- }
156
- part += value;
157
- }
158
- if (part) {
159
- push(part);
160
- }
161
- return parts;
162
- };
163
- var split2 = (input, options) => {
164
- if (options && typeof options.split === "function") return options.split(input);
165
- if (typeof input === "symbol") return [input];
166
- if (Array.isArray(input)) return input;
167
- return memoize(input, options, () => splitString(input, options));
168
- };
169
- var assignProp = (obj, prop, value, options) => {
170
- validateKey(prop);
171
- if (value === void 0) {
172
- deleteProperty(obj, prop);
173
- } else if (options && options.merge) {
174
- const merge = options.merge === "function" ? options.merge : Object.assign;
175
- if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
176
- obj[prop] = merge(obj[prop], value);
177
- } else {
178
- obj[prop] = value;
179
- }
180
- } else {
181
- obj[prop] = value;
182
- }
183
- return obj;
184
- };
185
- var setValue = (target, path, value, options) => {
186
- if (!path || !isObject2(target)) return target;
187
- const keys = split2(path, options);
188
- let obj = target;
189
- for (let i = 0; i < keys.length; i++) {
190
- const key = keys[i];
191
- const next = keys[i + 1];
192
- validateKey(key);
193
- if (next === void 0) {
194
- assignProp(obj, key, value, options);
195
- break;
196
- }
197
- if (typeof next === "number" && !Array.isArray(obj[key])) {
198
- obj = obj[key] = [];
199
- continue;
200
- }
201
- if (!isObject2(obj[key])) {
202
- obj[key] = {};
203
- }
204
- obj = obj[key];
205
- }
206
- return target;
207
- };
208
- setValue.split = split2;
209
- setValue.cache = /* @__PURE__ */ new Map();
210
- setValue.clear = () => {
211
- setValue.cache = /* @__PURE__ */ new Map();
212
- };
213
- module2.exports = setValue;
214
- }
215
- });
216
-
217
25
  // src/cli.ts
218
- init_cjs_shims();
219
26
  var import_node_fs = __toESM(require("fs"), 1);
220
27
  var import_node_path = require("path");
221
28
  var import_node_process = __toESM(require("process"), 1);
222
29
  var import_comment_json = __toESM(require("comment-json"), 1);
223
30
 
224
31
  // src/shared.ts
225
- init_cjs_shims();
226
-
227
- // ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
228
- init_cjs_shims();
229
- var __defProp2 = Object.defineProperty;
230
- var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
231
- var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
232
- var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
233
- if (typeof options.join === "function") {
234
- return options.join(segs);
235
- }
236
- return segs[0] + joinChar + segs[1];
237
- }, "join");
238
- var split = /* @__PURE__ */ __name((path, splitChar, options) => {
239
- if (typeof options.split === "function") {
240
- return options.split(path);
241
- }
242
- return path.split(splitChar);
243
- }, "split");
244
- var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
245
- if (typeof options?.isValid === "function") {
246
- return options.isValid(key, target);
247
- }
248
- return true;
249
- }, "isValid");
250
- var isValidObject = /* @__PURE__ */ __name((v) => {
251
- return isObject(v) || typeof v === "function";
252
- }, "isValidObject");
253
- var getValue = /* @__PURE__ */ __name((target, path, options = {}) => {
254
- if (!isObject(options)) {
255
- options = { default: options };
256
- }
257
- if (!isValidObject(target)) {
258
- return typeof options.default !== "undefined" ? options.default : target;
259
- }
260
- if (typeof path === "number") {
261
- path = String(path);
262
- }
263
- const pathIsArray = Array.isArray(path);
264
- const pathIsString = typeof path === "string";
265
- const splitChar = options.separator || ".";
266
- const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
267
- if (!pathIsString && !pathIsArray) {
268
- return target;
269
- }
270
- if (target[path] !== void 0) {
271
- return isValid(path, target, options) ? target[path] : options.default;
272
- }
273
- const segs = pathIsArray ? path : split(path, splitChar, options);
274
- const len = segs.length;
275
- let idx = 0;
276
- do {
277
- let prop = segs[idx];
278
- if (typeof prop !== "string") {
279
- prop = String(prop);
280
- }
281
- while (prop && prop.slice(-1) === "\\") {
282
- prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
283
- }
284
- if (target[prop] !== void 0) {
285
- if (!isValid(prop, target, options)) {
286
- return options.default;
287
- }
288
- target = target[prop];
289
- } else {
290
- let hasProp = false;
291
- let n = idx + 1;
292
- while (n < len) {
293
- prop = join([prop, segs[n++]], joinChar, options);
294
- if (hasProp = target[prop] !== void 0) {
295
- if (!isValid(prop, target, options)) {
296
- return options.default;
297
- }
298
- target = target[prop];
299
- idx = n - 1;
300
- break;
301
- }
302
- }
303
- if (!hasProp) {
304
- return options.default;
305
- }
306
- }
307
- } while (++idx < len && isValidObject(target));
308
- if (idx === len) {
309
- return target;
32
+ function asStringArray(value) {
33
+ if (!Array.isArray(value)) {
34
+ return [];
310
35
  }
311
- return options.default;
312
- }, "getValue");
313
- var index_default = getValue;
314
-
315
- // src/shared.ts
316
- var import_set_value = __toESM(require_set_value(), 1);
36
+ return value.filter((entry) => typeof entry === "string");
37
+ }
317
38
  function setVscodeSettingsJson(json2 = {}) {
318
- (0, import_set_value.default)(json2, "css\\.validate", false);
319
- (0, import_set_value.default)(json2, "less\\.validate", false);
320
- (0, import_set_value.default)(json2, "scss\\.validate", false);
321
- const stylelintValidates = new Set(index_default(json2, "stylelint\\.validate", { default: [] }));
322
- stylelintValidates.add("vue");
323
- stylelintValidates.add("css");
324
- stylelintValidates.add("scss");
325
- (0, import_set_value.default)(json2, "stylelint\\.validate", Array.from(stylelintValidates));
39
+ json2["css.validate"] = false;
40
+ json2["less.validate"] = false;
41
+ json2["scss.validate"] = false;
42
+ const existing = new Set(asStringArray(json2["stylelint.validate"]));
43
+ existing.add("vue");
44
+ existing.add("css");
45
+ existing.add("scss");
46
+ json2["stylelint.validate"] = Array.from(existing);
326
47
  return json2;
327
48
  }
328
49
 
@@ -343,45 +64,3 @@ if (isExisted) {
343
64
  setVscodeSettingsJson(json);
344
65
  import_node_fs.default.writeFileSync(vscodeSettingsFilename, import_comment_json.default.stringify(json, void 0, 2), "utf8");
345
66
  console.info(`[@icebreakers/stylelint-config] ${isExisted ? "update" : "init"} '.vscode/settings.json' finished`);
346
- /*! Bundled license information:
347
-
348
- is-primitive/index.js:
349
- (*!
350
- * is-primitive <https://github.com/jonschlinkert/is-primitive>
351
- *
352
- * Copyright (c) 2014-present, Jon Schlinkert.
353
- * Released under the MIT License.
354
- *)
355
-
356
- isobject/index.js:
357
- (*!
358
- * isobject <https://github.com/jonschlinkert/isobject>
359
- *
360
- * Copyright (c) 2014-2017, Jon Schlinkert.
361
- * Released under the MIT License.
362
- *)
363
-
364
- is-plain-object/index.js:
365
- (*!
366
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
367
- *
368
- * Copyright (c) 2014-2017, Jon Schlinkert.
369
- * Released under the MIT License.
370
- *)
371
-
372
- set-value/index.js:
373
- (*!
374
- * set-value <https://github.com/jonschlinkert/set-value>
375
- *
376
- * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
377
- * Released under the MIT License.
378
- *)
379
-
380
- get-value/dist/index.mjs:
381
- (*!
382
- * get-value <https://github.com/jonschlinkert/get-value>
383
- *
384
- * Copyright (c) 2014-present, Jon Schlinkert.
385
- * Released under the MIT License.
386
- *)
387
- */