@r_masseater/fu4 0.3.1 → 0.3.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.
@@ -1,204 +0,0 @@
1
- import { S as settingOf, _ as traceparent, a as matcher, b as callAddon, c as baseName, d as pathspecsOf, f as sectionOf, g as mergedRecords, h as mergedLayers, m as layersOf, n as sourceOf, o as selects, p as notUtf8, r as sourceView, x as loadAddon, y as exposes } from "./source-BRZXj75b.mjs";
2
- import { Array, Effect, Option, Order, Record, Schema, String as String$1, pipe } from "effect";
3
- // src/app/format.ts
4
- const format = (diagnostic) => `${diagnostic.path}:${String(diagnostic.line)}:${String(diagnostic.column)}: ${diagnostic.message} [${diagnostic.rule}]`;
5
- // src/entities/rule/model/extend.ts
6
- const flattenConfig = (config) => {
7
- const layers = layersOf(config);
8
- return {
9
- ...mergedLayers(layers),
10
- settings: mergedRecords(pipe(layers, Array.map((layer) => layer.settings)))
11
- };
12
- };
13
- // src/entities/rule/model/resolve.ts
14
- const SEPARATOR = "/";
15
- const START = 0;
16
- const enabled = ([id, entry]) => {
17
- const { severity, options } = settingOf(entry);
18
- if (severity === "off") return [];
19
- return [{
20
- id,
21
- severity,
22
- options
23
- }];
24
- };
25
- const applies = (path) => (override) => selects(override.files)(path);
26
- const isIgnored = (config) => (path) => matcher(config.ignores ?? [])(path);
27
- const entriesFor = (config) => (path) => {
28
- const merged = { ...config.rules };
29
- for (const override of pipe(config.overrides ?? [], Array.filter(applies(path)))) Object.assign(merged, override.rules);
30
- return merged;
31
- };
32
- const ruleOf = (config) => (id) => pipe(String$1.indexOf(SEPARATOR)(id), Option.flatMap((at) => pipe(Record.get(config.plugins ?? {}, String$1.slice(START, at)(id)), Option.flatMap((plugin) => Record.get(plugin.rules, String$1.slice(at + 1)(id))))));
33
- const activate = (config) => (entry) => pipe(ruleOf(config)(entry.id), Option.map((rule) => ({
34
- ...entry,
35
- rule
36
- })), Option.toArray);
37
- const activeRules = (config) => (path) => pipe(Record.toEntries(entriesFor(config)(path)), Array.flatMap(enabled), Array.flatMap(activate(config)));
38
- // src/entities/source/model/kind.ts
39
- const WORKFLOWS = ".github/workflows/";
40
- const YAML = /\.ya?ml$/u;
41
- const ACTION = /^action\.ya?ml$/u;
42
- const DEPENDABOT = /^\.github\/dependabot\.ya?ml$/u;
43
- const PRE_COMMIT = /^\.pre-commit-(?:config|hooks)\.yaml$/u;
44
- const kindOf = (path) => {
45
- if (DEPENDABOT.test(path)) return Option.some("dependabot");
46
- if (PRE_COMMIT.test(path)) return Option.some("pre-commit");
47
- if (ACTION.test(baseName(path))) return Option.some("action");
48
- if (String$1.includes(WORKFLOWS)(path) && YAML.test(path)) return Option.some("workflow");
49
- return Option.none();
50
- };
51
- // src/shared/lib/errors.ts
52
- const taggedError = Schema.TaggedError;
53
- var Fu4Error = class extends taggedError()("Fu4Error", { message: Schema.String }) {};
54
- const failedWith = (message) => (cause) => Fu4Error.make({ message: `${message}: ${String(cause)}` });
55
- // src/shared/native/index.ts
56
- const isNative = exposes([
57
- "parsePaths",
58
- "parseText",
59
- "parseScript",
60
- "readText",
61
- "pathExists",
62
- "flushTelemetry"
63
- ]);
64
- const native = loadAddon({
65
- packageName: "@r_masseater/fu4",
66
- binary: "fu4",
67
- from: import.meta.url,
68
- isAddon: isNative,
69
- failWith: failedWith
70
- });
71
- // src/features/run-rules/model/order.ts
72
- const byPosition = Order.combineAll([
73
- Order.mapInput(Order.String, (found) => found.path),
74
- Order.mapInput(Order.Number, (found) => found.line),
75
- Order.mapInput(Order.Number, (found) => found.column),
76
- Order.mapInput(Order.String, (found) => found.message)
77
- ]);
78
- const same = (left, right) => left.path === right.path && left.line === right.line && left.column === right.column && left.message === right.message && left.rule === right.rule;
79
- const ordered = (found) => Array.dedupeWith(Array.sort(found, byPosition), same);
80
- // src/features/run-rules/model/run.ts
81
- const CONCURRENT$1 = { concurrency: "unbounded" };
82
- const appliesTo = (kind) => ({ rule }) => pipe(rule.meta.kinds ?? ["workflow"], Array.some((each) => each === kind));
83
- const diagnosticOf = (input, active) => ({ rule, ...report }) => ({
84
- path: input.path,
85
- ...report,
86
- rule: rule ?? active.id,
87
- severity: active.severity
88
- });
89
- const checked = (active, context) => Effect.suspend(() => {
90
- const result = active.rule.check(context);
91
- if (Effect.isEffect(result)) return result;
92
- return Effect.void;
93
- });
94
- const runRule = (input) => (active) => {
95
- const reports = [];
96
- const context = {
97
- filename: input.path,
98
- kind: input.kind,
99
- source: input.source,
100
- options: active.options,
101
- settings: input.settings,
102
- project: input.project,
103
- parseScript: input.parseScript,
104
- report: (report) => {
105
- reports.push(report);
106
- }
107
- };
108
- return checked(active, context).pipe(Effect.catchCause((cause) => cause.pipe(failedWith(`fu4 rule ${active.id} failed on ${input.path}`), Effect.fail)), Effect.map(() => pipe(reports, Array.map(diagnosticOf(input, active)))), Effect.withSpan("fu4.rule", { attributes: {
109
- "fu4.rule.id": active.id,
110
- "code.file.path": input.path
111
- } }));
112
- };
113
- const runFile = Effect.fn("fu4.runFile")(function* runFile(input) {
114
- const active = pipe(input.rules, Array.filter(appliesTo(input.kind)));
115
- const results = yield* Effect.forEach(active, runRule(input), CONCURRENT$1);
116
- return Array.flatten(results);
117
- });
118
- // src/app/lint.ts
119
- const CONCURRENT = { concurrency: "unbounded" };
120
- const projectOf = (root, addon) => {
121
- const parsed = /* @__PURE__ */ new Map();
122
- const read = (file) => Option.fromNullishOr(addon.readText(root, file));
123
- const parse = (file) => {
124
- const source = pipe(read(file), Option.map((text) => sourceOf(sourceView(addon.parseText(text)))));
125
- parsed.set(file, source);
126
- return source;
127
- };
128
- return {
129
- root,
130
- exists: (file) => addon.pathExists(root, file),
131
- read,
132
- parse: (file) => Option.getOrElse(Option.fromNullishOr(parsed.get(file)), () => parse(file))
133
- };
134
- };
135
- const scriptParser = (addon) => (language, text) => sourceOf(sourceView(addon.parseScript(language, text)));
136
- const targetsOf = (config, files) => pipe(files, Array.filter((file) => Option.isSome(kindOf(file)) && !isIgnored(config)(file)));
137
- const parsedFiles = Effect.fn("fu4.parse")(function* parsedFiles(root, targets) {
138
- const parent = yield* traceparent;
139
- return yield* callAddon({
140
- addon: native,
141
- name: "fu4",
142
- files: targets.length,
143
- call: (loaded) => loaded.parsePaths(root, targets, { traceparent: Option.getOrUndefined(parent) }),
144
- failWith: failedWith
145
- });
146
- });
147
- const lint = Effect.fn("fu4.lint")(function* lint(input) {
148
- const config = flattenConfig(input.config ?? {});
149
- const addon = yield* native;
150
- const parsed = yield* parsedFiles(input.root, targetsOf(config, input.files));
151
- const project = projectOf(input.root, addon);
152
- const lintOne = (file) => Option.match(Option.fromUndefinedOr(file.source), {
153
- onNone: () => Effect.succeed([notUtf8("fu4")(file.path)]),
154
- onSome: (source) => runFile({
155
- path: file.path,
156
- kind: Option.getOrThrow(kindOf(file.path)),
157
- source: sourceOf(sourceView(source)),
158
- rules: activeRules(config)(file.path),
159
- settings: config.settings ?? {},
160
- project,
161
- parseScript: scriptParser(addon)
162
- })
163
- });
164
- const results = yield* Effect.forEach(parsed, lintOne, CONCURRENT);
165
- return ordered(Array.flatten(results));
166
- });
167
- const kindFor = (input) => pipe(Option.fromNullishOr(input.kind), Option.orElse(() => kindOf(input.path)), Option.getOrElse(() => "workflow"));
168
- const lintText = Effect.fn("fu4.lintText")(function* lintText(input) {
169
- const config = flattenConfig(input.config ?? {});
170
- const addon = yield* native;
171
- const source = sourceOf(sourceView(addon.parseText(input.text)));
172
- const results = yield* runFile({
173
- path: input.path,
174
- kind: kindFor(input),
175
- source,
176
- rules: activeRules(config)(input.path),
177
- settings: config.settings ?? {},
178
- project: projectOf(input.root, addon),
179
- parseScript: scriptParser(addon)
180
- });
181
- return ordered(results);
182
- });
183
- // src/app/section.ts
184
- const fu4Section = sectionOf({
185
- name: "fu4",
186
- prepare: flattenConfig,
187
- fallback: {}
188
- });
189
- const workflowPathspecs = pathspecsOf({
190
- defaults: [
191
- ".github/workflows/*.yml",
192
- ".github/workflows/*.yaml",
193
- ":(glob)**/action.yml",
194
- ":(glob)**/action.yaml",
195
- ".github/dependabot.yml",
196
- ".github/dependabot.yaml",
197
- ".pre-commit-config.yaml",
198
- ".pre-commit-hooks.yaml"
199
- ],
200
- unowned: [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"]
201
- });
202
- export { Fu4Error as a, lintText as i, workflowPathspecs as n, failedWith as o, lint as r, format as s, fu4Section as t };
203
-
204
- //# sourceMappingURL=app-DR_5JsmN.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-DR_5JsmN.mjs","names":["Arr","Arr","Str","Rec","Str","Arr","CONCURRENT","Arr","Arr"],"sources":["../src/app/format.ts","../src/entities/rule/model/extend.ts","../src/entities/rule/model/resolve.ts","../src/entities/source/model/kind.ts","../src/shared/lib/errors.ts","../src/shared/native/index.ts","../src/features/run-rules/model/order.ts","../src/features/run-rules/model/run.ts","../src/app/lint.ts","../src/app/section.ts"],"sourcesContent":["import type { Diagnostic } from \"#/shared/config/index.ts\";\n\nexport const format = (diagnostic: Diagnostic): string =>\n `${diagnostic.path}:${String(diagnostic.line)}:${String(diagnostic.column)}: ${diagnostic.message} [${diagnostic.rule}]`;\n","import { layersOf, mergedLayers, mergedRecords } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport type { Fu4Config } from \"#/shared/config/index.ts\";\n\nexport const flattenConfig = (config: Fu4Config): Fu4Config => {\n const layers = layersOf(config);\n return {\n ...mergedLayers(layers),\n settings: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.settings),\n ),\n ),\n };\n};\n","import { settingOf } from \"@masseater.dev/lint-host\";\nimport { matcher, selects } from \"@masseater.dev/path-kit\";\nimport { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport type {\n Fu4Config,\n Override,\n Rule,\n RuleEntry,\n RuleOptions,\n Severity,\n} from \"#/shared/config/index.ts\";\n\nconst SEPARATOR = \"/\";\nconst START = 0;\n\nexport interface ActiveRule {\n readonly id: string;\n readonly rule: Rule;\n readonly severity: Exclude<Severity, \"off\">;\n readonly options: RuleOptions;\n}\n\ninterface Enabled {\n readonly id: string;\n readonly severity: Exclude<Severity, \"off\">;\n readonly options: RuleOptions;\n}\n\nconst enabled = ([id, entry]: readonly [string, RuleEntry]): readonly Enabled[] => {\n const { severity, options } = settingOf(entry);\n if (severity === \"off\") {\n return [];\n }\n return [{ id, severity, options }];\n};\n\nconst applies =\n (path: string) =>\n (override: Override): boolean =>\n selects(override.files)(path);\n\nexport const isIgnored =\n (config: Fu4Config) =>\n (path: string): boolean =>\n matcher(config.ignores ?? [])(path);\n\nexport const entriesFor =\n (config: Fu4Config) =>\n (path: string): Readonly<Record<string, RuleEntry>> => {\n const merged: Record<string, RuleEntry> = { ...config.rules };\n for (const override of pipe(config.overrides ?? [], Arr.filter(applies(path)))) {\n Object.assign(merged, override.rules);\n }\n return merged;\n };\n\nconst ruleOf =\n (config: Fu4Config) =>\n (id: string): Option.Option<Rule> =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.flatMap((at) =>\n pipe(\n Rec.get(config.plugins ?? {}, Str.slice(START, at)(id)),\n Option.flatMap((plugin) => Rec.get(plugin.rules, Str.slice(at + SEPARATOR.length)(id))),\n ),\n ),\n );\n\nconst activate =\n (config: Fu4Config) =>\n (entry: Enabled): readonly ActiveRule[] =>\n pipe(\n ruleOf(config)(entry.id),\n Option.map((rule): ActiveRule => ({ ...entry, rule })),\n Option.toArray,\n );\n\nexport const activeRules =\n (config: Fu4Config) =>\n (path: string): readonly ActiveRule[] =>\n pipe(\n Rec.toEntries(entriesFor(config)(path)),\n Arr.flatMap(enabled),\n Arr.flatMap(activate(config)),\n );\n","import { baseName } from \"@masseater.dev/path-kit\";\nimport { Option, String as Str } from \"effect\";\n\nimport type { InputKind } from \"#/shared/config/index.ts\";\n\nconst WORKFLOWS = \".github/workflows/\";\nconst YAML = /\\.ya?ml$/u;\nconst ACTION = /^action\\.ya?ml$/u;\nconst DEPENDABOT = /^\\.github\\/dependabot\\.ya?ml$/u;\nconst PRE_COMMIT = /^\\.pre-commit-(?:config|hooks)\\.yaml$/u;\n\nexport const kindOf = (path: string): Option.Option<InputKind> => {\n if (DEPENDABOT.test(path)) {\n return Option.some(\"dependabot\");\n }\n if (PRE_COMMIT.test(path)) {\n return Option.some(\"pre-commit\");\n }\n if (ACTION.test(baseName(path))) {\n return Option.some(\"action\");\n }\n if (Str.includes(WORKFLOWS)(path) && YAML.test(path)) {\n return Option.some(\"workflow\");\n }\n return Option.none();\n};\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class Fu4Error extends taggedError<Fu4Error, { readonly brand: unique symbol }>()(\n \"Fu4Error\",\n {\n message: Schema.String,\n },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): Fu4Error =>\n Fu4Error.make({ message: `${message}: ${String(cause)}` });\n","import { exposes, loadAddon } from \"@masseater.dev/lint-host\";\nimport type { Effect } from \"effect\";\n\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { Fu4Error } from \"#/shared/lib/errors.ts\";\n\nexport { CONCRETE, FLAG, NONE, SEMANTIC, sourceView } from \"./source.ts\";\nexport type { SourceView } from \"./source.ts\";\n\nexport interface ParsedFile {\n readonly path: string;\n readonly source?: Uint8Array;\n}\n\nexport interface Native {\n readonly parsePaths: (\n root: string,\n paths: readonly string[],\n options: { readonly traceparent: string | undefined },\n ) => readonly ParsedFile[];\n readonly parseText: (text: string) => Uint8Array;\n readonly parseScript: (language: string, text: string) => Uint8Array;\n readonly readText: (root: string, path: string) => string | null;\n readonly pathExists: (root: string, path: string) => boolean;\n readonly flushTelemetry: () => Promise<void>;\n}\n\nconst NATIVE_FUNCTIONS = [\n \"parsePaths\",\n \"parseText\",\n \"parseScript\",\n \"readText\",\n \"pathExists\",\n \"flushTelemetry\",\n] as const;\n\nconst isNative = exposes<Native>(NATIVE_FUNCTIONS);\n\nexport const native: Effect.Effect<Native, Fu4Error> = loadAddon({\n packageName: \"@r_masseater/fu4\",\n binary: \"fu4\",\n from: import.meta.url,\n isAddon: isNative,\n failWith: failedWith,\n});\n","import { Array as Arr, Order } from \"effect\";\n\nimport type { Diagnostic } from \"#/shared/config/index.ts\";\n\nconst byPosition: Order.Order<Diagnostic> = Order.combineAll([\n Order.mapInput(Order.String, (found: Diagnostic) => found.path),\n Order.mapInput(Order.Number, (found: Diagnostic) => found.line),\n Order.mapInput(Order.Number, (found: Diagnostic) => found.column),\n Order.mapInput(Order.String, (found: Diagnostic) => found.message),\n]);\n\nconst same = (left: Diagnostic, right: Diagnostic): boolean =>\n left.path === right.path &&\n left.line === right.line &&\n left.column === right.column &&\n left.message === right.message &&\n left.rule === right.rule;\n\nexport const ordered = (found: readonly Diagnostic[]): readonly Diagnostic[] =>\n Arr.dedupeWith(Arr.sort(found, byPosition), same);\n","import { Array as Arr, Effect, pipe } from \"effect\";\n\nimport type { ActiveRule } from \"#/entities/rule/index.ts\";\nimport type {\n Diagnostic,\n InputKind,\n Project,\n Report,\n RuleContext,\n ScriptLanguage,\n Source,\n} from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { Fu4Error } from \"#/shared/lib/errors.ts\";\n\nexport interface FileInput {\n readonly path: string;\n readonly kind: InputKind;\n readonly source: Source;\n readonly rules: readonly ActiveRule[];\n readonly settings: Readonly<Record<string, unknown>>;\n readonly project: Project;\n readonly parseScript: (language: ScriptLanguage, text: string) => Source;\n}\n\nconst CONCURRENT = { concurrency: \"unbounded\" } as const;\n\nconst appliesTo =\n (kind: InputKind) =>\n ({ rule }: ActiveRule): boolean =>\n pipe(\n rule.meta.kinds ?? [\"workflow\"],\n Arr.some((each) => each === kind),\n );\n\nconst diagnosticOf =\n (input: FileInput, active: ActiveRule) =>\n ({ rule, ...report }: Report): Diagnostic => ({\n path: input.path,\n ...report,\n rule: rule ?? active.id,\n severity: active.severity,\n });\n\nconst checked = (active: ActiveRule, context: RuleContext): Effect.Effect<void> =>\n Effect.suspend(() => {\n const result = active.rule.check(context);\n if (Effect.isEffect(result)) {\n return result;\n }\n return Effect.void;\n });\n\nconst runRule =\n (input: FileInput) =>\n (active: ActiveRule): Effect.Effect<readonly Diagnostic[], Fu4Error> => {\n const reports: Report[] = [];\n const context: RuleContext = {\n filename: input.path,\n kind: input.kind,\n source: input.source,\n options: active.options,\n settings: input.settings,\n project: input.project,\n parseScript: input.parseScript,\n report: (report) => {\n reports.push(report);\n },\n };\n return checked(active, context).pipe(\n Effect.catchCause((cause) =>\n cause.pipe(failedWith(`fu4 rule ${active.id} failed on ${input.path}`), Effect.fail),\n ),\n Effect.map(() => pipe(reports, Arr.map(diagnosticOf(input, active)))),\n Effect.withSpan(\"fu4.rule\", {\n attributes: { \"fu4.rule.id\": active.id, \"code.file.path\": input.path },\n }),\n );\n };\n\nexport const runFile = Effect.fn(\"fu4.runFile\")(function* runFile(input: FileInput) {\n const active = pipe(input.rules, Arr.filter(appliesTo(input.kind)));\n const results = yield* Effect.forEach(active, runRule(input), CONCURRENT);\n return Arr.flatten(results);\n});\n","import { callAddon, notUtf8, traceparent } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { activeRules, flattenConfig, isIgnored } from \"#/entities/rule/index.ts\";\nimport { kindOf, sourceOf } from \"#/entities/source/index.ts\";\nimport { ordered, runFile } from \"#/features/run-rules/index.ts\";\nimport type {\n Fu4Config,\n InputKind,\n Project,\n ScriptLanguage,\n Source,\n} from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport { native, sourceView } from \"#/shared/native/index.ts\";\nimport type { Native, ParsedFile } from \"#/shared/native/index.ts\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly config?: Fu4Config;\n}\n\nexport interface LintTextInput {\n readonly root: string;\n readonly path: string;\n readonly text: string;\n readonly kind?: InputKind;\n readonly config?: Fu4Config;\n}\n\nconst CONCURRENT = { concurrency: \"unbounded\" } as const;\n\nconst projectOf = (root: string, addon: Native): Project => {\n const parsed = new Map<string, Option.Option<Source>>();\n const read = (file: string): Option.Option<string> =>\n Option.fromNullishOr(addon.readText(root, file));\n const parse = (file: string): Option.Option<Source> => {\n const source = pipe(\n read(file),\n Option.map((text) => sourceOf(sourceView(addon.parseText(text)))),\n );\n parsed.set(file, source);\n return source;\n };\n return {\n root,\n exists: (file) => addon.pathExists(root, file),\n read,\n parse: (file) => Option.getOrElse(Option.fromNullishOr(parsed.get(file)), () => parse(file)),\n };\n};\n\nconst scriptParser =\n (addon: Native) =>\n (language: ScriptLanguage, text: string): Source =>\n sourceOf(sourceView(addon.parseScript(language, text)));\n\nconst targetsOf = (config: Fu4Config, files: readonly string[]): readonly string[] =>\n pipe(\n files,\n Arr.filter((file) => Option.isSome(kindOf(file)) && !isIgnored(config)(file)),\n );\n\nconst parsedFiles = Effect.fn(\"fu4.parse\")(function* parsedFiles(\n root: string,\n targets: readonly string[],\n) {\n const parent = yield* traceparent;\n return yield* callAddon({\n addon: native,\n name: \"fu4\",\n files: targets.length,\n call: (loaded): readonly ParsedFile[] =>\n loaded.parsePaths(root, targets, { traceparent: Option.getOrUndefined(parent) }),\n failWith: failedWith,\n });\n});\n\nexport const lint = Effect.fn(\"fu4.lint\")(function* lint(input: LintInput) {\n const config = flattenConfig(input.config ?? {});\n const addon = yield* native;\n const parsed = yield* parsedFiles(input.root, targetsOf(config, input.files));\n const project = projectOf(input.root, addon);\n const lintOne = (file: ParsedFile): ReturnType<typeof runFile> =>\n Option.match(Option.fromUndefinedOr(file.source), {\n onNone: () => Effect.succeed([notUtf8(\"fu4\")(file.path)]),\n onSome: (source) =>\n runFile({\n path: file.path,\n kind: Option.getOrThrow(kindOf(file.path)),\n source: sourceOf(sourceView(source)),\n rules: activeRules(config)(file.path),\n settings: config.settings ?? {},\n project,\n parseScript: scriptParser(addon),\n }),\n });\n const results = yield* Effect.forEach(parsed, lintOne, CONCURRENT);\n return ordered(Arr.flatten(results));\n});\n\nconst kindFor = (input: LintTextInput): InputKind =>\n pipe(\n Option.fromNullishOr(input.kind),\n Option.orElse(() => kindOf(input.path)),\n Option.getOrElse((): InputKind => \"workflow\"),\n );\n\nexport const lintText = Effect.fn(\"fu4.lintText\")(function* lintText(input: LintTextInput) {\n const config = flattenConfig(input.config ?? {});\n const addon = yield* native;\n const source = sourceOf(sourceView(addon.parseText(input.text)));\n const results = yield* runFile({\n path: input.path,\n kind: kindFor(input),\n source,\n rules: activeRules(config)(input.path),\n settings: config.settings ?? {},\n project: projectOf(input.root, addon),\n parseScript: scriptParser(addon),\n });\n return ordered(results);\n});\n","import { pathspecsOf, sectionOf } from \"@masseater.dev/lint-host\";\nimport type { PathspecRequest } from \"@masseater.dev/lint-host\";\n\nimport { flattenConfig } from \"#/entities/rule/index.ts\";\nimport type { Fu4Config } from \"#/shared/config/index.ts\";\n\nexport type PathspecInput = PathspecRequest<Fu4Config>;\n\nexport const fu4Section = sectionOf<Fu4Config>({\n name: \"fu4\",\n prepare: flattenConfig,\n fallback: {},\n});\n\nexport const workflowPathspecs = pathspecsOf({\n defaults: [\n \".github/workflows/*.yml\",\n \".github/workflows/*.yaml\",\n \":(glob)**/action.yml\",\n \":(glob)**/action.yaml\",\n \".github/dependabot.yml\",\n \".github/dependabot.yaml\",\n \".pre-commit-config.yaml\",\n \".pre-commit-hooks.yaml\",\n ],\n unowned: [\":(exclude,attr:linguist-vendored)\", \":(exclude,attr:linguist-generated)\"],\n});\n"],"mappings":";;;AAEA,MAAa,UAAU,eACrB,GAAG,WAAW,KAAK,GAAG,OAAO,WAAW,IAAI,EAAE,GAAG,OAAO,WAAW,MAAM,EAAE,IAAI,WAAW,QAAQ,IAAI,WAAW,KAAK;;ACExH,MAAa,iBAAiB,WAAiC;CAC7D,MAAM,SAAS,SAAS,MAAM;CAC9B,OAAO;EACL,GAAG,aAAa,MAAM;EACtB,UAAU,cACR,KACE,QACAA,MAAI,KAAK,UAAU,MAAM,QAAQ,CAC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jC,CAAC;CACD,OAAO,QAAQ,OAAO;AACxB,CAAC;;ACnHD,MAAa,aAAa,UAAqB;CAC7C,MAAM;CACN,SAAS;CACT,UAAU,CAAC;AACb,CAAC;AAED,MAAa,oBAAoB,YAAY;CAC3C,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS,CAAC,qCAAqC,oCAAoC;AACrF,CAAC"}
@@ -1,21 +0,0 @@
1
- import { v as runCli$1 } from "./source-BRZXj75b.mjs";
2
- import { n as workflowPathspecs, o as failedWith, r as lint, s as format, t as fu4Section } from "./app-DR_5JsmN.mjs";
3
- // package.json
4
- var version = "0.3.1";
5
- var description = "The engine of a GitHub Actions linter: Rust parses workflows and TypeScript rules from its presets subpath check them, configured from vite.config.ts.";
6
- // src/app/cli.ts
7
- const runCli = () => {
8
- runCli$1({
9
- name: "fu4",
10
- version,
11
- description,
12
- section: fu4Section,
13
- pathspecs: workflowPathspecs,
14
- lint,
15
- format,
16
- failWith: failedWith
17
- });
18
- };
19
- export { runCli };
20
-
21
- //# sourceMappingURL=cli-Cv5v6zny.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-Cv5v6zny.mjs","names":["manifest.version","manifest.description"],"sources":["../package.json","../src/app/cli.ts"],"sourcesContent":["","import { runCli as runLinter } from \"@masseater.dev/lint-host\";\nimport manifest from \"@r_masseater/fu4/package.json\" with { type: \"json\" };\n\nimport { failedWith } from \"#/shared/lib/errors.ts\";\n\nimport { format, lint } from \"./index.ts\";\nimport { fu4Section, workflowPathspecs } from \"./section.ts\";\n\nexport const runCli = (): void => {\n runLinter({\n name: \"fu4\",\n version: manifest.version,\n description: manifest.description,\n section: fu4Section,\n pathspecs: workflowPathspecs,\n lint,\n format,\n failWith: failedWith,\n });\n};\n"],"mappings":";;;;;;ACQA,MAAa,eAAqB;CAChC,SAAU;EACR,MAAM;EACGA;EACIC;EACb,SAAS;EACT,WAAW;EACX;EACA;EACA,UAAU;CACZ,CAAC;AACH"}