@zukhruf/eslint 0.3.55 → 0.3.57

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 CHANGED
@@ -49,7 +49,8 @@ Put framework presets (for example Nx's `flat/react`) **before** the zukhruf con
49
49
  | `packaged-app` | TypeScript, not tests | `no-bare-spawn` |
50
50
  | `react` | `.tsx`, `.jsx` | `no-as-child` |
51
51
  | `react-router` | source | `require-loader-data-type-argument`; outside tests: `no-raw-route-path`, `no-internal-anchor`; TypeScript: `only-throw-error` allows a `Response` and `DataWithResponseInit` |
52
- | `hono` | TypeScript, not tests | `no-untyped-empty-json` |
52
+ | `hono` | TypeScript, not tests | `no-untyped-empty-json`, `no-http-exception-factory`, `no-catch-around-next` |
53
+ | `better-auth` | TypeScript, not tests | `no-api-error-instanceof`, `no-on-api-error-throw` |
53
54
  | `tailwind` | source | `no-h-screen`, `no-arbitrary-z-index`, `no-will-change` |
54
55
  | `pulumi` | TypeScript | `require-server-replace-guard` |
55
56
  | `nx-project-json` | `project.json` | `no-missing-asset-input` |
@@ -60,6 +61,16 @@ Put framework presets (for example Nx's `flat/react`) **before** the zukhruf con
60
61
 
61
62
  `zukhruf/no-phase-flag` reads each class field's type too. It reports a field that is a boolean, or that can be `undefined`, when code outside the constructor sets it. A callback that the constructor creates runs later, so its assignment counts as outside. Such a field records a phase, and every reader must know which phase holds. Push the fact as an event, wait on a one-shot latch, keep the phases in state objects, or ask the platform for the fact.
62
63
 
64
+ `zukhruf/no-test-lifecycle-hooks` keeps the arrange and the teardown of a test in that test. A hook moves them out, so the reader does not see the full test, and the state that one test leaves can reach the next test. A per-test `t.after()` of node:test also moves the teardown out of the flow of the test. The rule reads the names of the scope, not only the text. It reports a hook from the Vitest, Jest or Mocha globals, and from an import, also under a different name (`import { after as cleanup }`). It reports a hook on `test` or `it` of node:test, or on its namespace (`test.after()`). It reports a hook on a test context: the first parameter of a test callback or a subtest callback of node:test, or a parameter of the type `TestContext`. A function of the file that has the name `after` is not a hook. Put the teardown in `try`/`finally`, or use `await using` with a disposable.
65
+
66
+ `zukhruf/no-http-exception-factory` reports a function that only returns `new HTTPException(…)`. The function hides the status and the cause code behind a name, so the reader of the throw site cannot see what the client gets. Write `throw new HTTPException(status, { message, cause: { code, detail } })` in full at each throw site, also when many sites use the same code. A function with more statements than the `return`, such as a branch, stays. A lookup in the arguments of the exception does not change the result: put the lookup in a function of its own, and keep the exception at the throw site. A class method that returns the exception, such as `toHTTPException()`, also stays: each class translates its own error.
67
+
68
+ `zukhruf/no-catch-around-next` reports the `catch` of a `try` block that only calls `await next()` or `return next()`. Hono's `compose()` catches the error of each handler and gives it to the app's error handler. An app always has an error handler, because Hono adds a default one. Thus `next()` does not reject with an `Error`, and the `catch` never runs. Translate the error at the throw site, or read `c.error` after `next()`. The rule applies only to a file that imports `hono` or `hono/*`. In Koa, the same `catch` is the error handler that the Koa documentation shows.
69
+
70
+ `zukhruf/no-api-error-instanceof` reports `instanceof APIError` when `APIError` comes from `better-auth`, `better-auth/api`, `@better-auth/core/error`, `better-call` or `better-call/error`. The `APIError` of better-auth extends the `APIError` of better-call. Thus an `APIError` that better-call throws is not an instance of the better-auth class, and the error goes to the 500 path. Use `isAPIError(error)` from `better-auth/api`. It checks the two classes and the name of the error. An `APIError` from a different module, such as a generated client, is not reported.
71
+
72
+ `zukhruf/no-on-api-error-throw` reports `onAPIError: { throw: true }`. With this option, better-auth throws the error again before `onAPIError.onError` and before its own log. The router of better-call catches that error and makes a response from it, so the error handler of the app does not run, and no log shows a 4xx error. Log the error in `onAPIError.onError`.
73
+
63
74
  ### Options for a repo
64
75
 
65
76
  Give repo-specific values as rule options. For example:
@@ -224,7 +235,7 @@ The composition tests run the real ESLint CLI on temporary workspaces. They load
224
235
  A check is a rule under its own key ([ADR 0001](./docs/adr/0001-one-key-per-check.md)). Before you write a visitor by hand, use the builders in `src/authoring/`:
225
236
 
226
237
  - `importBanRule()` bans packages and their subpaths. It reports static imports, re-exports and literal dynamic imports, type-only ones included.
227
- - `selectorRule()` reports each node that one of its esquery selectors matches. The substring operator `*=` never matches a Literal's `value`, so write a regex selector (`[value=/…/]`).
238
+ - `selectorRule()` reports each node that one of its esquery selectors matches. The substring operator `*=` never matches a Literal's `value`, so write a regex selector (`[value=/…/]`). A `:has(> A > B)` with more than one level never matches, so nest it: `:has(> A:has(> B))`.
228
239
  - `scopedRule()` turns a rule on only for the files that its function accepts. Build that function from `isTestFile()`, `inRoots()` and `matchesAnyGlob()` in `path-scope.ts`. A rule finds its scope from the linted file, not from a config glob ([ADR 0002](./docs/adr/0002-scope-from-the-linted-file.md)).
229
240
  - `ast.ts` has the type guards for a visitor: `isAstNode()`, `isType()` and `identifierName()`.
230
241
 
@@ -0,0 +1,3 @@
1
+ import { type Concept } from '../concept.ts';
2
+ export declare const betterAuth: Concept;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/better-auth/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,eAAe,CAAC;AAUrD,eAAO,MAAM,UAAU,EAAE,OAYxB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { enable } from "../concept.js";
2
+ import { TESTS, TEST_SUPPORT, TYPESCRIPT } from "../files.js";
3
+ import noApiErrorInstanceof from "./no-api-error-instanceof.js";
4
+ import noOnApiErrorThrow from "./no-on-api-error-throw.js";
5
+ const rules = {
6
+ 'no-api-error-instanceof': noApiErrorInstanceof,
7
+ 'no-on-api-error-throw': noOnApiErrorThrow,
8
+ };
9
+ export const betterAuth = {
10
+ name: 'better-auth',
11
+ rules,
12
+ config: (plugins) => [
13
+ { name: 'zukhruf/better-auth/plugins', plugins },
14
+ {
15
+ name: 'zukhruf/better-auth',
16
+ files: TYPESCRIPT,
17
+ ignores: [...TESTS, ...TEST_SUPPORT],
18
+ rules: enable(rules),
19
+ },
20
+ ],
21
+ };
22
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/better-auth/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAE3D,MAAM,KAAK,GAAG;IACZ,yBAAyB,EAAE,oBAAoB;IAC/C,uBAAuB,EAAE,iBAAiB;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAY;IACjC,IAAI,EAAE,aAAa;IACnB,KAAK;IACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,EAAE,IAAI,EAAE,6BAA6B,EAAE,OAAO,EAAE;QAChD;YACE,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,YAAY,CAAC;YACpC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
3
+ //# sourceMappingURL=no-api-error-instanceof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-api-error-instanceof.d.ts","sourceRoot":"","sources":["../../src/better-auth/no-api-error-instanceof.ts"],"names":[],"mappings":";AAmFA,wBAAgC"}
@@ -0,0 +1,62 @@
1
+ import { ESLintUtils, } from '@typescript-eslint/utils';
2
+ import { eslintRule } from "../authoring/rule-module.js";
3
+ const SOURCES = new Set([
4
+ 'better-auth',
5
+ 'better-auth/api',
6
+ '@better-auth/core/error',
7
+ 'better-call',
8
+ 'better-call/error',
9
+ ]);
10
+ function importOf(scope, node) {
11
+ const definition = scope.references.find((reference) => reference.identifier === node)?.resolved?.defs[0];
12
+ return definition?.type === 'ImportBinding' &&
13
+ definition.parent.type === 'ImportDeclaration' &&
14
+ SOURCES.has(definition.parent.source.value)
15
+ ? definition.node
16
+ : undefined;
17
+ }
18
+ function isApiErrorClass(scope, right) {
19
+ if (right.type === 'MemberExpression' &&
20
+ !right.computed &&
21
+ right.property.type === 'Identifier' &&
22
+ right.property.name === 'APIError') {
23
+ return importOf(scope, right.object)?.type === 'ImportNamespaceSpecifier';
24
+ }
25
+ const node = importOf(scope, right);
26
+ return (node?.type === 'ImportSpecifier' &&
27
+ node.imported.type === 'Identifier' &&
28
+ node.imported.name === 'APIError');
29
+ }
30
+ /**
31
+ * better-auth's `APIError` extends better-call's, so an `APIError` that
32
+ * better-call throws itself fails `instanceof` against better-auth's class,
33
+ * and the error falls through to the 500 path. `isAPIError()` checks both
34
+ * classes and the error's name, which also covers a second copy of
35
+ * better-call (its CommonJS and ESM builds have separate classes).
36
+ */
37
+ const rule = ESLintUtils.RuleCreator.withoutDocs({
38
+ meta: {
39
+ type: 'problem',
40
+ docs: {
41
+ description: 'Disallow instanceof against better-auth and better-call APIError',
42
+ },
43
+ schema: [],
44
+ messages: {
45
+ instanceof: "instanceof misses an APIError of another class: better-auth's APIError subclasses better-call's, so an APIError that better-call throws is not an instance of it. Use isAPIError(error) from 'better-auth/api'.",
46
+ },
47
+ },
48
+ defaultOptions: [],
49
+ create(context) {
50
+ return {
51
+ BinaryExpression(node) {
52
+ if (node.operator !== 'instanceof')
53
+ return;
54
+ if (isApiErrorClass(context.sourceCode.getScope(node), node.right)) {
55
+ context.report({ node, messageId: 'instanceof' });
56
+ }
57
+ },
58
+ };
59
+ },
60
+ });
61
+ export default eslintRule(rule);
62
+ //# sourceMappingURL=no-api-error-instanceof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-api-error-instanceof.js","sourceRoot":"","sources":["../../src/better-auth/no-api-error-instanceof.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,W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U,CAClC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC/C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,kEAAkE;SACrE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,UAAU,EACR,iNAAiN;SACpN;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY;oBAAE,OAAO;gBAC3C,IAAI,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * In better-auth 1.7, `onAPIError.throw` rethrows before `onAPIError.onError`
3
+ * and before better-auth logs the error. better-call's router catches the
4
+ * rethrow and turns it into a response, so the app's own error handler never
5
+ * runs, and no 4xx is logged anywhere.
6
+ */
7
+ declare const _default: import("eslint").Rule.RuleModule;
8
+ export default _default;
9
+ //# sourceMappingURL=no-on-api-error-throw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-on-api-error-throw.d.ts","sourceRoot":"","sources":["../../src/better-auth/no-on-api-error-throw.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;;AACH,wBAOG"}
@@ -0,0 +1,15 @@
1
+ import { selectorRule } from "../authoring/selector-rule.js";
2
+ /**
3
+ * In better-auth 1.7, `onAPIError.throw` rethrows before `onAPIError.onError`
4
+ * and before better-auth logs the error. better-call's router catches the
5
+ * rethrow and turns it into a response, so the app's own error handler never
6
+ * runs, and no 4xx is logged anywhere.
7
+ */
8
+ export default selectorRule({
9
+ description: "Disallow better-auth's onAPIError.throw",
10
+ selectors: [
11
+ "Property:matches([key.name='onAPIError'], [key.value='onAPIError']) > ObjectExpression > Property:matches([key.name='throw'], [key.value='throw'])[value.value=true]",
12
+ ],
13
+ message: "onAPIError.throw rethrows before better-auth logs the error, and better-call turns the rethrow into a response, so the app's error handler never sees it. Log in onAPIError.onError instead.",
14
+ });
15
+ //# sourceMappingURL=no-on-api-error-throw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-on-api-error-throw.js","sourceRoot":"","sources":["../../src/better-auth/no-on-api-error-throw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D;;;;;GAKG;AACH,eAAe,YAAY,CAAC;IAC1B,WAAW,EAAE,yCAAyC;IACtD,SAAS,EAAE;QACT,sKAAsK;KACvK;IACD,OAAO,EACL,8LAA8L;CACjM,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/hono/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,eAAe,CAAC;AAMrD,eAAO,MAAM,IAAI,EAAE,OAYlB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/hono/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,eAAe,CAAC;AAYrD,eAAO,MAAM,IAAI,EAAE,OAYlB,CAAC"}
@@ -1,7 +1,13 @@
1
1
  import { enable } from "../concept.js";
2
2
  import { TESTS, TEST_SUPPORT, TYPESCRIPT } from "../files.js";
3
+ import noCatchAroundNext from "./no-catch-around-next.js";
4
+ import noHttpExceptionFactory from "./no-http-exception-factory.js";
3
5
  import noUntypedEmptyJson from "./no-untyped-empty-json.js";
4
- const rules = { 'no-untyped-empty-json': noUntypedEmptyJson };
6
+ const rules = {
7
+ 'no-untyped-empty-json': noUntypedEmptyJson,
8
+ 'no-http-exception-factory': noHttpExceptionFactory,
9
+ 'no-catch-around-next': noCatchAroundNext,
10
+ };
5
11
  export const hono = {
6
12
  name: 'hono',
7
13
  rules,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/hono/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,MAAM,KAAK,GAAG,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,CAAC;AAE9D,MAAM,CAAC,MAAM,IAAI,GAAY;IAC3B,IAAI,EAAE,MAAM;IACZ,KAAK;IACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE;QACzC;YACE,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,YAAY,CAAC;YACpC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/hono/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,uBAAuB,EAAE,kBAAkB;IAC3C,2BAA2B,EAAE,sBAAsB;IACnD,sBAAsB,EAAE,iBAAiB;CAC1C,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAY;IAC3B,IAAI,EAAE,MAAM;IACZ,KAAK;IACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE;QACzC;YACE,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,YAAY,CAAC;YACpC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB;KACF;CACF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const _default: Rule.RuleModule;
3
+ export default _default;
4
+ //# sourceMappingURL=no-catch-around-next.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-catch-around-next.d.ts","sourceRoot":"","sources":["../../src/hono/no-catch-around-next.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;;AAsEnC,wBAAyD"}
@@ -0,0 +1,56 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { eslintRule } from "../authoring/rule-module.js";
3
+ import { scopedRule } from "../authoring/scoped-rule.js";
4
+ function isNextCall(expression) {
5
+ return (expression?.type === 'CallExpression' &&
6
+ expression.callee.type === 'Identifier' &&
7
+ expression.callee.name === 'next' &&
8
+ expression.arguments.length === 0);
9
+ }
10
+ function isAwaitedNext(expression) {
11
+ return (expression?.type === 'AwaitExpression' && isNextCall(expression.argument));
12
+ }
13
+ function onlyCallsNext([statement, ...rest]) {
14
+ if (statement === undefined || rest.length > 0)
15
+ return false;
16
+ if (statement.type === 'ExpressionStatement') {
17
+ return isAwaitedNext(statement.expression);
18
+ }
19
+ return (statement.type === 'ReturnStatement' &&
20
+ (isAwaitedNext(statement.argument) || isNextCall(statement.argument)));
21
+ }
22
+ function importsHono(context) {
23
+ return context.sourceCode.ast.body.some((statement) => statement.type === 'ImportDeclaration' &&
24
+ /^hono(?:\/|$)/.test(String(statement.source.value)));
25
+ }
26
+ /**
27
+ * Hono's `compose()` catches an error of each handler and passes it to the
28
+ * app's error handler, which always exists, so `await next()` never rejects
29
+ * and a `catch` around it never runs. Translate the error where it is thrown,
30
+ * or read `c.error` after `next()`. The rule runs only in a file that imports
31
+ * Hono: in Koa, the same `catch` is the documented error handler.
32
+ */
33
+ const rule = ESLintUtils.RuleCreator.withoutDocs({
34
+ meta: {
35
+ type: 'problem',
36
+ docs: {
37
+ description: 'Disallow a catch around only next() in Hono middleware',
38
+ },
39
+ schema: [],
40
+ messages: {
41
+ deadCatch: "Hono catches a handler's error before next() returns, so this catch never runs. Translate the error where it is thrown, or read c.error after next().",
42
+ },
43
+ },
44
+ defaultOptions: [],
45
+ create(context) {
46
+ return {
47
+ TryStatement(node) {
48
+ if (node.handler && onlyCallsNext(node.block.body)) {
49
+ context.report({ node: node.handler, messageId: 'deadCatch' });
50
+ }
51
+ },
52
+ };
53
+ },
54
+ });
55
+ export default scopedRule(eslintRule(rule), importsHono);
56
+ //# sourceMappingURL=no-catch-around-next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-catch-around-next.js","sourceRoot":"","sources":["../../src/hono/no-catch-around-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,SAAS,UAAU,CAAC,UAAsC;IACxD,OAAO,CACL,UAAU,EAAE,IAAI,KAAK,gBAAgB;QACrC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;QACvC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM;QACjC,UAAU,CA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AO;YACL,YAAY,CAAC,IAAI;gBACf,IAAI,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A function that only returns `new HTTPException(…)` hides the status and the
3
+ * cause code behind a name, so the reader at the throw site cannot see what
4
+ * the client receives. Write the exception in full at each throw site; give a
5
+ * function of its own only to behavior: a branch, a lookup, a transformation.
6
+ * A class method that returns the exception is polymorphic translation and
7
+ * stays.
8
+ */
9
+ declare const _default: import("eslint").Rule.RuleModule;
10
+ export default _default;
11
+ //# sourceMappingURL=no-http-exception-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-http-exception-factory.d.ts","sourceRoot":"","sources":["../../src/hono/no-http-exception-factory.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;;AACH,wBAUG"}
@@ -0,0 +1,21 @@
1
+ import { selectorRule } from "../authoring/selector-rule.js";
2
+ const NEW_HTTP_EXCEPTION = "NewExpression[callee.name='HTTPException']";
3
+ const RETURNS_ONLY_HTTP_EXCEPTION = `BlockStatement[body.length=1]:has(> ReturnStatement:has(> ${NEW_HTTP_EXCEPTION}))`;
4
+ /**
5
+ * A function that only returns `new HTTPException(…)` hides the status and the
6
+ * cause code behind a name, so the reader at the throw site cannot see what
7
+ * the client receives. Write the exception in full at each throw site; give a
8
+ * function of its own only to behavior: a branch, a lookup, a transformation.
9
+ * A class method that returns the exception is polymorphic translation and
10
+ * stays.
11
+ */
12
+ export default selectorRule({
13
+ description: 'Disallow a function whose only statement returns a new HTTPException',
14
+ selectors: [
15
+ `FunctionDeclaration:has(> ${RETURNS_ONLY_HTTP_EXCEPTION})`,
16
+ `VariableDeclarator > :matches(FunctionExpression, ArrowFunctionExpression):has(> ${RETURNS_ONLY_HTTP_EXCEPTION})`,
17
+ `VariableDeclarator > ArrowFunctionExpression:has(> ${NEW_HTTP_EXCEPTION})`,
18
+ ],
19
+ message: 'This function only builds an HTTPException, so the status and the cause code are hidden at the throw site. Write throw new HTTPException(status, { message, cause }) in full where you throw it.',
20
+ });
21
+ //# sourceMappingURL=no-http-exception-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-http-exception-factory.js","sourceRoot":"","sources":["../../src/hono/no-http-exception-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AACxE,MAAM,2BAA2B,GAAG,6DAA6D,kBAAkB,IAAI,CAAC;AAExH;;;;;;;GAOG;AACH,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,sEAAsE;IACxE,SAAS,EAAE;QACT,6BAA6B,2BAA2B,GAAG;QAC3D,oFAAoF,2BAA2B,GAAG;QAClH,sDAAsD,kBAAkB,GAAG;KAC5E;IACD,OAAO,EACL,kMAAkM;CACrM,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAyC7C,QAAA,MAAM,MAAM;;;;;;;;;;CAUa,CAAC;AAM1B,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AA2C7C,QAAA,MAAM,MAAM;;;;;;;;;;CAUa,CAAC;AAM1B,eAAe,MAAM,CAAC"}
package/dist/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { findPackageJSON } from 'node:module';
3
3
  import { base } from "./base/config.js";
4
+ import { betterAuth } from "./better-auth/config.js";
4
5
  import { diagnostics } from "./diagnostics/config.js";
5
6
  import { env } from "./environment/config.js";
6
7
  import { hono } from "./hono/config.js";
@@ -21,6 +22,7 @@ const concepts = [
21
22
  react,
22
23
  reactRouter,
23
24
  hono,
25
+ betterAuth,
24
26
  tailwind,
25
27
  pulumi,
26
28
  nxProjectJson,
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,QAAQ,GAAc;IAC1B,IAAI;IACJ,KAAK;IACL,WAAW;IACX,GAA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ACzB,SAAS,EAAE,SAAS;KACrB;IACD,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC7D;IACD,OAAO;CACgB,CAAC;AAE1B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;IAC/B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/eslint",
3
- "version": "0.3.55",
3
+ "version": "0.3.57",
4
4
  "description": "ESLint rules and configs shared across workspaces. Every check is its own named rule, so a repo's own config cannot silently erase it.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,7 +56,7 @@
56
56
  "ts-api-utils": "^2.5.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@zukhruf/testing": "^0.3.55"
59
+ "@zukhruf/testing": "^0.3.57"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@eslint/js": "^9.30.0 || ^10.0.0",