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