@icebreakers/stylelint-config 1.1.6 → 1.2.1

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/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 };
package/dist/index.d.ts 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 };
package/dist/index.js CHANGED
@@ -1,149 +1,182 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-PRTO2AHU.js";
1
+ // src/config.ts
2
+ import { createRequire } from "module";
4
3
 
5
- // src/index.ts
6
- init_esm_shims();
4
+ // src/constants.ts
5
+ var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
6
+ var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
7
+ var PRESET_RECESS_ORDER = "stylelint-config-recess-order";
8
+ var DEFAULT_IGNORE_AT_RULES = [
9
+ "tailwind",
10
+ "theme",
11
+ "apply",
12
+ "source",
13
+ "utility",
14
+ "variant",
15
+ "custom-variant",
16
+ "reference",
17
+ "config",
18
+ "plugin",
19
+ "unocss"
20
+ ];
21
+ var DEFAULT_IGNORE_TYPES = [
22
+ "page"
23
+ ];
24
+ var DEFAULT_IGNORE_UNITS = [
25
+ "rpx"
26
+ ];
7
27
 
8
- // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
9
- init_esm_shims();
10
- function isPlainObject(value) {
11
- if (value === null || typeof value !== "object") {
12
- return false;
28
+ // src/utils.ts
29
+ var IGNORE_DEFAULTS = {
30
+ atRules: DEFAULT_IGNORE_AT_RULES,
31
+ types: DEFAULT_IGNORE_TYPES,
32
+ units: DEFAULT_IGNORE_UNITS
33
+ };
34
+ var IGNORE_REPLACE_KEYS = {
35
+ atRules: "atRules",
36
+ types: "types",
37
+ units: "units"
38
+ };
39
+ var IGNORE_APPEND_KEYS = {
40
+ atRules: "addAtRules",
41
+ types: "addTypes",
42
+ units: "addUnits"
43
+ };
44
+ function toArray(value) {
45
+ if (value == null) {
46
+ return [];
47
+ }
48
+ return Array.isArray(value) ? value : [value];
49
+ }
50
+ function unique(values) {
51
+ const result = [];
52
+ const seen = /* @__PURE__ */ new Set();
53
+ for (const value of values) {
54
+ if (seen.has(value)) {
55
+ continue;
56
+ }
57
+ seen.add(value);
58
+ result.push(value);
13
59
  }
14
- const prototype = Object.getPrototypeOf(value);
15
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
16
- return false;
60
+ return result;
61
+ }
62
+ function resolveIgnoreList(kind, options) {
63
+ const replaceKey = IGNORE_REPLACE_KEYS[kind];
64
+ const appendKey = IGNORE_APPEND_KEYS[kind];
65
+ const base = options?.[replaceKey];
66
+ const extras = options?.[appendKey];
67
+ const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
68
+ if (!extras || extras.length === 0) {
69
+ return unique(initial);
17
70
  }
18
- if (Symbol.iterator in value) {
19
- return false;
71
+ return unique([...initial, ...extras]);
72
+ }
73
+ function normalizeExtends(base) {
74
+ if (!base || Array.isArray(base) && base.length === 0) {
75
+ return void 0;
20
76
  }
21
- if (Symbol.toStringTag in value) {
22
- return Object.prototype.toString.call(value) === "[object Module]";
77
+ if (Array.isArray(base)) {
78
+ return base.length === 1 ? base[0] : base;
23
79
  }
24
- return true;
80
+ return base;
25
81
  }
26
- function _defu(baseObject, defaults, namespace = ".", merger) {
27
- if (!isPlainObject(defaults)) {
28
- return _defu(baseObject, {}, namespace, merger);
82
+
83
+ // src/config.ts
84
+ var requireFromConfig = createRequire(import.meta.url);
85
+ var PRESET_PATH_STANDARD_SCSS = requireFromConfig.resolve(PRESET_STANDARD_SCSS);
86
+ var PRESET_PATH_VUE_SCSS = requireFromConfig.resolve(PRESET_VUE_SCSS);
87
+ var PRESET_PATH_RECESS_ORDER = requireFromConfig.resolve(PRESET_RECESS_ORDER);
88
+ function resolvePresetExtends(presets) {
89
+ const entries = [];
90
+ if (presets?.scss !== false) {
91
+ entries.push(PRESET_PATH_STANDARD_SCSS);
29
92
  }
30
- const object = Object.assign({}, defaults);
31
- for (const key in baseObject) {
32
- if (key === "__proto__" || key === "constructor") {
33
- continue;
34
- }
35
- const value = baseObject[key];
36
- if (value === null || value === void 0) {
37
- continue;
38
- }
39
- if (merger && merger(object, key, value, namespace)) {
40
- continue;
41
- }
42
- if (Array.isArray(value) && Array.isArray(object[key])) {
43
- object[key] = [...value, ...object[key]];
44
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
45
- object[key] = _defu(
46
- value,
47
- object[key],
48
- (namespace ? `${namespace}.` : "") + key.toString(),
49
- merger
50
- );
51
- } else {
52
- object[key] = value;
53
- }
93
+ if (presets?.vue !== false) {
94
+ entries.push(PRESET_PATH_VUE_SCSS);
95
+ }
96
+ if (presets?.order !== false) {
97
+ entries.push(PRESET_PATH_RECESS_ORDER);
54
98
  }
55
- return object;
99
+ return entries;
56
100
  }
57
- function createDefu(merger) {
58
- return (...arguments_) => (
59
- // eslint-disable-next-line unicorn/no-array-reduce
60
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
61
- );
101
+ function resolveExtends(options) {
102
+ const presets = resolvePresetExtends(options?.presets);
103
+ const extras = toArray(options?.extends);
104
+ const values = unique([...presets, ...extras]);
105
+ return normalizeExtends(values);
62
106
  }
63
- var defu = createDefu();
64
- var defuFn = createDefu((object, key, currentValue) => {
65
- if (object[key] !== void 0 && typeof currentValue === "function") {
66
- object[key] = currentValue(object[key]);
67
- return true;
107
+ function resolveOverrides(options) {
108
+ const overrides = options?.overrides;
109
+ if (!overrides || overrides.length === 0) {
110
+ return [];
68
111
  }
69
- });
70
- var defuArrayFn = createDefu((object, key, currentValue) => {
71
- if (Array.isArray(object[key]) && typeof currentValue === "function") {
72
- object[key] = currentValue(object[key]);
73
- return true;
112
+ return [...overrides];
113
+ }
114
+ function resolveRules(options) {
115
+ const ignoreUnits = resolveIgnoreList("units", options?.ignores);
116
+ const ignoreTypes = resolveIgnoreList("types", options?.ignores);
117
+ const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
118
+ const rules = {
119
+ "unit-no-unknown": [
120
+ true,
121
+ {
122
+ ignoreUnits
123
+ }
124
+ ],
125
+ "selector-type-no-unknown": [
126
+ true,
127
+ {
128
+ ignoreTypes
129
+ }
130
+ ],
131
+ "at-rule-no-deprecated": [
132
+ true,
133
+ {
134
+ ignoreAtRules
135
+ }
136
+ ],
137
+ "scss/selector-no-redundant-nesting-selector": true,
138
+ "scss/at-rule-no-unknown": [
139
+ true,
140
+ {
141
+ ignoreAtRules
142
+ }
143
+ ]
144
+ };
145
+ if (options?.rules) {
146
+ return {
147
+ ...rules,
148
+ ...options.rules
149
+ };
74
150
  }
75
- });
151
+ return rules;
152
+ }
153
+ function createIcebreakerStylelintConfig(options = {}) {
154
+ return {
155
+ extends: resolveExtends(options),
156
+ overrides: resolveOverrides(options),
157
+ rules: resolveRules(options)
158
+ };
159
+ }
76
160
 
77
161
  // src/index.ts
78
- var ignoreAtRules = [
79
- // tailwindcss
80
- "tailwind",
81
- "theme",
82
- "apply",
83
- "source",
84
- "utility",
85
- "variant",
86
- "custom-variant",
87
- "reference",
88
- "config",
89
- "plugin",
90
- // unocss
91
- "unocss"
92
- ];
93
- function createDefaultConfig() {
162
+ function mergeConfigs(base, overrides) {
163
+ if (!overrides) {
164
+ return base;
165
+ }
94
166
  return {
95
- extends: [
96
- // https://www.npmjs.com/package/stylelint-config-standard-scss
97
- // extends: ['stylelint-config-standard', 'stylelint-config-recommended-scss']
98
- "stylelint-config-standard-scss",
99
- // https://github.com/ota-meshi/stylelint-config-recommended-vue/blob/main/lib/index.js
100
- // https://github.com/ota-meshi/stylelint-config-recommended-vue/blob/main/scss/index.js
101
- "stylelint-config-recommended-vue/scss",
102
- "stylelint-config-recess-order"
103
- ],
104
- // .map(module => require.resolve(module)),
105
- overrides: [
106
- // {
107
- // files: ['*.vue', '**/*.vue'],
108
- // rules: {
109
- // 'unit-allowed-list': ['em', 'rem', 's'],
110
- // },
111
- // },
112
- ],
167
+ ...base,
168
+ ...overrides,
113
169
  rules: {
114
- // https://stylelint.io/user-guide/rules/unit-no-unknown/#ignoreunits-regex-regex-string
115
- "unit-no-unknown": [
116
- true,
117
- {
118
- ignoreUnits: ["rpx"]
119
- }
120
- ],
121
- // https://stylelint.io/user-guide/rules/selector-type-no-unknown/
122
- "selector-type-no-unknown": [
123
- true,
124
- {
125
- ignoreTypes: ["page"]
126
- }
127
- ],
128
- "at-rule-no-deprecated": [
129
- true,
130
- {
131
- ignoreAtRules
132
- }
133
- ],
134
- "scss/selector-no-redundant-nesting-selector": true,
135
- "scss/at-rule-no-unknown": [
136
- true,
137
- {
138
- ignoreAtRules
139
- }
140
- ]
170
+ ...base.rules ?? {},
171
+ ...overrides.rules ?? {}
141
172
  }
142
173
  };
143
174
  }
144
175
  function icebreaker(config) {
145
- return defu(config, createDefaultConfig());
176
+ const base = createIcebreakerStylelintConfig();
177
+ return mergeConfigs(base, config);
146
178
  }
147
179
  export {
180
+ createIcebreakerStylelintConfig as createStylelintConfig,
148
181
  icebreaker
149
182
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/stylelint-config",
3
3
  "type": "module",
4
- "version": "1.1.6",
4
+ "version": "1.2.1",
5
5
  "description": "icebreaker's stylelint config",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -22,7 +22,13 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "import": "./dist/index.js",
24
24
  "require": "./dist/index.cjs"
25
- }
25
+ },
26
+ "./cli": {
27
+ "types": "./dist/cli.d.ts",
28
+ "import": "./dist/cli.js",
29
+ "require": "./dist/cli.cjs"
30
+ },
31
+ "./package.json": "./package.json"
26
32
  },
27
33
  "main": "./dist/index.cjs",
28
34
  "module": "./dist/index.js",
@@ -1,43 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // ../../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/esm_shims.js
31
- import path from "path";
32
- import { fileURLToPath } from "url";
33
- var init_esm_shims = __esm({
34
- "../../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/esm_shims.js"() {
35
- "use strict";
36
- }
37
- });
38
-
39
- export {
40
- __commonJS,
41
- __toESM,
42
- init_esm_shims
43
- };