@icebreakers/stylelint-config 1.2.5 → 2.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/index.js +10 -3
- package/package.json +7 -9
- package/dist/cli.cjs +0 -66
- package/dist/cli.d.cts +0 -2
- package/dist/index.cjs +0 -223
- package/dist/index.d.cts +0 -42
package/dist/index.js
CHANGED
|
@@ -83,9 +83,16 @@ function normalizeExtends(base) {
|
|
|
83
83
|
// src/config.ts
|
|
84
84
|
var requireFromConfig = createRequire(import.meta.url);
|
|
85
85
|
var BEM_OOCSS_CLASS_NAME_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:__[a-z0-9]+(?:-[a-z0-9]+)*)*(?:--[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
function resolvePresetPath(specifier) {
|
|
87
|
+
try {
|
|
88
|
+
return requireFromConfig.resolve(specifier);
|
|
89
|
+
} catch {
|
|
90
|
+
return specifier;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var PRESET_PATH_STANDARD_SCSS = resolvePresetPath(PRESET_STANDARD_SCSS);
|
|
94
|
+
var PRESET_PATH_VUE_SCSS = resolvePresetPath(PRESET_VUE_SCSS);
|
|
95
|
+
var PRESET_PATH_RECESS_ORDER = resolvePresetPath(PRESET_RECESS_ORDER);
|
|
89
96
|
function resolvePresetExtends(presets) {
|
|
90
97
|
const entries = [];
|
|
91
98
|
if (presets?.scss !== false) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "Stylelint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,17 +22,15 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"require": "./dist/index.cjs"
|
|
25
|
+
"default": "./dist/index.js"
|
|
27
26
|
},
|
|
28
27
|
"./cli": {
|
|
29
28
|
"types": "./dist/cli.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"require": "./dist/cli.cjs"
|
|
29
|
+
"default": "./dist/cli.js"
|
|
32
30
|
},
|
|
33
31
|
"./package.json": "./package.json"
|
|
34
32
|
},
|
|
35
|
-
"main": "./dist/index.
|
|
33
|
+
"main": "./dist/index.js",
|
|
36
34
|
"module": "./dist/index.js",
|
|
37
35
|
"types": "./dist/index.d.ts",
|
|
38
36
|
"bin": "./bin/init.js",
|
|
@@ -43,10 +41,10 @@
|
|
|
43
41
|
"dependencies": {
|
|
44
42
|
"comment-json": "^4.5.1",
|
|
45
43
|
"postcss-html": "^1.8.1",
|
|
46
|
-
"stylelint-config-recess-order": "^7.
|
|
47
|
-
"stylelint-config-recommended-scss": "^
|
|
44
|
+
"stylelint-config-recess-order": "^7.6.0",
|
|
45
|
+
"stylelint-config-recommended-scss": "^17.0.0",
|
|
48
46
|
"stylelint-config-recommended-vue": "^1.6.1",
|
|
49
|
-
"stylelint-config-standard-scss": "^
|
|
47
|
+
"stylelint-config-standard-scss": "^17.0.0"
|
|
50
48
|
},
|
|
51
49
|
"publishConfig": {
|
|
52
50
|
"access": "public",
|
package/dist/cli.cjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
// src/cli.ts
|
|
26
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
27
|
-
var import_node_path = require("path");
|
|
28
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
29
|
-
var import_comment_json = __toESM(require("comment-json"), 1);
|
|
30
|
-
|
|
31
|
-
// src/shared.ts
|
|
32
|
-
function asStringArray(value) {
|
|
33
|
-
if (!Array.isArray(value)) {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
return value.filter((entry) => typeof entry === "string");
|
|
37
|
-
}
|
|
38
|
-
function setVscodeSettingsJson(json2 = {}) {
|
|
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);
|
|
47
|
-
return json2;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/cli.ts
|
|
51
|
-
var cwd = import_node_process.default.cwd();
|
|
52
|
-
import_node_fs.default.mkdirSync((0, import_node_path.resolve)(cwd, ".vscode"), {
|
|
53
|
-
recursive: true
|
|
54
|
-
});
|
|
55
|
-
var vscodeSettingsFilename = (0, import_node_path.resolve)(cwd, ".vscode/settings.json");
|
|
56
|
-
var json = {};
|
|
57
|
-
var isExisted = import_node_fs.default.existsSync(vscodeSettingsFilename);
|
|
58
|
-
if (isExisted) {
|
|
59
|
-
const value = import_comment_json.default.parse(import_node_fs.default.readFileSync(vscodeSettingsFilename, "utf8"));
|
|
60
|
-
if (value) {
|
|
61
|
-
json = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
setVscodeSettingsJson(json);
|
|
65
|
-
import_node_fs.default.writeFileSync(vscodeSettingsFilename, import_comment_json.default.stringify(json, void 0, 2), "utf8");
|
|
66
|
-
console.info(`[@icebreakers/stylelint-config] ${isExisted ? "update" : "init"} '.vscode/settings.json' finished`);
|
package/dist/cli.d.cts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
createStylelintConfig: () => createIcebreakerStylelintConfig,
|
|
24
|
-
icebreaker: () => icebreaker
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
29
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
30
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
31
|
-
|
|
32
|
-
// src/config.ts
|
|
33
|
-
var import_node_module = require("module");
|
|
34
|
-
|
|
35
|
-
// src/constants.ts
|
|
36
|
-
var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
37
|
-
var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
38
|
-
var PRESET_RECESS_ORDER = "stylelint-config-recess-order";
|
|
39
|
-
var DEFAULT_IGNORE_AT_RULES = [
|
|
40
|
-
"tailwind",
|
|
41
|
-
"theme",
|
|
42
|
-
"apply",
|
|
43
|
-
"source",
|
|
44
|
-
"utility",
|
|
45
|
-
"variant",
|
|
46
|
-
"custom-variant",
|
|
47
|
-
"reference",
|
|
48
|
-
"config",
|
|
49
|
-
"plugin",
|
|
50
|
-
"unocss"
|
|
51
|
-
];
|
|
52
|
-
var DEFAULT_IGNORE_TYPES = [
|
|
53
|
-
"page"
|
|
54
|
-
];
|
|
55
|
-
var DEFAULT_IGNORE_UNITS = [
|
|
56
|
-
"rpx"
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// src/utils.ts
|
|
60
|
-
var IGNORE_DEFAULTS = {
|
|
61
|
-
atRules: DEFAULT_IGNORE_AT_RULES,
|
|
62
|
-
types: DEFAULT_IGNORE_TYPES,
|
|
63
|
-
units: DEFAULT_IGNORE_UNITS
|
|
64
|
-
};
|
|
65
|
-
var IGNORE_REPLACE_KEYS = {
|
|
66
|
-
atRules: "atRules",
|
|
67
|
-
types: "types",
|
|
68
|
-
units: "units"
|
|
69
|
-
};
|
|
70
|
-
var IGNORE_APPEND_KEYS = {
|
|
71
|
-
atRules: "addAtRules",
|
|
72
|
-
types: "addTypes",
|
|
73
|
-
units: "addUnits"
|
|
74
|
-
};
|
|
75
|
-
function toArray(value) {
|
|
76
|
-
if (value == null) {
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
return Array.isArray(value) ? value : [value];
|
|
80
|
-
}
|
|
81
|
-
function unique(values) {
|
|
82
|
-
const result = [];
|
|
83
|
-
const seen = /* @__PURE__ */ new Set();
|
|
84
|
-
for (const value of values) {
|
|
85
|
-
if (seen.has(value)) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
seen.add(value);
|
|
89
|
-
result.push(value);
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
function resolveIgnoreList(kind, options) {
|
|
94
|
-
const replaceKey = IGNORE_REPLACE_KEYS[kind];
|
|
95
|
-
const appendKey = IGNORE_APPEND_KEYS[kind];
|
|
96
|
-
const base = options?.[replaceKey];
|
|
97
|
-
const extras = options?.[appendKey];
|
|
98
|
-
const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
|
|
99
|
-
if (!extras || extras.length === 0) {
|
|
100
|
-
return unique(initial);
|
|
101
|
-
}
|
|
102
|
-
return unique([...initial, ...extras]);
|
|
103
|
-
}
|
|
104
|
-
function normalizeExtends(base) {
|
|
105
|
-
if (!base || Array.isArray(base) && base.length === 0) {
|
|
106
|
-
return void 0;
|
|
107
|
-
}
|
|
108
|
-
if (Array.isArray(base)) {
|
|
109
|
-
return base.length === 1 ? base[0] : base;
|
|
110
|
-
}
|
|
111
|
-
return base;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/config.ts
|
|
115
|
-
var requireFromConfig = (0, import_node_module.createRequire)(importMetaUrl);
|
|
116
|
-
var BEM_OOCSS_CLASS_NAME_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:__[a-z0-9]+(?:-[a-z0-9]+)*)*(?:--[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
|
|
117
|
-
var PRESET_PATH_STANDARD_SCSS = requireFromConfig.resolve(PRESET_STANDARD_SCSS);
|
|
118
|
-
var PRESET_PATH_VUE_SCSS = requireFromConfig.resolve(PRESET_VUE_SCSS);
|
|
119
|
-
var PRESET_PATH_RECESS_ORDER = requireFromConfig.resolve(PRESET_RECESS_ORDER);
|
|
120
|
-
function resolvePresetExtends(presets) {
|
|
121
|
-
const entries = [];
|
|
122
|
-
if (presets?.scss !== false) {
|
|
123
|
-
entries.push(PRESET_PATH_STANDARD_SCSS);
|
|
124
|
-
}
|
|
125
|
-
if (presets?.vue !== false) {
|
|
126
|
-
entries.push(PRESET_PATH_VUE_SCSS);
|
|
127
|
-
}
|
|
128
|
-
if (presets?.order !== false) {
|
|
129
|
-
entries.push(PRESET_PATH_RECESS_ORDER);
|
|
130
|
-
}
|
|
131
|
-
return entries;
|
|
132
|
-
}
|
|
133
|
-
function resolveExtends(options) {
|
|
134
|
-
const presets = resolvePresetExtends(options?.presets);
|
|
135
|
-
const extras = toArray(options?.extends);
|
|
136
|
-
const values = unique([...presets, ...extras]);
|
|
137
|
-
return normalizeExtends(values);
|
|
138
|
-
}
|
|
139
|
-
function resolveOverrides(options) {
|
|
140
|
-
const overrides = options?.overrides;
|
|
141
|
-
if (!overrides || overrides.length === 0) {
|
|
142
|
-
return [];
|
|
143
|
-
}
|
|
144
|
-
return [...overrides];
|
|
145
|
-
}
|
|
146
|
-
function resolveRules(options) {
|
|
147
|
-
const ignoreUnits = resolveIgnoreList("units", options?.ignores);
|
|
148
|
-
const ignoreTypes = resolveIgnoreList("types", options?.ignores);
|
|
149
|
-
const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
|
|
150
|
-
const rules = {
|
|
151
|
-
"function-name-case": null,
|
|
152
|
-
"selector-class-pattern": [
|
|
153
|
-
new RegExp(BEM_OOCSS_CLASS_NAME_PATTERN),
|
|
154
|
-
{
|
|
155
|
-
message: "Use BEM/OOCSS-friendly class names",
|
|
156
|
-
resolveNestedSelectors: true
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
"unit-no-unknown": [
|
|
160
|
-
true,
|
|
161
|
-
{
|
|
162
|
-
ignoreUnits
|
|
163
|
-
}
|
|
164
|
-
],
|
|
165
|
-
"selector-type-no-unknown": [
|
|
166
|
-
true,
|
|
167
|
-
{
|
|
168
|
-
ignoreTypes
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
"at-rule-no-deprecated": [
|
|
172
|
-
true,
|
|
173
|
-
{
|
|
174
|
-
ignoreAtRules
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
"scss/selector-no-redundant-nesting-selector": true,
|
|
178
|
-
"scss/at-rule-no-unknown": [
|
|
179
|
-
true,
|
|
180
|
-
{
|
|
181
|
-
ignoreAtRules
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
};
|
|
185
|
-
if (options?.rules) {
|
|
186
|
-
return {
|
|
187
|
-
...rules,
|
|
188
|
-
...options.rules
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return rules;
|
|
192
|
-
}
|
|
193
|
-
function createIcebreakerStylelintConfig(options = {}) {
|
|
194
|
-
return {
|
|
195
|
-
extends: resolveExtends(options),
|
|
196
|
-
overrides: resolveOverrides(options),
|
|
197
|
-
rules: resolveRules(options)
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// src/index.ts
|
|
202
|
-
function mergeConfigs(base, overrides) {
|
|
203
|
-
if (!overrides) {
|
|
204
|
-
return base;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
...base,
|
|
208
|
-
...overrides,
|
|
209
|
-
rules: {
|
|
210
|
-
...base.rules ?? {},
|
|
211
|
-
...overrides.rules ?? {}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function icebreaker(config) {
|
|
216
|
-
const base = createIcebreakerStylelintConfig();
|
|
217
|
-
return mergeConfigs(base, config);
|
|
218
|
-
}
|
|
219
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
-
0 && (module.exports = {
|
|
221
|
-
createStylelintConfig,
|
|
222
|
-
icebreaker
|
|
223
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Config } from 'stylelint';
|
|
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
|
-
|
|
40
|
-
declare function icebreaker(config?: Config): Config;
|
|
41
|
-
|
|
42
|
-
export { type IcebreakerStylelintOptions, type IgnoreListOptions, type PresetToggles, createIcebreakerStylelintConfig as createStylelintConfig, icebreaker };
|