@useinsider/eslint-config 1.5.0-beta.2 → 1.5.0-beta.4
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 +52 -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","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,33 @@
|
|
|
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
|
+
"typescript",
|
|
27
|
+
"typescript-eslint"
|
|
28
|
+
];
|
|
9
29
|
function m(e) {
|
|
10
|
-
const t = y.resolve(e, "package.json"), r =
|
|
30
|
+
const t = y.resolve(e, "package.json"), r = w.readFileSync(t, "utf8");
|
|
11
31
|
if (!r)
|
|
12
32
|
throw new Error(`Unable to locate package.json: ${t}`);
|
|
13
33
|
return JSON.parse(r);
|
|
@@ -19,17 +39,17 @@ function k() {
|
|
|
19
39
|
...e.devDependencies
|
|
20
40
|
};
|
|
21
41
|
}
|
|
22
|
-
function
|
|
42
|
+
function E() {
|
|
23
43
|
return m(h(new URL(
|
|
24
44
|
/* @vite-ignore */
|
|
25
45
|
"../",
|
|
26
46
|
import.meta.url
|
|
27
47
|
))).dependencies;
|
|
28
48
|
}
|
|
29
|
-
async function
|
|
49
|
+
async function D() {
|
|
30
50
|
if (d)
|
|
31
51
|
return;
|
|
32
|
-
const e = k(), r = Object.entries(
|
|
52
|
+
const e = k(), r = Object.entries(E()).filter(([s, o]) => S.includes(s) && !f.has(s) && (!e[s] || e[s] !== o));
|
|
33
53
|
if (!r.length)
|
|
34
54
|
return;
|
|
35
55
|
const n = r.map(([s, o]) => `${s}@${o.replace(/^\W+/, "")}`);
|
|
@@ -37,7 +57,7 @@ async function E() {
|
|
|
37
57
|
`)), console.info(`
|
|
38
58
|
Installing dependencies:`), await b(n, { dev: !0, additionalArgs: ["-E"] }), process.exit(1);
|
|
39
59
|
}
|
|
40
|
-
function
|
|
60
|
+
function $(e) {
|
|
41
61
|
if (typeof e == "boolean") {
|
|
42
62
|
d = !0;
|
|
43
63
|
return;
|
|
@@ -47,34 +67,34 @@ function O(e) {
|
|
|
47
67
|
function u(...e) {
|
|
48
68
|
return v.withOptions({ mergeArrays: !1 }, ...e);
|
|
49
69
|
}
|
|
50
|
-
const
|
|
70
|
+
const a = /* @__PURE__ */ new Set();
|
|
51
71
|
function c(e) {
|
|
52
72
|
e.forEach((t) => {
|
|
53
|
-
|
|
73
|
+
a.add(t);
|
|
54
74
|
});
|
|
55
75
|
}
|
|
56
|
-
function
|
|
76
|
+
function x(e) {
|
|
57
77
|
if (!Array.isArray(e))
|
|
58
78
|
return "warn";
|
|
59
79
|
const [, ...t] = e;
|
|
60
80
|
return ["warn", ...t];
|
|
61
81
|
}
|
|
62
|
-
function
|
|
63
|
-
let r = t ||
|
|
82
|
+
function l(e, t) {
|
|
83
|
+
let r = t || a;
|
|
64
84
|
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) ?
|
|
85
|
+
e[n] || j(`Unknown rule "${n}". Please remove it from the silenced rules list.`);
|
|
86
|
+
}), Object.entries(e).reduce((n, [s, o]) => (o && (n[s] = r.has(s) ? x(o) : o), n), {}));
|
|
67
87
|
}
|
|
68
88
|
if (import.meta.vitest) {
|
|
69
89
|
const { vi: e, describe: t, test: r, expect: n, afterEach: s } = import.meta.vitest, o = e.hoisted(() => ({
|
|
70
90
|
warn: e.fn()
|
|
71
91
|
}));
|
|
72
92
|
e.mock("node:console", () => o), s(() => {
|
|
73
|
-
|
|
93
|
+
a.clear();
|
|
74
94
|
}), t("silenceRules", () => {
|
|
75
95
|
r("should register given rule keys as silenced", () => {
|
|
76
96
|
const i = "@stylistic/type-generic-spacing";
|
|
77
|
-
n(
|
|
97
|
+
n(a.has(i)).toBe(!1), c([i]), n(a.has(i)).toBe(!0);
|
|
78
98
|
});
|
|
79
99
|
}), t("filterSilencedRules", () => {
|
|
80
100
|
r("should return the same rules object if no rules are silenced", () => {
|
|
@@ -82,9 +102,9 @@ if (import.meta.vitest) {
|
|
|
82
102
|
"no-console": "warn",
|
|
83
103
|
"no-debugger": "warn"
|
|
84
104
|
};
|
|
85
|
-
n(
|
|
105
|
+
n(l(i)).toBe(i);
|
|
86
106
|
}), r("should return a new rules object with silenced rules silenced and other rules unchanged", () => {
|
|
87
|
-
c(["no-console"]), n(
|
|
107
|
+
c(["no-console"]), n(l({
|
|
88
108
|
"no-console": "error",
|
|
89
109
|
"no-debugger": "warn",
|
|
90
110
|
"no-alert": "error"
|
|
@@ -94,7 +114,7 @@ if (import.meta.vitest) {
|
|
|
94
114
|
"no-alert": "error"
|
|
95
115
|
});
|
|
96
116
|
}), r("should return a new rules object with silenced rules silenced and other rules unchanged", () => {
|
|
97
|
-
c(["no-bitwise", "new-cap"]), n(
|
|
117
|
+
c(["no-bitwise", "new-cap"]), n(l({
|
|
98
118
|
"max-len": "off",
|
|
99
119
|
"new-cap": ["error"],
|
|
100
120
|
"no-alert": ["error"],
|
|
@@ -110,13 +130,13 @@ if (import.meta.vitest) {
|
|
|
110
130
|
}]
|
|
111
131
|
});
|
|
112
132
|
}), r("should not warn about unknown rules", () => {
|
|
113
|
-
c(["no-console", "no-bitwise"]),
|
|
133
|
+
c(["no-console", "no-bitwise"]), l({
|
|
114
134
|
"no-console": "error",
|
|
115
135
|
"no-debugger": "warn",
|
|
116
136
|
"no-alert": "error"
|
|
117
137
|
}), n(o.warn).not.toHaveBeenCalled(), n(o.warn).not.toHaveBeenCalled();
|
|
118
138
|
}), r("should warn about unknown rules", () => {
|
|
119
|
-
|
|
139
|
+
l({
|
|
120
140
|
"no-console": "error",
|
|
121
141
|
"no-debugger": "warn",
|
|
122
142
|
"no-alert": "error"
|
|
@@ -125,20 +145,20 @@ if (import.meta.vitest) {
|
|
|
125
145
|
[["@typescript-eslint/no-unsafe-call"], "warn"],
|
|
126
146
|
[/* @__PURE__ */ new Set(["@typescript-eslint/no-unsafe-call"]), "warn"],
|
|
127
147
|
[[], "error"]
|
|
128
|
-
])("#%# should filter scope-related rules and ignore globally silenced rules", (i,
|
|
129
|
-
c(["@typescript-eslint/no-unsafe-assignment"]), n(
|
|
148
|
+
])("#%# should filter scope-related rules and ignore globally silenced rules", (i, g) => {
|
|
149
|
+
c(["@typescript-eslint/no-unsafe-assignment"]), n(l({
|
|
130
150
|
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
131
151
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
132
152
|
"@typescript-eslint/no-unsafe-call": "error"
|
|
133
153
|
}, i)).toStrictEqual({
|
|
134
154
|
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
135
155
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
136
|
-
"@typescript-eslint/no-unsafe-call":
|
|
156
|
+
"@typescript-eslint/no-unsafe-call": g
|
|
137
157
|
});
|
|
138
158
|
});
|
|
139
159
|
});
|
|
140
160
|
}
|
|
141
|
-
function
|
|
161
|
+
function U(...e) {
|
|
142
162
|
return e.flat().reduce((t, r) => u(t, r), {});
|
|
143
163
|
}
|
|
144
164
|
const p = {
|
|
@@ -173,15 +193,15 @@ const p = {
|
|
|
173
193
|
return import("./index-BVRhCxZ-.js");
|
|
174
194
|
}
|
|
175
195
|
};
|
|
176
|
-
async function
|
|
177
|
-
await
|
|
196
|
+
async function H(e) {
|
|
197
|
+
await D();
|
|
178
198
|
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 =
|
|
199
|
+
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
200
|
}
|
|
181
201
|
export {
|
|
182
202
|
u as merge,
|
|
183
|
-
|
|
184
|
-
|
|
203
|
+
U as mergeAll,
|
|
204
|
+
$ as silenceDependencyWarning,
|
|
185
205
|
c as silenceRules,
|
|
186
|
-
|
|
206
|
+
H as useInsider
|
|
187
207
|
};
|
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.4",
|
|
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",
|