@useinsider/eslint-config 1.5.0-beta.2 → 1.5.0-beta.3
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/main.cjs +2 -2
- package/dist/main.js +53 -32
- package/package.json +2 -2
package/dist/main.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:fs"),m=require("node:path"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:fs"),m=require("node:path"),y=require("node:url"),w=require("@antfu/install-pkg"),h=require("ts-deepmerge"),b=require("node:console");var o=typeof document<"u"?document.currentScript:null;let u=!1;const d=new Set,v=["@cspell/eslint-plugin","@eslint/eslintrc","@eslint/js","@stylistic/eslint-plugin","@stylistic/eslint-plugin-migrate","@types/eslint","@types/eslint__eslintrc","@types/eslint__js","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","eslint","eslint-config-airbnb-base","eslint-config-airbnb-typescript","eslint-import-resolver-typescript","eslint-plugin-import","eslint-plugin-jsdoc","globals","ts-deepmerge","typescript","typescript-eslint"];function p(e){const n=m.resolve(e,"package.json"),r=g.readFileSync(n,"utf8");if(!r)throw new Error(`Unable to locate package.json: ${n}`);return JSON.parse(r)}function R(){const e=p(process.cwd());return{...e.dependencies,...e.devDependencies}}function S(){return p(y.fileURLToPath(new URL("../",typeof document>"u"?require("url").pathToFileURL(__filename).href:o&&o.src||new URL("main.cjs",document.baseURI).href))).dependencies}async function k(){if(u)return;const e=R(),r=Object.entries(S()).filter(([s,i])=>v.includes(s)&&!d.has(s)&&(!e[s]||e[s]!==i));if(!r.length)return;const t=r.map(([s,i])=>`${s}@${i.replace(/^\W+/,"")}`);console.info("Missing dependencies detected:"),console.info(t.map(s=>` - ${s}`).join(`
|
|
2
2
|
`)),console.info(`
|
|
3
|
-
Installing dependencies:`),await
|
|
3
|
+
Installing dependencies:`),await w.installPackage(t,{dev:!0,additionalArgs:["-E"]}),process.exit(1)}function q(e){if(typeof e=="boolean"){u=!0;return}e.forEach(n=>d.add(String(n)))}function l(...e){return h.merge.withOptions({mergeArrays:!1},...e)}const f=new Set;function x(e){e.forEach(n=>{f.add(n)})}function P(e){if(!Array.isArray(e))return"warn";const[,...n]=e;return["warn",...n]}function c(e,n){let r=n||f;return Array.isArray(r)&&(r=new Set(r)),!e||!r.size?e:(n&&r.forEach(t=>{e[t]||b.warn(`Unknown rule "${t}". Please remove it from the silenced rules list.`)}),Object.entries(e).reduce((t,[s,i])=>(i&&(t[s]=r.has(s)?P(i):i),t),{}))}function j(...e){return e.flat().reduce((n,r)=>l(n,r),{})}const a={async config(){return Promise.resolve().then(()=>require("./index-CAuGyIr4.cjs"))},async javascript(){return Promise.resolve().then(()=>require("./index-DI_UoSW4.cjs"))},async"javascript-node"(){return Promise.resolve().then(()=>require("./index-COJ71EEW.cjs"))},async"javascript-dom"(){return Promise.resolve().then(()=>require("./index-B45cvr6O.cjs"))},async typescript(){return Promise.resolve().then(()=>require("./index-CCngt07f.cjs"))},async"typescript-node"(){return Promise.resolve().then(()=>require("./index-CZG4LLz1.cjs"))},async"typescript-dom"(){return Promise.resolve().then(()=>require("./index-ZUN0xFSs.cjs"))},async vue3(){return Promise.resolve().then(()=>require("./index-BPS1S4-r.cjs"))},async"vue3-typescript"(){return Promise.resolve().then(()=>require("./index-Brj-OnR2.cjs"))},async vue2(){return Promise.resolve().then(()=>require("./index-DLjVlGbl.cjs"))}};async function D(e){await k();const n=e.preset.map(async s=>typeof a[s]=="function"&&(await a[s]()).default).filter(Boolean),r=await Promise.all(n),t=l(r.reduce((s,i)=>l(s,i),{}),e.config);return t?(e.silenceRules?t.rules=c(t.rules,e.silenceRules):t.rules=c(t.rules),t):Promise.reject(new Error("No config found"))}exports.merge=l;exports.mergeAll=j;exports.silenceDependencyWarning=q;exports.silenceRules=x;exports.useInsider=D;
|
package/dist/main.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import w from "node:fs";
|
|
2
2
|
import y from "node:path";
|
|
3
3
|
import { fileURLToPath as h } from "node:url";
|
|
4
4
|
import { installPackage as b } from "@antfu/install-pkg";
|
|
5
5
|
import { merge as v } from "ts-deepmerge";
|
|
6
|
-
import { warn as
|
|
6
|
+
import { warn as j } from "node:console";
|
|
7
7
|
let d = !1;
|
|
8
|
-
const f = /* @__PURE__ */ new Set()
|
|
8
|
+
const f = /* @__PURE__ */ new Set(), S = [
|
|
9
|
+
"@cspell/eslint-plugin",
|
|
10
|
+
"@eslint/eslintrc",
|
|
11
|
+
"@eslint/js",
|
|
12
|
+
"@stylistic/eslint-plugin",
|
|
13
|
+
"@stylistic/eslint-plugin-migrate",
|
|
14
|
+
"@types/eslint",
|
|
15
|
+
"@types/eslint__eslintrc",
|
|
16
|
+
"@types/eslint__js",
|
|
17
|
+
"@typescript-eslint/eslint-plugin",
|
|
18
|
+
"@typescript-eslint/parser",
|
|
19
|
+
"eslint",
|
|
20
|
+
"eslint-config-airbnb-base",
|
|
21
|
+
"eslint-config-airbnb-typescript",
|
|
22
|
+
"eslint-import-resolver-typescript",
|
|
23
|
+
"eslint-plugin-import",
|
|
24
|
+
"eslint-plugin-jsdoc",
|
|
25
|
+
"globals",
|
|
26
|
+
"ts-deepmerge",
|
|
27
|
+
"typescript",
|
|
28
|
+
"typescript-eslint"
|
|
29
|
+
];
|
|
9
30
|
function m(e) {
|
|
10
|
-
const t = y.resolve(e, "package.json"), r =
|
|
31
|
+
const t = y.resolve(e, "package.json"), r = w.readFileSync(t, "utf8");
|
|
11
32
|
if (!r)
|
|
12
33
|
throw new Error(`Unable to locate package.json: ${t}`);
|
|
13
34
|
return JSON.parse(r);
|
|
@@ -19,17 +40,17 @@ function k() {
|
|
|
19
40
|
...e.devDependencies
|
|
20
41
|
};
|
|
21
42
|
}
|
|
22
|
-
function
|
|
43
|
+
function E() {
|
|
23
44
|
return m(h(new URL(
|
|
24
45
|
/* @vite-ignore */
|
|
25
46
|
"../",
|
|
26
47
|
import.meta.url
|
|
27
48
|
))).dependencies;
|
|
28
49
|
}
|
|
29
|
-
async function
|
|
50
|
+
async function D() {
|
|
30
51
|
if (d)
|
|
31
52
|
return;
|
|
32
|
-
const e = k(), r = Object.entries(
|
|
53
|
+
const e = k(), r = Object.entries(E()).filter(([s, o]) => S.includes(s) && !f.has(s) && (!e[s] || e[s] !== o));
|
|
33
54
|
if (!r.length)
|
|
34
55
|
return;
|
|
35
56
|
const n = r.map(([s, o]) => `${s}@${o.replace(/^\W+/, "")}`);
|
|
@@ -37,7 +58,7 @@ async function E() {
|
|
|
37
58
|
`)), console.info(`
|
|
38
59
|
Installing dependencies:`), await b(n, { dev: !0, additionalArgs: ["-E"] }), process.exit(1);
|
|
39
60
|
}
|
|
40
|
-
function
|
|
61
|
+
function $(e) {
|
|
41
62
|
if (typeof e == "boolean") {
|
|
42
63
|
d = !0;
|
|
43
64
|
return;
|
|
@@ -47,34 +68,34 @@ function O(e) {
|
|
|
47
68
|
function u(...e) {
|
|
48
69
|
return v.withOptions({ mergeArrays: !1 }, ...e);
|
|
49
70
|
}
|
|
50
|
-
const
|
|
71
|
+
const a = /* @__PURE__ */ new Set();
|
|
51
72
|
function c(e) {
|
|
52
73
|
e.forEach((t) => {
|
|
53
|
-
|
|
74
|
+
a.add(t);
|
|
54
75
|
});
|
|
55
76
|
}
|
|
56
|
-
function
|
|
77
|
+
function x(e) {
|
|
57
78
|
if (!Array.isArray(e))
|
|
58
79
|
return "warn";
|
|
59
80
|
const [, ...t] = e;
|
|
60
81
|
return ["warn", ...t];
|
|
61
82
|
}
|
|
62
|
-
function
|
|
63
|
-
let r = t ||
|
|
83
|
+
function l(e, t) {
|
|
84
|
+
let r = t || a;
|
|
64
85
|
return Array.isArray(r) && (r = new Set(r)), !e || !r.size ? e : (t && r.forEach((n) => {
|
|
65
|
-
e[n] ||
|
|
66
|
-
}), Object.entries(e).reduce((n, [s, o]) => (o && (n[s] = r.has(s) ?
|
|
86
|
+
e[n] || j(`Unknown rule "${n}". Please remove it from the silenced rules list.`);
|
|
87
|
+
}), Object.entries(e).reduce((n, [s, o]) => (o && (n[s] = r.has(s) ? x(o) : o), n), {}));
|
|
67
88
|
}
|
|
68
89
|
if (import.meta.vitest) {
|
|
69
90
|
const { vi: e, describe: t, test: r, expect: n, afterEach: s } = import.meta.vitest, o = e.hoisted(() => ({
|
|
70
91
|
warn: e.fn()
|
|
71
92
|
}));
|
|
72
93
|
e.mock("node:console", () => o), s(() => {
|
|
73
|
-
|
|
94
|
+
a.clear();
|
|
74
95
|
}), t("silenceRules", () => {
|
|
75
96
|
r("should register given rule keys as silenced", () => {
|
|
76
97
|
const i = "@stylistic/type-generic-spacing";
|
|
77
|
-
n(
|
|
98
|
+
n(a.has(i)).toBe(!1), c([i]), n(a.has(i)).toBe(!0);
|
|
78
99
|
});
|
|
79
100
|
}), t("filterSilencedRules", () => {
|
|
80
101
|
r("should return the same rules object if no rules are silenced", () => {
|
|
@@ -82,9 +103,9 @@ if (import.meta.vitest) {
|
|
|
82
103
|
"no-console": "warn",
|
|
83
104
|
"no-debugger": "warn"
|
|
84
105
|
};
|
|
85
|
-
n(
|
|
106
|
+
n(l(i)).toBe(i);
|
|
86
107
|
}), r("should return a new rules object with silenced rules silenced and other rules unchanged", () => {
|
|
87
|
-
c(["no-console"]), n(
|
|
108
|
+
c(["no-console"]), n(l({
|
|
88
109
|
"no-console": "error",
|
|
89
110
|
"no-debugger": "warn",
|
|
90
111
|
"no-alert": "error"
|
|
@@ -94,7 +115,7 @@ if (import.meta.vitest) {
|
|
|
94
115
|
"no-alert": "error"
|
|
95
116
|
});
|
|
96
117
|
}), r("should return a new rules object with silenced rules silenced and other rules unchanged", () => {
|
|
97
|
-
c(["no-bitwise", "new-cap"]), n(
|
|
118
|
+
c(["no-bitwise", "new-cap"]), n(l({
|
|
98
119
|
"max-len": "off",
|
|
99
120
|
"new-cap": ["error"],
|
|
100
121
|
"no-alert": ["error"],
|
|
@@ -110,13 +131,13 @@ if (import.meta.vitest) {
|
|
|
110
131
|
}]
|
|
111
132
|
});
|
|
112
133
|
}), r("should not warn about unknown rules", () => {
|
|
113
|
-
c(["no-console", "no-bitwise"]),
|
|
134
|
+
c(["no-console", "no-bitwise"]), l({
|
|
114
135
|
"no-console": "error",
|
|
115
136
|
"no-debugger": "warn",
|
|
116
137
|
"no-alert": "error"
|
|
117
138
|
}), n(o.warn).not.toHaveBeenCalled(), n(o.warn).not.toHaveBeenCalled();
|
|
118
139
|
}), r("should warn about unknown rules", () => {
|
|
119
|
-
|
|
140
|
+
l({
|
|
120
141
|
"no-console": "error",
|
|
121
142
|
"no-debugger": "warn",
|
|
122
143
|
"no-alert": "error"
|
|
@@ -125,20 +146,20 @@ if (import.meta.vitest) {
|
|
|
125
146
|
[["@typescript-eslint/no-unsafe-call"], "warn"],
|
|
126
147
|
[/* @__PURE__ */ new Set(["@typescript-eslint/no-unsafe-call"]), "warn"],
|
|
127
148
|
[[], "error"]
|
|
128
|
-
])("#%# should filter scope-related rules and ignore globally silenced rules", (i,
|
|
129
|
-
c(["@typescript-eslint/no-unsafe-assignment"]), n(
|
|
149
|
+
])("#%# should filter scope-related rules and ignore globally silenced rules", (i, g) => {
|
|
150
|
+
c(["@typescript-eslint/no-unsafe-assignment"]), n(l({
|
|
130
151
|
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
131
152
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
132
153
|
"@typescript-eslint/no-unsafe-call": "error"
|
|
133
154
|
}, i)).toStrictEqual({
|
|
134
155
|
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
135
156
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
136
|
-
"@typescript-eslint/no-unsafe-call":
|
|
157
|
+
"@typescript-eslint/no-unsafe-call": g
|
|
137
158
|
});
|
|
138
159
|
});
|
|
139
160
|
});
|
|
140
161
|
}
|
|
141
|
-
function
|
|
162
|
+
function U(...e) {
|
|
142
163
|
return e.flat().reduce((t, r) => u(t, r), {});
|
|
143
164
|
}
|
|
144
165
|
const p = {
|
|
@@ -173,15 +194,15 @@ const p = {
|
|
|
173
194
|
return import("./index-BVRhCxZ-.js");
|
|
174
195
|
}
|
|
175
196
|
};
|
|
176
|
-
async function
|
|
177
|
-
await
|
|
197
|
+
async function H(e) {
|
|
198
|
+
await D();
|
|
178
199
|
const t = e.preset.map(async (s) => typeof p[s] == "function" && (await p[s]()).default).filter(Boolean), r = await Promise.all(t), n = u(r.reduce((s, o) => u(s, o), {}), e.config);
|
|
179
|
-
return n ? (e.silenceRules ? n.rules =
|
|
200
|
+
return n ? (e.silenceRules ? n.rules = l(n.rules, e.silenceRules) : n.rules = l(n.rules), n) : Promise.reject(new Error("No config found"));
|
|
180
201
|
}
|
|
181
202
|
export {
|
|
182
203
|
u as merge,
|
|
183
|
-
|
|
184
|
-
|
|
204
|
+
U as mergeAll,
|
|
205
|
+
$ as silenceDependencyWarning,
|
|
185
206
|
c as silenceRules,
|
|
186
|
-
|
|
207
|
+
H as useInsider
|
|
187
208
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.0-beta.
|
|
4
|
+
"version": "1.5.0-beta.3",
|
|
5
5
|
"description": "A collection of ESLint configurations provided by @useinsider, offering support for various environments including Vanilla JS, TypeScript, and framework-specific setups such as Vue 3.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"useinsider",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"pnpm": ">=9"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
+
"@antfu/install-pkg": "1.0.0",
|
|
70
71
|
"@cspell/eslint-plugin": "8.16.0",
|
|
71
72
|
"@eslint/eslintrc": "3.2.0",
|
|
72
73
|
"@eslint/js": "8.57.1",
|
|
@@ -89,7 +90,6 @@
|
|
|
89
90
|
"typescript-eslint": "8.14.0"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
|
-
"@antfu/install-pkg": "1.0.0",
|
|
93
93
|
"@rollup/plugin-typescript": "11.1.6",
|
|
94
94
|
"@semantic-release/changelog": "6.0.3",
|
|
95
95
|
"@semantic-release/git": "10.0.1",
|