1 import type { Linter } from "eslint"
2 import { ruleId } from "../constants"
3 import { buildRecommended } from "./recommended"
4 import { tsParserBlock } from "./shared"
5
6 /**
7 * Strict preset — superset of `recommended` plus rules that are too expensive
8 * for the default preset: rules that require TypeScript type information
9 * (this preset enables `parserOptions.project`, so the consumer must have a
10 * tsconfig that includes the linted files), and cross-file rules whose cost
11 * scales with project size. These are slower to run, which is why they are not
12 * in `recommended`.
13 */
14 export function buildStrict(plugin: unknown): Linter.Config[] {
15 return [
16 ...buildRecommended(plugin),
17 // Enable type-aware parsing for the type-information rules below. This comes
18 // after `recommended` so it overrides that preset's project-less parser
19 // block.
20 tsParserBlock(true),
21 {
22 files: ["**/*.{ts,tsx}"],
23 rules: {
24 [ruleId("no-workflow-call-without-container")]: "warn",
25 },
26 },
27 {
28 files: ["src/workflows/**/*.{ts,tsx}", "**/workflows/**/*.{ts,tsx}"],
29 rules: {
30 [ruleId("no-non-serializable-step-return")]: "error",
31 },
32 },
33 {
34 files: ["src/api/**/route.{ts,tsx,js}", "**/api/**/route.{ts,tsx,js}"],
35 rules: {
36 [ruleId("use-validated-body-or-query")]: "warn",
37 },
38 },
39 {
40 // Cross-file uniqueness check: for each job file it reads and parses every
41 // other job file under the same `jobs/` root, so cost scales with the
42 // number of jobs squared. Strict-only for that reason.
43 files: ["src/jobs/**/*.{ts,js}", "**/src/jobs/**/*.{ts,js}"],
44 rules: {
45 [ruleId("scheduled-job-name-unique")]: "error",
46 },
47 },
48 ]
49 }