@useinsider/eslint-config 1.13.0 → 1.14.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 +366 -58
- package/dist/builders/configFiles.d.ts +12 -0
- package/dist/builders/jquery.d.ts +5 -0
- package/dist/builders/scopeBlocks.d.ts +49 -0
- package/dist/builders/spellChecker.d.ts +7 -0
- package/dist/builders/strict.d.ts +2 -0
- package/dist/builders/typescript.d.ts +6 -0
- package/dist/builders/vue.d.ts +8 -0
- package/dist/cli.cjs +4538 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/configs/config/dependencies.d.ts +1 -0
- package/dist/configs/javascript/dependencies.d.ts +1 -0
- package/dist/configs/javascript-dom/dependencies.d.ts +1 -0
- package/dist/configs/javascript-node/dependencies.d.ts +1 -0
- package/dist/configs/jest/dependencies.d.ts +3 -0
- package/dist/configs/jsdoc-based-ts/dependencies.d.ts +6 -0
- package/dist/configs/strict/dependencies.d.ts +3 -0
- package/dist/configs/typescript/dependencies.d.ts +6 -0
- package/dist/configs/typescript-dom/dependencies.d.ts +6 -0
- package/dist/configs/typescript-node/dependencies.d.ts +6 -0
- package/dist/configs/vitest/dependencies.d.ts +3 -0
- package/dist/configs/vitest/index.d.ts +3 -0
- package/dist/configs/vue2/dependencies.d.ts +5 -0
- package/dist/configs/vue2-options-api/dependencies.d.ts +5 -0
- package/dist/configs/vue2-options-api/index.d.ts +1208 -0
- package/dist/configs/vue2-typescript/dependencies.d.ts +9 -0
- package/dist/configs/vue2-typescript-options-api/dependencies.d.ts +9 -0
- package/dist/configs/vue2-typescript-options-api/index.d.ts +3 -0
- package/dist/configs/vue3/dependencies.d.ts +5 -0
- package/dist/configs/vue3-options-api/dependencies.d.ts +5 -0
- package/dist/configs/vue3-options-api/index.d.ts +1208 -0
- package/dist/configs/vue3-typescript/dependencies.d.ts +9 -0
- package/dist/configs/vue3-typescript-options-api/dependencies.d.ts +9 -0
- package/dist/configs/vue3-typescript-options-api/index.d.ts +3 -0
- package/dist/{javascript-ZbGsFE17.cjs → javascript-CrNAuq8X.cjs} +2 -2
- package/dist/{javascript-ZbGsFE17.cjs.map → javascript-CrNAuq8X.cjs.map} +1 -1
- package/dist/{javascript-BXgxOHrE.js → javascript-DBh1tdoj.js} +2 -2
- package/dist/{javascript-BXgxOHrE.js.map → javascript-DBh1tdoj.js.map} +1 -1
- package/dist/{javascript-dom-D7RX0w0r.cjs → javascript-dom-qddIl6lD.cjs} +2 -2
- package/dist/{javascript-dom-D7RX0w0r.cjs.map → javascript-dom-qddIl6lD.cjs.map} +1 -1
- package/dist/{javascript-dom-DQiJS6LF.js → javascript-dom-vHj4V_jJ.js} +2 -2
- package/dist/{javascript-dom-DQiJS6LF.js.map → javascript-dom-vHj4V_jJ.js.map} +1 -1
- package/dist/{javascript-node-fII8MlI4.cjs → javascript-node-CymkpeIN.cjs} +2 -2
- package/dist/{javascript-node-fII8MlI4.cjs.map → javascript-node-CymkpeIN.cjs.map} +1 -1
- package/dist/{javascript-node-DDpIBysN.js → javascript-node-rbQ7OZX2.js} +2 -2
- package/dist/{javascript-node-DDpIBysN.js.map → javascript-node-rbQ7OZX2.js.map} +1 -1
- package/dist/main.cjs +530 -52
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.ts +56 -21
- package/dist/main.js +531 -55
- package/dist/main.js.map +1 -1
- package/dist/rules/vue-options-api.d.ts +2 -0
- package/dist/{stylistic-Cca81A-Y.js → stylistic-C527N_5D.js} +22 -20
- package/dist/stylistic-C527N_5D.js.map +1 -0
- package/dist/{stylistic-BltudTa0.cjs → stylistic-_qagyIah.cjs} +22 -20
- package/dist/stylistic-_qagyIah.cjs.map +1 -0
- package/dist/{typescript-Z0gBgZeY.js → typescript-BkxC1Ebj.js} +3 -3
- package/dist/{typescript-Z0gBgZeY.js.map → typescript-BkxC1Ebj.js.map} +1 -1
- package/dist/{typescript-RDy5oH7o.cjs → typescript-Cm5y5BRu.cjs} +3 -3
- package/dist/{typescript-RDy5oH7o.cjs.map → typescript-Cm5y5BRu.cjs.map} +1 -1
- package/dist/{typescript-dom-DUh1spmb.cjs → typescript-dom-B5cwc97i.cjs} +2 -2
- package/dist/{typescript-dom-DUh1spmb.cjs.map → typescript-dom-B5cwc97i.cjs.map} +1 -1
- package/dist/{typescript-dom-BFinGO4G.js → typescript-dom-BMG-VaTV.js} +2 -2
- package/dist/{typescript-dom-BFinGO4G.js.map → typescript-dom-BMG-VaTV.js.map} +1 -1
- package/dist/{typescript-node-ClKSHtBn.cjs → typescript-node-BPHyiIve.cjs} +2 -2
- package/dist/{typescript-node-ClKSHtBn.cjs.map → typescript-node-BPHyiIve.cjs.map} +1 -1
- package/dist/{typescript-node-B3akGwfD.js → typescript-node-D_KHq9pf.js} +2 -2
- package/dist/{typescript-node-B3akGwfD.js.map → typescript-node-D_KHq9pf.js.map} +1 -1
- package/dist/utils/ensureConfigStructure.d.ts +17 -0
- package/dist/vitest-BgPQ6GrC.js +15 -0
- package/dist/vitest-BgPQ6GrC.js.map +1 -0
- package/dist/vitest-Cxe6To8m.cjs +17 -0
- package/dist/vitest-Cxe6To8m.cjs.map +1 -0
- package/dist/{vue-ABpPpVRF.cjs → vue-BSB1UZUR.cjs} +1 -1
- package/dist/{vue-ABpPpVRF.cjs.map → vue-BSB1UZUR.cjs.map} +1 -1
- package/dist/{vue-DN4l4tpE.js → vue-W9Dr0NU_.js} +1 -1
- package/dist/{vue-DN4l4tpE.js.map → vue-W9Dr0NU_.js.map} +1 -1
- package/dist/vue-options-api-DOwpLXkl.cjs +21 -0
- package/dist/vue-options-api-DOwpLXkl.cjs.map +1 -0
- package/dist/vue-options-api-Dx5bF7ak.js +16 -0
- package/dist/vue-options-api-Dx5bF7ak.js.map +1 -0
- package/dist/{vue2-DSL0XmaS.cjs → vue2-BO5tkjc4.cjs} +2 -2
- package/dist/{vue2-DSL0XmaS.cjs.map → vue2-BO5tkjc4.cjs.map} +1 -1
- package/dist/{vue2-BiP0fuu1.js → vue2-DkvfPqh_.js} +2 -2
- package/dist/{vue2-BiP0fuu1.js.map → vue2-DkvfPqh_.js.map} +1 -1
- package/dist/{vue2-Bh7W369C.cjs → vue2-XNhU8qvc.cjs} +3 -3
- package/dist/{vue2-Bh7W369C.cjs.map → vue2-XNhU8qvc.cjs.map} +1 -1
- package/dist/{vue2-DDKBhsLm.js → vue2-npomS1zY.js} +3 -3
- package/dist/{vue2-DDKBhsLm.js.map → vue2-npomS1zY.js.map} +1 -1
- package/dist/vue2-options-api-BPw5U0yK.js +25 -0
- package/dist/vue2-options-api-BPw5U0yK.js.map +1 -0
- package/dist/vue2-options-api-zm_Ppsnb.cjs +31 -0
- package/dist/vue2-options-api-zm_Ppsnb.cjs.map +1 -0
- package/dist/vue2-typescript-B2ubjEbm.cjs +18 -0
- package/dist/vue2-typescript-B2ubjEbm.cjs.map +1 -0
- package/dist/{vue2-typescript-CUqjxRHT.js → vue2-typescript-DV30OSCU.js} +4 -13
- package/dist/vue2-typescript-DV30OSCU.js.map +1 -0
- package/dist/vue2-typescript-DkeW8a4q.js +13 -0
- package/dist/vue2-typescript-DkeW8a4q.js.map +1 -0
- package/dist/vue2-typescript-options-api-Dxl4Cj_u.js +42 -0
- package/dist/vue2-typescript-options-api-Dxl4Cj_u.js.map +1 -0
- package/dist/vue2-typescript-options-api-Tj8_pTDc.cjs +50 -0
- package/dist/vue2-typescript-options-api-Tj8_pTDc.cjs.map +1 -0
- package/dist/{vue2-typescript-GmtjjCxx.cjs → vue2-typescript-qUvTF_0O.cjs} +5 -14
- package/dist/vue2-typescript-qUvTF_0O.cjs.map +1 -0
- package/dist/{vue3-CKwnKeS6.js → vue3-BnQYXB3K.js} +3 -3
- package/dist/{vue3-CKwnKeS6.js.map → vue3-BnQYXB3K.js.map} +1 -1
- package/dist/{vue3-BtNhSn_w.cjs → vue3-Dexa-ftV.cjs} +3 -3
- package/dist/{vue3-BtNhSn_w.cjs.map → vue3-Dexa-ftV.cjs.map} +1 -1
- package/dist/vue3-options-api-Fl27U2nN.cjs +31 -0
- package/dist/vue3-options-api-Fl27U2nN.cjs.map +1 -0
- package/dist/vue3-options-api-cejoqzVH.js +25 -0
- package/dist/vue3-options-api-cejoqzVH.js.map +1 -0
- package/dist/{vue3-typescript-CbM4dYzN.js → vue3-typescript-C65tDgFp.js} +3 -3
- package/dist/{vue3-typescript-CbM4dYzN.js.map → vue3-typescript-C65tDgFp.js.map} +1 -1
- package/dist/{vue3-typescript-P2UoKs0V.cjs → vue3-typescript-CzR7L5ep.cjs} +3 -3
- package/dist/{vue3-typescript-P2UoKs0V.cjs.map → vue3-typescript-CzR7L5ep.cjs.map} +1 -1
- package/dist/vue3-typescript-options-api-D56mHjp4.cjs +49 -0
- package/dist/vue3-typescript-options-api-D56mHjp4.cjs.map +1 -0
- package/dist/vue3-typescript-options-api-DL7JFqMJ.js +41 -0
- package/dist/vue3-typescript-options-api-DL7JFqMJ.js.map +1 -0
- package/package.json +29 -6
- package/dist/stylistic-BltudTa0.cjs.map +0 -1
- package/dist/stylistic-Cca81A-Y.js.map +0 -1
- package/dist/vue2-typescript-CUqjxRHT.js.map +0 -1
- package/dist/vue2-typescript-GmtjjCxx.cjs.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,12 +1,493 @@
|
|
|
1
1
|
import { t as merge } from "./merge-DEya5rmo.js";
|
|
2
2
|
import { t as mergeAll } from "./mergeAllConfig-BbXVeKTg.js";
|
|
3
|
-
import {
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
import globals from "globals";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
4
6
|
import { createRequire } from "node:module";
|
|
5
|
-
import { resolve } from "node:path";
|
|
7
|
+
import { dirname, resolve } from "node:path";
|
|
6
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
7
10
|
import { installPackage } from "@antfu/install-pkg";
|
|
8
11
|
import semver from "semver";
|
|
9
12
|
import { warn } from "node:console";
|
|
13
|
+
//#region src/builders/configFiles.ts
|
|
14
|
+
/**
|
|
15
|
+
* Default globs treated as "configuration files" — root-level `*.config.*`
|
|
16
|
+
* variants plus the canonical `eslint.config.*` flat-config filenames.
|
|
17
|
+
*
|
|
18
|
+
* These are intentionally conservative: only the top-level matches that the
|
|
19
|
+
* v1 `config` preset was overwhelmingly applied to. Project-specific paths
|
|
20
|
+
* (subdirectories, custom names) must be opted into by passing them via the
|
|
21
|
+
* `configFiles: string[]` knob.
|
|
22
|
+
*/
|
|
23
|
+
var DEFAULT_CONFIG_FILE_GLOBS = [
|
|
24
|
+
"*.config.{ts,mts,cts,js,mjs,cjs}",
|
|
25
|
+
"*.config.*.{ts,mts,cts,js,mjs,cjs}",
|
|
26
|
+
"eslint.config.{mjs,js,cjs,ts}"
|
|
27
|
+
];
|
|
28
|
+
var configFileRules = {
|
|
29
|
+
"import-x/no-extraneous-dependencies": "off",
|
|
30
|
+
"import-x/prefer-default-export": "off"
|
|
31
|
+
};
|
|
32
|
+
function mergeGlobs(userGlobs) {
|
|
33
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34
|
+
const merged = [];
|
|
35
|
+
DEFAULT_CONFIG_FILE_GLOBS.forEach((glob) => {
|
|
36
|
+
if (!seen.has(glob)) {
|
|
37
|
+
seen.add(glob);
|
|
38
|
+
merged.push(glob);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
userGlobs.forEach((glob) => {
|
|
42
|
+
if (!seen.has(glob)) {
|
|
43
|
+
seen.add(glob);
|
|
44
|
+
merged.push(glob);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return merged;
|
|
48
|
+
}
|
|
49
|
+
function buildConfigFilesBlocks(value) {
|
|
50
|
+
if (value === false) return [];
|
|
51
|
+
return [{
|
|
52
|
+
files: value === void 0 ? [...DEFAULT_CONFIG_FILE_GLOBS] : mergeGlobs(value),
|
|
53
|
+
rules: { ...configFileRules }
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/builders/jquery.ts
|
|
58
|
+
function buildJqueryBlocks(entries) {
|
|
59
|
+
if (!entries || entries.length === 0) return [];
|
|
60
|
+
return entries.map((entry) => ({
|
|
61
|
+
files: entry.files,
|
|
62
|
+
languageOptions: { globals: { ...globals.jquery } }
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/builders/typescript.ts
|
|
67
|
+
function applyTypescriptOverrides(block, input) {
|
|
68
|
+
const languageOptions = block.languageOptions ?? {};
|
|
69
|
+
const parserOptions = languageOptions.parserOptions ?? {};
|
|
70
|
+
parserOptions.project = input.tsconfigPaths;
|
|
71
|
+
parserOptions.tsconfigRootDir = process.cwd();
|
|
72
|
+
languageOptions.parserOptions = parserOptions;
|
|
73
|
+
block.languageOptions = languageOptions;
|
|
74
|
+
return block;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/builders/vue.ts
|
|
78
|
+
function escapeRegex(input) {
|
|
79
|
+
return input.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
80
|
+
}
|
|
81
|
+
function anchoredEscapeRegex(input) {
|
|
82
|
+
return `^${escapeRegex(input)}$`;
|
|
83
|
+
}
|
|
84
|
+
function applyVueOverrides(block, input) {
|
|
85
|
+
if (!input.globalComponents || input.globalComponents.length === 0) return block;
|
|
86
|
+
const rules = block.rules ?? {};
|
|
87
|
+
rules["vue/no-undef-components"] = ["error", { ignorePatterns: input.globalComponents.map(anchoredEscapeRegex) }];
|
|
88
|
+
block.rules = rules;
|
|
89
|
+
return block;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/builders/scopeBlocks.ts
|
|
93
|
+
var scopeMap = {
|
|
94
|
+
async config() {
|
|
95
|
+
return import("./config-Css2Pu_R.js");
|
|
96
|
+
},
|
|
97
|
+
async javascript() {
|
|
98
|
+
return import("./javascript-DBh1tdoj.js");
|
|
99
|
+
},
|
|
100
|
+
async javascriptDom() {
|
|
101
|
+
return import("./javascript-dom-vHj4V_jJ.js");
|
|
102
|
+
},
|
|
103
|
+
async javascriptNode() {
|
|
104
|
+
return import("./javascript-node-rbQ7OZX2.js");
|
|
105
|
+
},
|
|
106
|
+
async typescript() {
|
|
107
|
+
return import("./typescript-BkxC1Ebj.js");
|
|
108
|
+
},
|
|
109
|
+
async typescriptDom() {
|
|
110
|
+
return import("./typescript-dom-BMG-VaTV.js");
|
|
111
|
+
},
|
|
112
|
+
async typescriptNode() {
|
|
113
|
+
return import("./typescript-node-D_KHq9pf.js");
|
|
114
|
+
},
|
|
115
|
+
async vue2() {
|
|
116
|
+
return import("./vue2-npomS1zY.js");
|
|
117
|
+
},
|
|
118
|
+
async vue3() {
|
|
119
|
+
return import("./vue3-BnQYXB3K.js");
|
|
120
|
+
},
|
|
121
|
+
async vue2Typescript() {
|
|
122
|
+
return import("./vue2-typescript-DV30OSCU.js");
|
|
123
|
+
},
|
|
124
|
+
async vue3Typescript() {
|
|
125
|
+
return import("./vue3-typescript-C65tDgFp.js");
|
|
126
|
+
},
|
|
127
|
+
async vue2OptionsApi() {
|
|
128
|
+
return import("./vue2-options-api-BPw5U0yK.js");
|
|
129
|
+
},
|
|
130
|
+
async vue3OptionsApi() {
|
|
131
|
+
return import("./vue3-options-api-cejoqzVH.js");
|
|
132
|
+
},
|
|
133
|
+
async vue2TypescriptOptionsApi() {
|
|
134
|
+
return import("./vue2-typescript-options-api-Dxl4Cj_u.js");
|
|
135
|
+
},
|
|
136
|
+
async vue3TypescriptOptionsApi() {
|
|
137
|
+
return import("./vue3-typescript-options-api-DL7JFqMJ.js");
|
|
138
|
+
},
|
|
139
|
+
async jest() {
|
|
140
|
+
return import("./jest-B0jgh-Ns.js");
|
|
141
|
+
},
|
|
142
|
+
async vitest() {
|
|
143
|
+
return import("./vitest-BgPQ6GrC.js");
|
|
144
|
+
},
|
|
145
|
+
async jsdocBasedTs() {
|
|
146
|
+
return import("./jsdoc-based-ts-B40HFdNC.js");
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var tsScopes = new Set([
|
|
150
|
+
"typescript",
|
|
151
|
+
"typescriptDom",
|
|
152
|
+
"typescriptNode",
|
|
153
|
+
"vue2Typescript",
|
|
154
|
+
"vue3Typescript",
|
|
155
|
+
"vue2TypescriptOptionsApi",
|
|
156
|
+
"vue3TypescriptOptionsApi",
|
|
157
|
+
"jsdocBasedTs"
|
|
158
|
+
]);
|
|
159
|
+
var vueScopes = new Set([
|
|
160
|
+
"vue2",
|
|
161
|
+
"vue3",
|
|
162
|
+
"vue2Typescript",
|
|
163
|
+
"vue3Typescript",
|
|
164
|
+
"vue2OptionsApi",
|
|
165
|
+
"vue3OptionsApi",
|
|
166
|
+
"vue2TypescriptOptionsApi",
|
|
167
|
+
"vue3TypescriptOptionsApi"
|
|
168
|
+
]);
|
|
169
|
+
function clonePreset(preset) {
|
|
170
|
+
return {
|
|
171
|
+
...preset,
|
|
172
|
+
languageOptions: preset.languageOptions ? {
|
|
173
|
+
...preset.languageOptions,
|
|
174
|
+
parserOptions: preset.languageOptions.parserOptions ? { ...preset.languageOptions.parserOptions } : void 0,
|
|
175
|
+
globals: preset.languageOptions.globals ? { ...preset.languageOptions.globals } : void 0
|
|
176
|
+
} : void 0,
|
|
177
|
+
rules: preset.rules ? { ...preset.rules } : void 0,
|
|
178
|
+
settings: preset.settings ? { ...preset.settings } : void 0
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function isScopeName(key) {
|
|
182
|
+
return Object.keys(scopeMap).includes(key);
|
|
183
|
+
}
|
|
184
|
+
function applyCommonEntryFields(block, entry) {
|
|
185
|
+
if (entry.ignores && entry.ignores.length > 0) block.ignores = [...entry.ignores];
|
|
186
|
+
if (entry.globals) {
|
|
187
|
+
const languageOptions = block.languageOptions ?? {};
|
|
188
|
+
languageOptions.globals = {
|
|
189
|
+
...languageOptions.globals ?? {},
|
|
190
|
+
...entry.globals
|
|
191
|
+
};
|
|
192
|
+
block.languageOptions = languageOptions;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function buildScopeBlocks(scope, entries) {
|
|
196
|
+
const preset = (await scopeMap[scope]()).default;
|
|
197
|
+
return entries.map((entry) => {
|
|
198
|
+
const block = clonePreset(preset);
|
|
199
|
+
block.files = entry.files;
|
|
200
|
+
if (tsScopes.has(scope)) {
|
|
201
|
+
const { tsconfigPaths } = entry;
|
|
202
|
+
if (tsconfigPaths) applyTypescriptOverrides(block, { tsconfigPaths });
|
|
203
|
+
}
|
|
204
|
+
if (vueScopes.has(scope)) {
|
|
205
|
+
const { globalComponents } = entry;
|
|
206
|
+
applyVueOverrides(block, { globalComponents });
|
|
207
|
+
}
|
|
208
|
+
applyCommonEntryFields(block, entry);
|
|
209
|
+
return block;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/builders/spellChecker.ts
|
|
214
|
+
function buildSpellCheckerBlocks(input) {
|
|
215
|
+
if (!input) return [];
|
|
216
|
+
const blocks = [];
|
|
217
|
+
if (input.customWordListFile) blocks.push({ rules: { "@cspell/spellchecker": ["error", { customWordListFile: input.customWordListFile }] } });
|
|
218
|
+
if (input.ignoredPaths && input.ignoredPaths.length > 0) blocks.push({
|
|
219
|
+
files: input.ignoredPaths,
|
|
220
|
+
rules: { "@cspell/spellchecker": "off" }
|
|
221
|
+
});
|
|
222
|
+
return blocks;
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/builders/strict.ts
|
|
226
|
+
async function buildStrictBlocks(value) {
|
|
227
|
+
if (!value) return [];
|
|
228
|
+
const isFileScoped = Array.isArray(value);
|
|
229
|
+
if (isFileScoped && value.length === 0) return [];
|
|
230
|
+
const { default: strictConfig } = await import("./strict-BfeS2xp_.js");
|
|
231
|
+
const clone = { ...strictConfig };
|
|
232
|
+
if (clone.rules) clone.rules = { ...clone.rules };
|
|
233
|
+
if (isFileScoped) clone.files = value;
|
|
234
|
+
else delete clone.files;
|
|
235
|
+
return [clone];
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/utils/ensureConfigStructure.ts
|
|
239
|
+
var CONFIG_FILE_REGEX = /eslint\.config\.[mc]?[jt]s(?:$|\?)/;
|
|
240
|
+
var OPT_OUT_ENV = "INSIDER_SKIP_CONFIG_VALIDATION";
|
|
241
|
+
var FILE_URL_PREFIX = "file://";
|
|
242
|
+
var TARGET_CALLEE_NAME = "useInsider";
|
|
243
|
+
var INSIDER_IMPORT_SOURCE = "@useinsider/eslint-config";
|
|
244
|
+
var bypassWarnEmitted = false;
|
|
245
|
+
function computeSelfModulePath() {
|
|
246
|
+
const raw = fileURLToPath(import.meta.url);
|
|
247
|
+
try {
|
|
248
|
+
return realpathSync(raw);
|
|
249
|
+
} catch {
|
|
250
|
+
return raw;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
var SELF_MODULE_PATH = computeSelfModulePath();
|
|
254
|
+
function isPathSpecifier(source) {
|
|
255
|
+
return source.startsWith(".") || source.startsWith("/");
|
|
256
|
+
}
|
|
257
|
+
function defaultIsInsiderImportSource(source, configPath) {
|
|
258
|
+
if (source === INSIDER_IMPORT_SOURCE) return true;
|
|
259
|
+
if (!configPath || !isPathSpecifier(source)) return false;
|
|
260
|
+
try {
|
|
261
|
+
return realpathSync(resolve(dirname(configPath), source)) === SELF_MODULE_PATH;
|
|
262
|
+
} catch {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function locOf(node) {
|
|
267
|
+
return {
|
|
268
|
+
line: node.loc.start.line,
|
|
269
|
+
column: node.loc.start.column
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function validateCallExpression(callExpr) {
|
|
273
|
+
const { callee } = callExpr;
|
|
274
|
+
if (callee.type !== AST_NODE_TYPES.Identifier || callee.name !== TARGET_CALLEE_NAME) return [{
|
|
275
|
+
...locOf(callExpr),
|
|
276
|
+
reason: "Default export must call `useInsider(...)` directly."
|
|
277
|
+
}];
|
|
278
|
+
return [];
|
|
279
|
+
}
|
|
280
|
+
function validateExportedCall(callee, fallbackLoc) {
|
|
281
|
+
let target = callee;
|
|
282
|
+
if (target.type === AST_NODE_TYPES.AwaitExpression) target = target.argument;
|
|
283
|
+
if (target.type === AST_NODE_TYPES.CallExpression) return validateCallExpression(target);
|
|
284
|
+
if (target.type === AST_NODE_TYPES.ArrayExpression) return [{
|
|
285
|
+
...locOf(target),
|
|
286
|
+
reason: "Default export must not wrap `useInsider(...)` in an array. Use the typed options object instead."
|
|
287
|
+
}];
|
|
288
|
+
if (target.type === AST_NODE_TYPES.LogicalExpression || target.type === AST_NODE_TYPES.ConditionalExpression) {
|
|
289
|
+
const reason = ["Default export must not gate `useInsider(...)` behind a logical/conditional expression.", "Use the typed options object instead."].join(" ");
|
|
290
|
+
return [{
|
|
291
|
+
...locOf(target),
|
|
292
|
+
reason
|
|
293
|
+
}];
|
|
294
|
+
}
|
|
295
|
+
return [{
|
|
296
|
+
...fallbackLoc,
|
|
297
|
+
reason: "Default export must be a direct call to `useInsider(...)`."
|
|
298
|
+
}];
|
|
299
|
+
}
|
|
300
|
+
function collectInsiderBindings(node, bindings, isInsiderSource) {
|
|
301
|
+
if (!isInsiderSource(node.source.value)) return;
|
|
302
|
+
node.specifiers.forEach((specifier) => {
|
|
303
|
+
bindings.add(specifier.local.name);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function classifyExpressionStatement(node, insiderBindings) {
|
|
307
|
+
const { expression } = node;
|
|
308
|
+
if (expression.type === AST_NODE_TYPES.CallExpression && expression.callee.type === AST_NODE_TYPES.Identifier && insiderBindings.has(expression.callee.name)) return { type: "ignore" };
|
|
309
|
+
const reason = ["Disallowed top-level statement `ExpressionStatement`.", `Only call expressions whose callee was imported from \`${INSIDER_IMPORT_SOURCE}\` are allowed at top level.`].join(" ");
|
|
310
|
+
return {
|
|
311
|
+
type: "disallowed",
|
|
312
|
+
violation: {
|
|
313
|
+
...locOf(node),
|
|
314
|
+
reason
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function classifyStatement(node, exportSeen, insiderBindings) {
|
|
319
|
+
if (node.type === AST_NODE_TYPES.ImportDeclaration || node.type === AST_NODE_TYPES.VariableDeclaration) return { type: "ignore" };
|
|
320
|
+
if (node.type === AST_NODE_TYPES.ExpressionStatement) return classifyExpressionStatement(node, insiderBindings);
|
|
321
|
+
if (node.type === AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
322
|
+
if (exportSeen) return {
|
|
323
|
+
type: "duplicateExport",
|
|
324
|
+
violation: {
|
|
325
|
+
...locOf(node),
|
|
326
|
+
reason: "Only one default export is allowed."
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const declaration = node.declaration;
|
|
330
|
+
return {
|
|
331
|
+
type: "export",
|
|
332
|
+
violations: validateExportedCall(declaration, locOf(node))
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const reason = [
|
|
336
|
+
`Disallowed top-level statement \`${node.type}\`.`,
|
|
337
|
+
"Only imports, variable declarations, helper calls from `@useinsider/eslint-config`,",
|
|
338
|
+
"and one `export default useInsider(...)` are allowed."
|
|
339
|
+
].join(" ");
|
|
340
|
+
return {
|
|
341
|
+
type: "disallowed",
|
|
342
|
+
violation: {
|
|
343
|
+
...locOf(node),
|
|
344
|
+
reason
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function validateProgramStructure(program, configPath = "", options = {}) {
|
|
349
|
+
const violations = [];
|
|
350
|
+
const insiderBindings = /* @__PURE__ */ new Set();
|
|
351
|
+
const resolver = options.isInsiderImportSource ?? defaultIsInsiderImportSource;
|
|
352
|
+
const isInsiderSource = (source) => resolver(source, configPath);
|
|
353
|
+
let exportSeen = false;
|
|
354
|
+
program.body.forEach((node) => {
|
|
355
|
+
if (node.type === AST_NODE_TYPES.ImportDeclaration) collectInsiderBindings(node, insiderBindings, isInsiderSource);
|
|
356
|
+
const result = classifyStatement(node, exportSeen, insiderBindings);
|
|
357
|
+
if (result.type === "ignore") return;
|
|
358
|
+
if (result.type === "export") {
|
|
359
|
+
exportSeen = true;
|
|
360
|
+
violations.push(...result.violations);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (result.type === "duplicateExport") {
|
|
364
|
+
violations.push(result.violation);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
violations.push(result.violation);
|
|
368
|
+
});
|
|
369
|
+
if (!exportSeen) violations.push({
|
|
370
|
+
line: 1,
|
|
371
|
+
column: 0,
|
|
372
|
+
reason: "Missing `export default useInsider(...)`."
|
|
373
|
+
});
|
|
374
|
+
return violations;
|
|
375
|
+
}
|
|
376
|
+
function readStackFrames() {
|
|
377
|
+
const original = Error.prepareStackTrace;
|
|
378
|
+
Error.prepareStackTrace = (_, frames) => frames;
|
|
379
|
+
const holder = {};
|
|
380
|
+
Error.captureStackTrace(holder, readStackFrames);
|
|
381
|
+
const { stack } = holder;
|
|
382
|
+
Error.prepareStackTrace = original;
|
|
383
|
+
if (!Array.isArray(stack)) return [];
|
|
384
|
+
return stack;
|
|
385
|
+
}
|
|
386
|
+
function normalizeFrameFilename(raw) {
|
|
387
|
+
if (!raw) return null;
|
|
388
|
+
const withoutPrefix = raw.startsWith(FILE_URL_PREFIX) ? raw.slice(7) : raw;
|
|
389
|
+
const queryIndex = withoutPrefix.indexOf("?");
|
|
390
|
+
return queryIndex === -1 ? withoutPrefix : withoutPrefix.slice(0, queryIndex);
|
|
391
|
+
}
|
|
392
|
+
function extractMatchesFromStack(frames) {
|
|
393
|
+
const matches = /* @__PURE__ */ new Set();
|
|
394
|
+
frames.forEach((frame) => {
|
|
395
|
+
const name = normalizeFrameFilename(frame.getFileName());
|
|
396
|
+
if (name && CONFIG_FILE_REGEX.test(name)) matches.add(name);
|
|
397
|
+
});
|
|
398
|
+
return Array.from(matches);
|
|
399
|
+
}
|
|
400
|
+
function argvCandidateAt(argv, index) {
|
|
401
|
+
const arg = argv[index];
|
|
402
|
+
if (arg === "--config" || arg === "-c") return argv[index + 1] ?? null;
|
|
403
|
+
if (arg.startsWith("--config=")) return arg.slice(9);
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
function extractConfigFromArgv(argv) {
|
|
407
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
408
|
+
const candidate = argvCandidateAt(argv, i);
|
|
409
|
+
if (candidate && CONFIG_FILE_REGEX.test(candidate)) return candidate;
|
|
410
|
+
}
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
function getConsumerConfigPath(frames = readStackFrames(), argv = process.argv) {
|
|
414
|
+
const stackMatches = extractMatchesFromStack(frames);
|
|
415
|
+
if (stackMatches.length === 1) return stackMatches[0];
|
|
416
|
+
const fromArgv = extractConfigFromArgv(argv);
|
|
417
|
+
if (fromArgv) return fromArgv;
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
function formatReport(configPath, violations) {
|
|
421
|
+
const header = ["@useinsider/eslint-config: protected configuration structure violated in:", ` ${configPath}`].join("\n");
|
|
422
|
+
const lines = violations.map((violation) => ` - [${violation.line}:${violation.column}] ${violation.reason}`);
|
|
423
|
+
const footer = [
|
|
424
|
+
"",
|
|
425
|
+
"Allowed structure:",
|
|
426
|
+
" - import statements",
|
|
427
|
+
" - const/let/var declarations",
|
|
428
|
+
" - exactly one `export default useInsider({ ... })`",
|
|
429
|
+
"",
|
|
430
|
+
"Emergency bypass: set INSIDER_SKIP_CONFIG_VALIDATION=true (do not commit)."
|
|
431
|
+
].join("\n");
|
|
432
|
+
return `${header}\n${lines.join("\n")}\n${footer}`;
|
|
433
|
+
}
|
|
434
|
+
function emitBypassWarning() {
|
|
435
|
+
if (bypassWarnEmitted) return;
|
|
436
|
+
bypassWarnEmitted = true;
|
|
437
|
+
const message = ["@useinsider/eslint-config: structure validation BYPASSED", "via INSIDER_SKIP_CONFIG_VALIDATION — emergency use only."].join(" ");
|
|
438
|
+
console.warn(message);
|
|
439
|
+
}
|
|
440
|
+
var ConfigStructureExit = class extends Error {};
|
|
441
|
+
function fail(message) {
|
|
442
|
+
console.error(message);
|
|
443
|
+
process.exit.bind(process)(1);
|
|
444
|
+
throw new ConfigStructureExit(message);
|
|
445
|
+
}
|
|
446
|
+
function readConsumerSource(configPath) {
|
|
447
|
+
try {
|
|
448
|
+
return readFileSync(configPath, "utf8");
|
|
449
|
+
} catch (readError) {
|
|
450
|
+
const { message } = readError;
|
|
451
|
+
return fail(`@useinsider/eslint-config: failed to read consumer config at ${configPath}: ${message}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
var lazyRequire = createRequire(import.meta.url);
|
|
455
|
+
function loadParser() {
|
|
456
|
+
return lazyRequire("@typescript-eslint/parser").parse;
|
|
457
|
+
}
|
|
458
|
+
function parseConsumerSource(configPath, source) {
|
|
459
|
+
const parse = loadParser();
|
|
460
|
+
try {
|
|
461
|
+
return parse(source, {
|
|
462
|
+
sourceType: "module",
|
|
463
|
+
range: true,
|
|
464
|
+
loc: true
|
|
465
|
+
});
|
|
466
|
+
} catch (parseError) {
|
|
467
|
+
const { message } = parseError;
|
|
468
|
+
return fail(`@useinsider/eslint-config: failed to parse consumer config at ${configPath}: ${message}`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function runValidation(overridePath) {
|
|
472
|
+
const configPath = overridePath === void 0 ? getConsumerConfigPath() : overridePath;
|
|
473
|
+
if (!configPath) fail(["@useinsider/eslint-config: unable to locate consumer `eslint.config.*` file for structure validation.", "If this is an unexpected environment, set INSIDER_SKIP_CONFIG_VALIDATION=true (do not commit)."].join("\n"));
|
|
474
|
+
const violations = validateProgramStructure(parseConsumerSource(configPath, readConsumerSource(configPath)), configPath);
|
|
475
|
+
if (violations.length === 0) return;
|
|
476
|
+
fail(formatReport(configPath, violations));
|
|
477
|
+
}
|
|
478
|
+
function ensureConfigStructure(overridePath) {
|
|
479
|
+
if (process.env[OPT_OUT_ENV] === "true") {
|
|
480
|
+
emitBypassWarning();
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
runValidation(overridePath);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
if (error instanceof ConfigStructureExit) return;
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
10
491
|
//#region src/utils/ensureDependencies.ts
|
|
11
492
|
var turnOff = false;
|
|
12
493
|
var scanned = false;
|
|
@@ -96,62 +577,57 @@ function filterSilencedRules(rules, silencedRules) {
|
|
|
96
577
|
}
|
|
97
578
|
//#endregion
|
|
98
579
|
//#region src/main.ts
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
130
|
-
async "vue2-typescript"() {
|
|
131
|
-
return import("./vue2-typescript-CUqjxRHT.js");
|
|
132
|
-
},
|
|
133
|
-
async jest() {
|
|
134
|
-
return import("./jest-B0jgh-Ns.js");
|
|
135
|
-
},
|
|
136
|
-
async "jsdoc-based-ts"() {
|
|
137
|
-
return import("./jsdoc-based-ts-B40HFdNC.js");
|
|
138
|
-
},
|
|
139
|
-
async strict() {
|
|
140
|
-
return import("./strict-BfeS2xp_.js");
|
|
141
|
-
}
|
|
142
|
-
};
|
|
580
|
+
var reservedKeys = new Set([
|
|
581
|
+
"ignores",
|
|
582
|
+
"jquery",
|
|
583
|
+
"strict",
|
|
584
|
+
"spellChecker",
|
|
585
|
+
"silenceRules",
|
|
586
|
+
"configFiles"
|
|
587
|
+
]);
|
|
588
|
+
function isProcessableScopeKey(key) {
|
|
589
|
+
return !reservedKeys.has(key) && isScopeName(key);
|
|
590
|
+
}
|
|
591
|
+
async function collectScopeBlocks(config) {
|
|
592
|
+
return Object.keys(config).filter(isProcessableScopeKey).reduce(async (accumulator, key) => {
|
|
593
|
+
const blocks = await accumulator;
|
|
594
|
+
const entries = config[key];
|
|
595
|
+
if (!entries || entries.length === 0) return blocks;
|
|
596
|
+
const scopeBlocks = await buildScopeBlocks(key, entries);
|
|
597
|
+
return [...blocks, ...scopeBlocks];
|
|
598
|
+
}, Promise.resolve([]));
|
|
599
|
+
}
|
|
600
|
+
function applySilenceRules(blocks, perCallSilence) {
|
|
601
|
+
blocks.forEach((block) => {
|
|
602
|
+
if (!block.rules) return;
|
|
603
|
+
block.rules = perCallSilence ? filterSilencedRules(block.rules, perCallSilence) : filterSilencedRules(block.rules);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function buildIgnoresBlocks(ignores) {
|
|
607
|
+
if (!ignores || ignores.length === 0) return [];
|
|
608
|
+
return [{ ignores: [...ignores] }];
|
|
609
|
+
}
|
|
143
610
|
async function useInsider(config) {
|
|
611
|
+
ensureConfigStructure();
|
|
144
612
|
await ensureDependencies();
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
613
|
+
const ignoresBlocks = buildIgnoresBlocks(config.ignores);
|
|
614
|
+
const scopeBlocks = await collectScopeBlocks(config);
|
|
615
|
+
const jqueryBlocks = buildJqueryBlocks(config.jquery);
|
|
616
|
+
const configFilesBlocks = buildConfigFilesBlocks(config.configFiles);
|
|
617
|
+
const strictBlocks = await buildStrictBlocks(config.strict);
|
|
618
|
+
const spellCheckerBlocks = buildSpellCheckerBlocks(config.spellChecker);
|
|
619
|
+
const blocks = [
|
|
620
|
+
...ignoresBlocks,
|
|
621
|
+
...scopeBlocks,
|
|
622
|
+
...jqueryBlocks,
|
|
623
|
+
...configFilesBlocks,
|
|
624
|
+
...strictBlocks,
|
|
625
|
+
...spellCheckerBlocks
|
|
626
|
+
];
|
|
627
|
+
applySilenceRules(blocks, config.silenceRules);
|
|
628
|
+
return defineConfig(blocks);
|
|
153
629
|
}
|
|
154
630
|
//#endregion
|
|
155
|
-
export { merge, mergeAll, silenceDependencyWarning, silenceRules, useInsider };
|
|
631
|
+
export { ensureConfigStructure, merge, mergeAll, silenceDependencyWarning, silenceRules, useInsider };
|
|
156
632
|
|
|
157
633
|
//# sourceMappingURL=main.js.map
|