@starci/eslint-canon-be 3.27.3 → 3.28.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/CHANGELOG.md +5 -0
- package/dist/default-deny.js +1 -1
- package/dist/entity-base.d.ts +1 -1
- package/dist/entity-base.js +1 -1
- package/dist/event-bus-lite.js +1 -4
- package/dist/function-budget.d.ts +1 -1
- package/dist/function-budget.js +1 -1
- package/dist/index.js +2 -3
- package/dist/jobs-scheduler.d.ts +1 -1
- package/dist/jobs-scheduler.js +1 -1
- package/dist/lib/hfs-view.d.ts +0 -1
- package/dist/module-layering.js +1 -1
- package/dist/no-raw-sql.js +0 -1
- package/dist/query-safety.d.ts +0 -6
- package/dist/query-safety.js +6 -69
- package/package.json +4 -4
- package/dist/lib/edition.d.ts +0 -24
- package/dist/lib/edition.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.28.0 - 2026-11-20
|
|
4
|
+
|
|
5
|
+
- Changed: one app edition (R212, owner ruling 2026-11-20). The edition gate (`pluginForEdition`) is gone: every rule of the plugin runs for every app. Requires @starci/hfs ~6.14.0.
|
|
6
|
+
- Removed: `sql-text-only` and `no-query-builder` (R36 BE_SQL_OUTSIDE_PERSISTENCE, a full-only rule no app ran); R334 `no-raw-sql` holds the persistence boundary. `event-bus-lite-shape` and the lite entity list of `module-layering` judge every app.
|
|
7
|
+
|
|
3
8
|
## 3.27.3 - 2026-11-18
|
|
4
9
|
|
|
5
10
|
- Fixed (`no-raw-sql`): the nivoos SDK's typed object read, `reach.objects(Type).query({ where, sort, limit })`, is no SQL: a `.query(` whose receiver is an `.objects(...)` call, in a file that imports `@starci/nivoos-sdk`, passes. Any other `.query(` in that file is still refused.
|
package/dist/default-deny.js
CHANGED
|
@@ -163,7 +163,7 @@ export const publicNeedsReason = {
|
|
|
163
163
|
export const publicReasonClosed = {
|
|
164
164
|
meta: {
|
|
165
165
|
type: "problem",
|
|
166
|
-
docs: { description: "`PublicReason` is closed to Health, AuthHandshake, SignedWebhook and CatalogRead
|
|
166
|
+
docs: { description: "`PublicReason` is closed to Health, AuthHandshake, SignedWebhook and CatalogRead." },
|
|
167
167
|
schema: [],
|
|
168
168
|
messages: {
|
|
169
169
|
closed: "BE_PUBLIC_REASON_CLOSED: `PublicReason` has exactly Health, AuthHandshake, SignedWebhook and CatalogRead. An API-key or tool-token route authenticates with its own guard; do not add a public reason.",
|
package/dist/entity-base.d.ts
CHANGED
package/dist/entity-base.js
CHANGED
|
@@ -113,5 +113,5 @@ export const entityExtendsBase = {
|
|
|
113
113
|
};
|
|
114
114
|
/** The rules of the entity-base law, by name. */
|
|
115
115
|
export const rules = { "entity-extends-base": entityExtendsBase };
|
|
116
|
-
/** On at error
|
|
116
|
+
/** On at error. */
|
|
117
117
|
export const recommended = { "starci-be/entity-extends-base": "error" };
|
package/dist/event-bus-lite.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hfsOf } from "./lib/hfs.js";
|
|
2
1
|
/** The public entry of the event bus capability. */
|
|
3
2
|
const EVENT_BUS_MODULE = "@modules/platform/event-bus";
|
|
4
3
|
/** The base class every typed event extends. */
|
|
@@ -72,7 +71,7 @@ export const eventDedupeKey = {
|
|
|
72
71
|
},
|
|
73
72
|
},
|
|
74
73
|
create(context) {
|
|
75
|
-
if (
|
|
74
|
+
if (!EVENT_FILE.test(context.filename))
|
|
76
75
|
return {};
|
|
77
76
|
let declarations = new Map();
|
|
78
77
|
const judge = (node) => {
|
|
@@ -101,8 +100,6 @@ export const eventSubscriptionStatic = {
|
|
|
101
100
|
},
|
|
102
101
|
},
|
|
103
102
|
create(context) {
|
|
104
|
-
if (hfsOf(context).edition !== "lite")
|
|
105
|
-
return {};
|
|
106
103
|
const topicQueues = new Set();
|
|
107
104
|
let importsBus = false;
|
|
108
105
|
const literalOptions = (node) => node.type === "ObjectExpression" && node.properties.every((property) => property.type === "Property" && !property.computed && property.value.type === "Literal");
|
|
@@ -3,5 +3,5 @@ import type { Recommended, RuleModule, Rules } from "./lib/rule.js";
|
|
|
3
3
|
export declare const functionLineBudget: RuleModule;
|
|
4
4
|
/** The rule this law contributes to the plugin. */
|
|
5
5
|
export declare const rules: Rules;
|
|
6
|
-
/** The function budget is an error
|
|
6
|
+
/** The function budget is an error. */
|
|
7
7
|
export declare const recommended: Recommended;
|
package/dist/function-budget.js
CHANGED
|
@@ -42,5 +42,5 @@ export const functionLineBudget = {
|
|
|
42
42
|
};
|
|
43
43
|
/** The rule this law contributes to the plugin. */
|
|
44
44
|
export const rules = { "function-line-budget": functionLineBudget };
|
|
45
|
-
/** The function budget is an error
|
|
45
|
+
/** The function budget is an error. */
|
|
46
46
|
export const recommended = { "starci-be/function-line-budget": "error" };
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { extEslintConfigs } from "@starci/hfs/runtime/scripts/lib/project-ext.mjs";
|
|
20
20
|
import { buildBeConfig, buildBePackagesConfig } from "./lib/config.js";
|
|
21
|
-
import { pluginForEdition } from "./lib/edition.js";
|
|
22
21
|
import { recommended as aiGatewayRecommended, rules as aiGatewayRules } from "./ai-gateway.js";
|
|
23
22
|
import { recommended as authPassportRecommended, rules as authPassportRules } from "./auth-passport.js";
|
|
24
23
|
import { recommended as noRawSqlRecommended, rules as noRawSqlRules } from "./no-raw-sql.js";
|
|
@@ -182,7 +181,7 @@ export default plugin;
|
|
|
182
181
|
* @returns The flat config.
|
|
183
182
|
*/
|
|
184
183
|
export const starciBeConfig = async ({ hfs }) => [
|
|
185
|
-
...(await buildBeConfig({ hfs, plugin
|
|
184
|
+
...(await buildBeConfig({ hfs, plugin, recommended })),
|
|
186
185
|
...withExtRules(hfs, "be"),
|
|
187
186
|
];
|
|
188
187
|
/**
|
|
@@ -204,7 +203,7 @@ const packageRecommended = Object.fromEntries(Object.entries(recommended).filter
|
|
|
204
203
|
* @returns The flat config.
|
|
205
204
|
*/
|
|
206
205
|
export const starciBePackagesConfig = async ({ hfs }) => [
|
|
207
|
-
...(await buildBePackagesConfig({ hfs, plugin
|
|
206
|
+
...(await buildBePackagesConfig({ hfs, plugin, recommended: packageRecommended })),
|
|
208
207
|
...withExtRules(hfs, "packages"),
|
|
209
208
|
];
|
|
210
209
|
export { linterOptions } from "./lib/config.js";
|
package/dist/jobs-scheduler.d.ts
CHANGED
package/dist/jobs-scheduler.js
CHANGED
|
@@ -81,5 +81,5 @@ export const jobsSchedulerOwner = {
|
|
|
81
81
|
};
|
|
82
82
|
/** The rule of the tick scheduler law, by name. */
|
|
83
83
|
export const rules = { "jobs-scheduler-owner": jobsSchedulerOwner };
|
|
84
|
-
/** On at error
|
|
84
|
+
/** On at error. */
|
|
85
85
|
export const recommended = { "starci-be/jobs-scheduler-owner": "error" };
|
package/dist/lib/hfs-view.d.ts
CHANGED
|
@@ -151,7 +151,6 @@ export interface HfsView {
|
|
|
151
151
|
readonly repoRoot: string;
|
|
152
152
|
readonly profile: string;
|
|
153
153
|
readonly side: string | null;
|
|
154
|
-
readonly edition: string;
|
|
155
154
|
readonly grammar?: string;
|
|
156
155
|
readonly apps: readonly HfsApp[];
|
|
157
156
|
readonly connections?: readonly HfsConnection[];
|
package/dist/module-layering.js
CHANGED
|
@@ -183,7 +183,7 @@ export const noFolderReexport = {
|
|
|
183
183
|
create(context) {
|
|
184
184
|
const filename = context.filename || context.getFilename();
|
|
185
185
|
const hfs = hfsOf(context);
|
|
186
|
-
const isIndex = isIndexFile(filename) && !
|
|
186
|
+
const isIndex = isIndexFile(filename) && !LITE_ENTITY_LIST.test(hfs.relative(filename));
|
|
187
187
|
const max = indexExportBudget(hfs, filename);
|
|
188
188
|
let count = 0;
|
|
189
189
|
return {
|
package/dist/no-raw-sql.js
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
* pg built-ins, bare, plus every other function schema-qualified, including hfs.json `sides.be.dbFunctions`).
|
|
20
20
|
* - `builder`: a query builder names its entity (`createQueryBuilder(Entity, "alias")`); a builder over a table-name string, a
|
|
21
21
|
* builder with no entity, and a `getRepository(...)` are refused (the world excepted).
|
|
22
|
-
* The rule runs in lite only (the catalog's `editions`); full keeps R36.
|
|
23
22
|
*
|
|
24
23
|
* Schema authority stays `db/migrations/*.sql`; whether the entities match it is `BE_ENTITY_SCHEMA_DRIFT` of `starci app db drift`.
|
|
25
24
|
*/
|
package/dist/query-safety.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
-
/** SQL text is `SqlText`, and only a persistence `.sql.ts` builds it. */
|
|
3
|
-
export declare const sqlTextOnly: RuleModule;
|
|
4
|
-
/** There is one way to write a complex read, and it is SQL. */
|
|
5
|
-
export declare const noQueryBuilder: RuleModule;
|
|
6
2
|
/** A statement is text plus parameters; a value never becomes part of the text. */
|
|
7
3
|
export declare const noInterpolatedSql: RuleModule;
|
|
8
4
|
/** A list read states its bound. */
|
|
@@ -11,8 +7,6 @@ export declare const queryNeedsLimit: RuleModule;
|
|
|
11
7
|
export declare const noQueryInLoop: RuleModule;
|
|
12
8
|
/** The rules this law contributes to the plugin. */
|
|
13
9
|
export declare const rules: {
|
|
14
|
-
"sql-text-only": RuleModule;
|
|
15
|
-
"no-query-builder": RuleModule;
|
|
16
10
|
"no-interpolated-sql": RuleModule;
|
|
17
11
|
"query-needs-limit": RuleModule;
|
|
18
12
|
"no-query-in-loop": RuleModule;
|
package/dist/query-safety.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The rules that keep a database call safe to run in production (
|
|
2
|
+
* The rules that keep a database call safe to run in production (R68, R69, R77).
|
|
3
3
|
*
|
|
4
4
|
* SQL text is a `SqlText` constant built with the `sql` tag in a persistence `<name>.sql.ts`; a dynamic identifier is a
|
|
5
5
|
* `SqlIdent` from `ident()`; a value is a numbered parameter. Every receiver is identified by its TypeScript type
|
|
@@ -7,12 +7,9 @@
|
|
|
7
7
|
* HFS slot view. No rule here parses SQL text: what a statement reads and writes is judged by the architecture
|
|
8
8
|
* machine (R86).
|
|
9
9
|
*
|
|
10
|
-
* - `sql-text-only` (R36 `BE_SQL_OUTSIDE_PERSISTENCE`) - the first argument of `.query(` is a `SqlText`, and the `sql`
|
|
11
|
-
* tag is called only in a persistence `<name>.sql.ts`.
|
|
12
|
-
* - `no-query-builder` (R36) - no `createQueryBuilder(` call.
|
|
13
10
|
* - `no-interpolated-sql` (R68 `BE_SQL_INTERPOLATED`) - a substitution inside the `sql` tag is a `SqlIdent`; a `.query(`
|
|
14
|
-
* string built by template or concatenation is refused. One file is the owner R334 names for the
|
|
15
|
-
* `platform/database/database.client.ts` of
|
|
11
|
+
* string built by template or concatenation is refused. One file is the owner R334 names for the call and LISTEN statements,
|
|
12
|
+
* `platform/database/database.client.ts` of an app: there a `.query(` template may substitute only the checked parts its own
|
|
16
13
|
* validator brands (`DbFunctionPart`, `DbParameterList` declared in that file); any other substitution, a `+` and the same
|
|
17
14
|
* template in any other file stay refused.
|
|
18
15
|
* - `query-needs-limit` (R69 `BE_QUERY_UNBOUNDED`) - `find`, `findBy` and `findAndCount` on an `EntityManager` carry `take`.
|
|
@@ -38,68 +35,12 @@ const hasBrand = (context, hfs, node, name) => typeOrigins(context, node).some((
|
|
|
38
35
|
/** Whether a call goes through `.query` on a manager, runner or data source. */
|
|
39
36
|
const isQueryCall = (context, node) => calleeProperty(node) === "query" && node.callee.type === "MemberExpression" && infraTypeOf(context, node.callee.object) !== null;
|
|
40
37
|
// -- R36 -----------------------------------------------------------------------------------------------
|
|
41
|
-
/**
|
|
42
|
-
export const sqlTextOnly = {
|
|
43
|
-
meta: {
|
|
44
|
-
type: "problem",
|
|
45
|
-
docs: { description: "`.query(...)` takes a `SqlText`, and the `sql` tag is called only in a persistence `<name>.sql.ts`." },
|
|
46
|
-
schema: [],
|
|
47
|
-
messages: {
|
|
48
|
-
notSqlText: "The first argument of `.query(...)` is not a `SqlText`. SQL text is a constant built with the `sql` tag in the `persistence/<name>.sql.ts` of the owning capability and imported here; the row shape and its mapper live in `<name>.rows.ts`.",
|
|
49
|
-
tagOutsideSqlFile: "The `sql` tag is called outside a persistence `<name>.sql.ts`. Write the statement as an exported constant in the `persistence/<name>.sql.ts` of the capability that owns the tables, and import it.",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
create(context) {
|
|
53
|
-
const hfs = hfsOf(context);
|
|
54
|
-
const filename = context.filename || context.getFilename();
|
|
55
|
-
const migration = isMigrationFile(hfs, filename);
|
|
56
|
-
const sqlFile = hfs.slotOf(filename) === "be.persistence" && baseNameOf(filename).endsWith(".sql.ts");
|
|
57
|
-
const isSqlTag = (node) => typeOrigins(context, node).some((origin) => origin.name === "sql" && fromDatabaseCapability(hfs, origin));
|
|
58
|
-
return {
|
|
59
|
-
CallExpression(node) {
|
|
60
|
-
if (isSqlTag(node.callee) && !sqlFile)
|
|
61
|
-
context.report({ node, messageId: "tagOutsideSqlFile" });
|
|
62
|
-
if (migration || !isQueryCall(context, node))
|
|
63
|
-
return;
|
|
64
|
-
const first = node.arguments[0];
|
|
65
|
-
if (!first || !hasBrand(context, hfs, first, "SqlText"))
|
|
66
|
-
context.report({ node: first ?? node, messageId: "notSqlText" });
|
|
67
|
-
},
|
|
68
|
-
TaggedTemplateExpression(node) {
|
|
69
|
-
if (isSqlTag(node.tag) && !sqlFile)
|
|
70
|
-
context.report({ node, messageId: "tagOutsideSqlFile" });
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
/** There is one way to write a complex read, and it is SQL. */
|
|
76
|
-
export const noQueryBuilder = {
|
|
77
|
-
meta: {
|
|
78
|
-
type: "problem",
|
|
79
|
-
docs: { description: "No `createQueryBuilder(...)` call." },
|
|
80
|
-
schema: [],
|
|
81
|
-
messages: {
|
|
82
|
-
builder: "`createQueryBuilder(...)` is banned. A read is `manager.find(Entity, { where, take })`, or a `SqlText` constant in the capability's `persistence/<name>.sql.ts` run with `manager.query(...)`.",
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
create(context) {
|
|
86
|
-
return {
|
|
87
|
-
CallExpression(node) {
|
|
88
|
-
const callee = node.callee;
|
|
89
|
-
const name = callee.type === "Identifier" ? callee.name : calleeProperty(node);
|
|
90
|
-
if (name === "createQueryBuilder")
|
|
91
|
-
context.report({ node, messageId: "builder" });
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
// -- R68 -----------------------------------------------------------------------------------------------
|
|
97
|
-
/** The one file R334 names as the composer of a lite function-call statement: `platform/database/database.client.ts`. */
|
|
38
|
+
/** The one file R334 names as the composer of a function-call statement: `platform/database/database.client.ts`. */
|
|
98
39
|
const CALL_STATEMENT_FILE = "database.client.ts";
|
|
99
40
|
/** The brands the call-statement file gives the checked parts it splices: a function-name part and a numbered parameter list. */
|
|
100
41
|
const CALL_STATEMENT_BRANDS = ["DbFunctionPart", "DbParameterList"];
|
|
101
|
-
/** Whether a file is the
|
|
102
|
-
const isCallStatementFile = (hfs, filename) =>
|
|
42
|
+
/** Whether a file is the call-statement owner of the platform database capability. */
|
|
43
|
+
const isCallStatementFile = (hfs, filename) => baseNameOf(filename) === CALL_STATEMENT_FILE && inDatabaseCapability(hfs, filename);
|
|
103
44
|
/** Whether a substitution has a brand the call-statement file itself declares for the parts it checked. */
|
|
104
45
|
const isCheckedCallPart = (context, hfs, node) => typeOrigins(context, node).some((origin) => CALL_STATEMENT_BRANDS.includes(origin.name) && isCallStatementFile(hfs, origin.file));
|
|
105
46
|
/** A statement is text plus parameters; a value never becomes part of the text. */
|
|
@@ -222,16 +163,12 @@ export const noQueryInLoop = {
|
|
|
222
163
|
};
|
|
223
164
|
/** The rules this law contributes to the plugin. */
|
|
224
165
|
export const rules = {
|
|
225
|
-
"sql-text-only": sqlTextOnly,
|
|
226
|
-
"no-query-builder": noQueryBuilder,
|
|
227
166
|
"no-interpolated-sql": noInterpolatedSql,
|
|
228
167
|
"query-needs-limit": queryNeedsLimit,
|
|
229
168
|
"no-query-in-loop": noQueryInLoop,
|
|
230
169
|
};
|
|
231
170
|
/** Every rule of this law ships at `error`; no baseline exists. */
|
|
232
171
|
export const recommended = {
|
|
233
|
-
"starci-be/sql-text-only": "error",
|
|
234
|
-
"starci-be/no-query-builder": "error",
|
|
235
172
|
"starci-be/no-interpolated-sql": "error",
|
|
236
173
|
"starci-be/query-needs-limit": "error",
|
|
237
174
|
"starci-be/no-query-in-loop": "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-canon-be",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=22.13.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@starci/hfs": "~6.
|
|
43
|
+
"@starci/hfs": "~6.14.0",
|
|
44
44
|
"eslint": ">=9",
|
|
45
45
|
"typescript": ">=5.9"
|
|
46
46
|
},
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"typescript": "^6.0.3"
|
|
75
75
|
},
|
|
76
76
|
"types": "./dist/index.d.ts",
|
|
77
|
-
"gitHead": "
|
|
78
|
-
"starciSource": "
|
|
77
|
+
"gitHead": "0bf97f870be00547f1058f9418c2f675f6e0c74d",
|
|
78
|
+
"starciSource": "0a9b528f5c9a11c82de0989c2bdbe4bf792c5e14d0d4842b37056992a49dc0ff"
|
|
79
79
|
}
|
package/dist/lib/edition.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The edition gate of the back-end plugin.
|
|
3
|
-
*
|
|
4
|
-
* Edition applicability belongs to the HFS rule catalog, beside the law and its enforcer. A rule
|
|
5
|
-
* that the catalog does not judge in this app's edition still ships in the plugin, but its `create`
|
|
6
|
-
* returns no listeners. The plugin wiring therefore has one generic gate instead of edition checks
|
|
7
|
-
* scattered through rule bodies.
|
|
8
|
-
*/
|
|
9
|
-
import { type RuleCatalog } from "@starci/hfs/runtime/scripts/hfs/rule-catalog.mjs";
|
|
10
|
-
import type { CanonPlugin } from "./config.js";
|
|
11
|
-
/**
|
|
12
|
-
* The plugin view for one HFS edition.
|
|
13
|
-
*
|
|
14
|
-
* Both editions read the catalog: full is the default edition, and a rule whose catalog entries name only lite (R334
|
|
15
|
-
* `no-raw-sql`) is inactive there, as a full-only rule is in lite. The bundled catalog is loaded once per lint process;
|
|
16
|
-
* tests may inject a catalog to prove the generic filtering independently of the bundled copy.
|
|
17
|
-
*/
|
|
18
|
-
export declare const pluginForEdition: <P extends CanonPlugin>({ plugin, hfs, catalog }: {
|
|
19
|
-
plugin: P;
|
|
20
|
-
hfs?: {
|
|
21
|
-
readonly edition?: string;
|
|
22
|
-
} | null | undefined;
|
|
23
|
-
catalog?: Pick<RuleCatalog, "enforcerJudgedIn"> | undefined;
|
|
24
|
-
}) => P;
|
package/dist/lib/edition.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The edition gate of the back-end plugin.
|
|
3
|
-
*
|
|
4
|
-
* Edition applicability belongs to the HFS rule catalog, beside the law and its enforcer. A rule
|
|
5
|
-
* that the catalog does not judge in this app's edition still ships in the plugin, but its `create`
|
|
6
|
-
* returns no listeners. The plugin wiring therefore has one generic gate instead of edition checks
|
|
7
|
-
* scattered through rule bodies.
|
|
8
|
-
*/
|
|
9
|
-
import { loadRuleCatalog } from "@starci/hfs/runtime/scripts/hfs/rule-catalog.mjs";
|
|
10
|
-
import { RUNTIME_ROOT as RUNTIME } from "./runtime-root.js";
|
|
11
|
-
let catalogCache;
|
|
12
|
-
/** The bundled rule catalog, loaded once per lint process. */
|
|
13
|
-
const bundledCatalog = () => {
|
|
14
|
-
catalogCache ??= loadRuleCatalog({ root: RUNTIME });
|
|
15
|
-
return catalogCache;
|
|
16
|
-
};
|
|
17
|
-
/** A rule which intentionally registers no listeners in this edition. */
|
|
18
|
-
const inactive = (rule) => Object.freeze({ ...rule, create: () => ({}) });
|
|
19
|
-
/**
|
|
20
|
-
* The plugin view for one HFS edition.
|
|
21
|
-
*
|
|
22
|
-
* Both editions read the catalog: full is the default edition, and a rule whose catalog entries name only lite (R334
|
|
23
|
-
* `no-raw-sql`) is inactive there, as a full-only rule is in lite. The bundled catalog is loaded once per lint process;
|
|
24
|
-
* tests may inject a catalog to prove the generic filtering independently of the bundled copy.
|
|
25
|
-
*/
|
|
26
|
-
export const pluginForEdition = ({ plugin, hfs, catalog }) => {
|
|
27
|
-
const edition = hfs?.edition === undefined ? "full" : hfs.edition;
|
|
28
|
-
if (edition !== "full" && edition !== "lite") {
|
|
29
|
-
throw new RangeError(`Unknown HFS edition ${JSON.stringify(edition)}; expected "full" or "lite"`);
|
|
30
|
-
}
|
|
31
|
-
const loaded = catalog ?? bundledCatalog();
|
|
32
|
-
const rules = Object.fromEntries(Object.entries(plugin.rules).map(([id, rule]) => [
|
|
33
|
-
id,
|
|
34
|
-
loaded.enforcerJudgedIn("eslint-be", id, edition) ? rule : inactive(rule),
|
|
35
|
-
]));
|
|
36
|
-
return Object.freeze({ ...plugin, rules: Object.freeze(rules) });
|
|
37
|
-
};
|