@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/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,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
3
|
+
var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
4
|
+
var PRESET_RECESS_ORDER = "stylelint-config-recess-order";
|
|
5
|
+
var DEFAULT_IGNORE_AT_RULES = [
|
|
6
|
+
"tailwind",
|
|
7
|
+
"theme",
|
|
8
|
+
"apply",
|
|
9
|
+
"source",
|
|
10
|
+
"utility",
|
|
11
|
+
"variant",
|
|
12
|
+
"custom-variant",
|
|
13
|
+
"reference",
|
|
14
|
+
"config",
|
|
15
|
+
"plugin",
|
|
16
|
+
"unocss"
|
|
17
|
+
];
|
|
18
|
+
var DEFAULT_IGNORE_TYPES = [
|
|
19
|
+
"page"
|
|
20
|
+
];
|
|
21
|
+
var DEFAULT_IGNORE_UNITS = [
|
|
22
|
+
"rpx"
|
|
23
|
+
];
|
|
7
24
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
// src/utils.ts
|
|
26
|
+
var IGNORE_DEFAULTS = {
|
|
27
|
+
atRules: DEFAULT_IGNORE_AT_RULES,
|
|
28
|
+
types: DEFAULT_IGNORE_TYPES,
|
|
29
|
+
units: DEFAULT_IGNORE_UNITS
|
|
30
|
+
};
|
|
31
|
+
var IGNORE_REPLACE_KEYS = {
|
|
32
|
+
atRules: "atRules",
|
|
33
|
+
types: "types",
|
|
34
|
+
units: "units"
|
|
35
|
+
};
|
|
36
|
+
var IGNORE_APPEND_KEYS = {
|
|
37
|
+
atRules: "addAtRules",
|
|
38
|
+
types: "addTypes",
|
|
39
|
+
units: "addUnits"
|
|
40
|
+
};
|
|
41
|
+
function toArray(value) {
|
|
42
|
+
if (value == null) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return Array.isArray(value) ? value : [value];
|
|
46
|
+
}
|
|
47
|
+
function unique(values) {
|
|
48
|
+
const result = [];
|
|
49
|
+
const seen = /* @__PURE__ */ new Set();
|
|
50
|
+
for (const value of values) {
|
|
51
|
+
if (seen.has(value)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
seen.add(value);
|
|
55
|
+
result.push(value);
|
|
13
56
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function resolveIgnoreList(kind, options) {
|
|
60
|
+
const replaceKey = IGNORE_REPLACE_KEYS[kind];
|
|
61
|
+
const appendKey = IGNORE_APPEND_KEYS[kind];
|
|
62
|
+
const base = options?.[replaceKey];
|
|
63
|
+
const extras = options?.[appendKey];
|
|
64
|
+
const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
|
|
65
|
+
if (!extras || extras.length === 0) {
|
|
66
|
+
return unique(initial);
|
|
17
67
|
}
|
|
18
|
-
|
|
19
|
-
|
|
68
|
+
return unique([...initial, ...extras]);
|
|
69
|
+
}
|
|
70
|
+
function normalizeExtends(base) {
|
|
71
|
+
if (!base || Array.isArray(base) && base.length === 0) {
|
|
72
|
+
return void 0;
|
|
20
73
|
}
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
74
|
+
if (Array.isArray(base)) {
|
|
75
|
+
return base.length === 1 ? base[0] : base;
|
|
23
76
|
}
|
|
24
|
-
return
|
|
77
|
+
return base;
|
|
25
78
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
79
|
+
|
|
80
|
+
// src/config.ts
|
|
81
|
+
function resolvePresetExtends(presets) {
|
|
82
|
+
const entries = [];
|
|
83
|
+
if (presets?.scss !== false) {
|
|
84
|
+
entries.push(PRESET_STANDARD_SCSS);
|
|
29
85
|
}
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
}
|
|
86
|
+
if (presets?.vue !== false) {
|
|
87
|
+
entries.push(PRESET_VUE_SCSS);
|
|
54
88
|
}
|
|
55
|
-
|
|
89
|
+
if (presets?.order !== false) {
|
|
90
|
+
entries.push(PRESET_RECESS_ORDER);
|
|
91
|
+
}
|
|
92
|
+
return entries;
|
|
56
93
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
94
|
+
function resolveExtends(options) {
|
|
95
|
+
const presets = resolvePresetExtends(options?.presets);
|
|
96
|
+
const extras = toArray(options?.extends);
|
|
97
|
+
const values = unique([...presets, ...extras]);
|
|
98
|
+
return normalizeExtends(values);
|
|
62
99
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
return true;
|
|
100
|
+
function resolveOverrides(options) {
|
|
101
|
+
const overrides = options?.overrides;
|
|
102
|
+
if (!overrides || overrides.length === 0) {
|
|
103
|
+
return [];
|
|
68
104
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
return [...overrides];
|
|
106
|
+
}
|
|
107
|
+
function resolveRules(options) {
|
|
108
|
+
const ignoreUnits = resolveIgnoreList("units", options?.ignores);
|
|
109
|
+
const ignoreTypes = resolveIgnoreList("types", options?.ignores);
|
|
110
|
+
const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
|
|
111
|
+
const rules = {
|
|
112
|
+
"unit-no-unknown": [
|
|
113
|
+
true,
|
|
114
|
+
{
|
|
115
|
+
ignoreUnits
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"selector-type-no-unknown": [
|
|
119
|
+
true,
|
|
120
|
+
{
|
|
121
|
+
ignoreTypes
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"at-rule-no-deprecated": [
|
|
125
|
+
true,
|
|
126
|
+
{
|
|
127
|
+
ignoreAtRules
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"scss/selector-no-redundant-nesting-selector": true,
|
|
131
|
+
"scss/at-rule-no-unknown": [
|
|
132
|
+
true,
|
|
133
|
+
{
|
|
134
|
+
ignoreAtRules
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
};
|
|
138
|
+
if (options?.rules) {
|
|
139
|
+
return {
|
|
140
|
+
...rules,
|
|
141
|
+
...options.rules
|
|
142
|
+
};
|
|
74
143
|
}
|
|
75
|
-
|
|
144
|
+
return rules;
|
|
145
|
+
}
|
|
146
|
+
function createIcebreakerStylelintConfig(options = {}) {
|
|
147
|
+
return {
|
|
148
|
+
extends: resolveExtends(options),
|
|
149
|
+
overrides: resolveOverrides(options),
|
|
150
|
+
rules: resolveRules(options)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
76
153
|
|
|
77
154
|
// src/index.ts
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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() {
|
|
155
|
+
function mergeConfigs(base, overrides) {
|
|
156
|
+
if (!overrides) {
|
|
157
|
+
return base;
|
|
158
|
+
}
|
|
94
159
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
],
|
|
160
|
+
...base,
|
|
161
|
+
...overrides,
|
|
113
162
|
rules: {
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
]
|
|
163
|
+
...base.rules ?? {},
|
|
164
|
+
...overrides.rules ?? {}
|
|
141
165
|
}
|
|
142
166
|
};
|
|
143
167
|
}
|
|
144
168
|
function icebreaker(config) {
|
|
145
|
-
|
|
169
|
+
const base = createIcebreakerStylelintConfig();
|
|
170
|
+
return mergeConfigs(base, config);
|
|
146
171
|
}
|
|
147
172
|
export {
|
|
173
|
+
createIcebreakerStylelintConfig as createStylelintConfig,
|
|
148
174
|
icebreaker
|
|
149
175
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -33,7 +39,7 @@
|
|
|
33
39
|
"dist"
|
|
34
40
|
],
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"comment-json": "^4.
|
|
42
|
+
"comment-json": "^4.4.1",
|
|
37
43
|
"postcss-html": "^1.8.0",
|
|
38
44
|
"stylelint-config-recess-order": "^7.3.0",
|
|
39
45
|
"stylelint-config-recommended-scss": "^16.0.2",
|
package/dist/chunk-JCOMXB4R.js
DELETED
|
@@ -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.0_postcss@8.5.6_tsx@4.20.6_typescript@5.9.2_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.0_postcss@8.5.6_tsx@4.20.6_typescript@5.9.2_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
|
-
};
|