@r_masseater/fumx 0.0.0 → 0.1.1
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/LICENSE +87 -0
- package/README.md +123 -1
- package/dist/analysis-BAPm6c9P.d.mts +75 -0
- package/dist/analysis-CRyaJD5D.mjs +294 -0
- package/dist/analysis-CRyaJD5D.mjs.map +1 -0
- package/dist/analysis.d.mts +3 -0
- package/dist/analysis.mjs +3 -0
- package/dist/cli-D2DptmOG.mjs +2506 -0
- package/dist/cli-D2DptmOG.mjs.map +1 -0
- package/dist/convert-als.d.mts +17 -0
- package/dist/convert-als.mjs +512 -0
- package/dist/convert-als.mjs.map +1 -0
- package/dist/convert-midi.d.mts +17 -0
- package/dist/convert-midi.mjs +273 -0
- package/dist/convert-midi.mjs.map +1 -0
- package/dist/fumx.mjs +9 -0
- package/dist/fumx.mjs.map +1 -0
- package/dist/grammar-Ds8M-PkG.mjs +9836 -0
- package/dist/grammar-Ds8M-PkG.mjs.map +1 -0
- package/dist/habits.d.mts +71 -0
- package/dist/habits.mjs +98 -0
- package/dist/habits.mjs.map +1 -0
- package/dist/index-Bc9UT9HF.d.mts +795 -0
- package/dist/index-C7av_aK1.d.mts +104 -0
- package/dist/index-DOfjU43D.d.mts +71 -0
- package/dist/index-KxUilka8.d.mts +6 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/lint-Bnl4l0aI.mjs +296 -0
- package/dist/lint-Bnl4l0aI.mjs.map +1 -0
- package/dist/lint-CJ5lq-Fr.d.mts +37 -0
- package/dist/lint.d.mts +3 -0
- package/dist/lint.mjs +1 -0
- package/dist/mapper.mjs +14 -0
- package/dist/mapper.mjs.map +1 -0
- package/dist/mix-facts-QCYCXdIA.mjs +7006 -0
- package/dist/mix-facts-QCYCXdIA.mjs.map +1 -0
- package/dist/presets.d.mts +35 -0
- package/dist/presets.mjs +814 -0
- package/dist/presets.mjs.map +1 -0
- package/dist/read-song-B9342KUK.mjs +13017 -0
- package/dist/read-song-B9342KUK.mjs.map +1 -0
- package/dist/read-song-CsW4kd7v.d.mts +1326 -0
- package/dist/read-song-DW8MLsln.mjs +2783 -0
- package/dist/read-song-DW8MLsln.mjs.map +1 -0
- package/dist/song-BlIPWk7b.mjs +387 -0
- package/dist/song-BlIPWk7b.mjs.map +1 -0
- package/dist/song-UZ4T_dj9.d.mts +1477 -0
- package/dist/sounding-BCyExbPp.d.mts +20 -0
- package/dist/sounding-DYDZFp4e.mjs +41 -0
- package/dist/sounding-DYDZFp4e.mjs.map +1 -0
- package/dist/style-rules-CjaZTDt_.d.mts +131 -0
- package/dist/ticks-D6yACwHt.mjs +26 -0
- package/dist/ticks-D6yACwHt.mjs.map +1 -0
- package/dist/transform-CeFBPHqb.mjs +108 -0
- package/dist/transform-CeFBPHqb.mjs.map +1 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.mjs +127 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/write-CHtCd-bG.mjs +747 -0
- package/dist/write-CHtCd-bG.mjs.map +1 -0
- package/package.json +111 -5
- package/skills/lint-songs/SKILL.md +54 -0
- package/skills/read-fumx/SKILL.md +89 -0
- package/skills/use-fumx-tools/SKILL.md +69 -0
- package/skills/use-lint-presets/SKILL.md +72 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { a as Controller, l as MixerParameter } from "./song-UZ4T_dj9.mjs";
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
interface Timed {
|
|
4
|
+
readonly tick: number;
|
|
5
|
+
}
|
|
6
|
+
interface TimelineNote extends Timed {
|
|
7
|
+
readonly end: number;
|
|
8
|
+
readonly midi: number;
|
|
9
|
+
readonly velocity: number;
|
|
10
|
+
readonly release: number;
|
|
11
|
+
}
|
|
12
|
+
interface TimelineControl extends Timed {
|
|
13
|
+
readonly controller: Controller;
|
|
14
|
+
readonly value: number;
|
|
15
|
+
}
|
|
16
|
+
interface Text extends Timed {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
}
|
|
19
|
+
interface Part {
|
|
20
|
+
readonly track: number;
|
|
21
|
+
readonly channel: number;
|
|
22
|
+
readonly name: Option.Option<string>;
|
|
23
|
+
readonly program: Option.Option<number>;
|
|
24
|
+
readonly notes: readonly TimelineNote[];
|
|
25
|
+
readonly controls: readonly TimelineControl[];
|
|
26
|
+
readonly lyrics: readonly Text[];
|
|
27
|
+
}
|
|
28
|
+
interface Level {
|
|
29
|
+
readonly decibels: number;
|
|
30
|
+
readonly pan: number;
|
|
31
|
+
readonly muted: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface TrackSend {
|
|
34
|
+
readonly bus: number;
|
|
35
|
+
readonly amount: number;
|
|
36
|
+
}
|
|
37
|
+
type MixParameter = MixerParameter;
|
|
38
|
+
interface MixPoint extends Timed {
|
|
39
|
+
readonly value: number;
|
|
40
|
+
}
|
|
41
|
+
interface Envelope {
|
|
42
|
+
readonly parameter: MixParameter;
|
|
43
|
+
readonly points: readonly MixPoint[];
|
|
44
|
+
}
|
|
45
|
+
interface TrackMix {
|
|
46
|
+
readonly level: Level;
|
|
47
|
+
readonly sends: readonly TrackSend[];
|
|
48
|
+
readonly envelopes: readonly Envelope[];
|
|
49
|
+
}
|
|
50
|
+
interface LaidTempo {
|
|
51
|
+
readonly offset: number;
|
|
52
|
+
readonly length: number;
|
|
53
|
+
readonly microseconds: number;
|
|
54
|
+
readonly target: Option.Option<number>;
|
|
55
|
+
}
|
|
56
|
+
interface Span {
|
|
57
|
+
readonly start: number;
|
|
58
|
+
readonly length: number;
|
|
59
|
+
}
|
|
60
|
+
interface LaidBar extends Span {
|
|
61
|
+
readonly meter: string;
|
|
62
|
+
readonly tempo: readonly LaidTempo[];
|
|
63
|
+
readonly marks: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
interface Group {
|
|
66
|
+
readonly start: number;
|
|
67
|
+
readonly end: number;
|
|
68
|
+
readonly midis: readonly number[];
|
|
69
|
+
readonly velocity: number;
|
|
70
|
+
readonly release: number;
|
|
71
|
+
readonly lyric: Option.Option<string>;
|
|
72
|
+
}
|
|
73
|
+
type Line = readonly Group[];
|
|
74
|
+
type Source = {
|
|
75
|
+
readonly kind: "instrument";
|
|
76
|
+
readonly instrument: string;
|
|
77
|
+
readonly program: number;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "kit";
|
|
80
|
+
};
|
|
81
|
+
interface PlannedPart {
|
|
82
|
+
readonly part: Part;
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly source: Source;
|
|
85
|
+
readonly lines: readonly Line[];
|
|
86
|
+
readonly controls: readonly TimelineControl[];
|
|
87
|
+
readonly mix: TrackMix;
|
|
88
|
+
}
|
|
89
|
+
interface PlannedBus {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly level: Level;
|
|
92
|
+
}
|
|
93
|
+
interface Plan {
|
|
94
|
+
readonly parts: readonly PlannedPart[];
|
|
95
|
+
readonly buses: readonly PlannedBus[];
|
|
96
|
+
readonly instruments: ReadonlyMap<number, string>;
|
|
97
|
+
readonly drumVoices: ReadonlyMap<number, string>;
|
|
98
|
+
}
|
|
99
|
+
interface Written {
|
|
100
|
+
readonly text: string;
|
|
101
|
+
readonly plan: Plan;
|
|
102
|
+
readonly bars: readonly LaidBar[];
|
|
103
|
+
}
|
|
104
|
+
export { Written as t };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "./index-Bc9UT9HF.mjs";
|
|
2
|
+
import { d as Song } from "./song-UZ4T_dj9.mjs";
|
|
3
|
+
import { t as Sounding } from "./sounding-BCyExbPp.mjs";
|
|
4
|
+
import "./read-song-CsW4kd7v.mjs";
|
|
5
|
+
import { Effect, Schema } from "effect";
|
|
6
|
+
import "effect/cli";
|
|
7
|
+
import "effect/process";
|
|
8
|
+
import "effect/PlatformError";
|
|
9
|
+
type Severity = "off" | "warn" | "error";
|
|
10
|
+
type RuleOptions = Readonly<Record<string, unknown>>;
|
|
11
|
+
type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];
|
|
12
|
+
declare const NotUtf8Error_base: Schema.Class<NotUtf8Error, Schema.TaggedStruct<"NotUtf8Error", {
|
|
13
|
+
readonly path: Schema.String;
|
|
14
|
+
}>, import("effect/Cause").YieldableError & {
|
|
15
|
+
readonly brand: unique symbol;
|
|
16
|
+
}>;
|
|
17
|
+
declare class NotUtf8Error extends NotUtf8Error_base {}
|
|
18
|
+
interface PathspecRequest<Config> {
|
|
19
|
+
readonly config: Config;
|
|
20
|
+
readonly patterns?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
interface Report {
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly line: number;
|
|
25
|
+
readonly column?: number;
|
|
26
|
+
readonly detail?: string;
|
|
27
|
+
}
|
|
28
|
+
interface RuleContext {
|
|
29
|
+
readonly filename: string;
|
|
30
|
+
readonly song: Song;
|
|
31
|
+
readonly soundings: readonly Sounding[];
|
|
32
|
+
readonly options: RuleOptions;
|
|
33
|
+
readonly report: (report: Report) => void;
|
|
34
|
+
}
|
|
35
|
+
interface Rule {
|
|
36
|
+
readonly meta: {
|
|
37
|
+
readonly description: string;
|
|
38
|
+
};
|
|
39
|
+
readonly check: (context: RuleContext) => void;
|
|
40
|
+
}
|
|
41
|
+
interface Plugin {
|
|
42
|
+
readonly rules: Readonly<Record<string, Rule>>;
|
|
43
|
+
}
|
|
44
|
+
interface LintConfig {
|
|
45
|
+
readonly extends?: readonly LintConfig[];
|
|
46
|
+
readonly plugins?: Readonly<Record<string, Plugin>>;
|
|
47
|
+
readonly rules?: Readonly<Record<string, RuleEntry>>;
|
|
48
|
+
readonly ignores?: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
interface FumxConfig {
|
|
51
|
+
readonly lint?: LintConfig;
|
|
52
|
+
}
|
|
53
|
+
interface Diagnostic {
|
|
54
|
+
readonly path: string;
|
|
55
|
+
readonly line: number;
|
|
56
|
+
readonly column?: number;
|
|
57
|
+
readonly rule: string;
|
|
58
|
+
readonly message: string;
|
|
59
|
+
readonly detail?: string;
|
|
60
|
+
readonly severity: Exclude<Severity, "off">;
|
|
61
|
+
}
|
|
62
|
+
declare const defineRule: (rule: Rule) => Rule;
|
|
63
|
+
declare const definePlugin: (plugin: Plugin) => Plugin;
|
|
64
|
+
declare const LintError_base: Schema.Class<LintError, Schema.TaggedStruct<"LintError", {
|
|
65
|
+
readonly message: Schema.String;
|
|
66
|
+
}>, import("effect/Cause").YieldableError & {
|
|
67
|
+
readonly brand: unique symbol;
|
|
68
|
+
}>;
|
|
69
|
+
declare class LintError extends LintError_base {}
|
|
70
|
+
type Read = (path: string) => Effect.Effect<string, LintError | NotUtf8Error>;
|
|
71
|
+
export { Diagnostic as a, Plugin as c, RuleContext as d, PathspecRequest as f, Severity as h, defineRule as i, Report as l, RuleOptions as m, LintError as n, FumxConfig as o, RuleEntry as p, definePlugin as r, LintConfig as s, Read as t, Rule as u };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as PluginUse, c as Hit, d as Slice, i as PluginArgument, l as Lyric, n as PlayParam, o as PluginValue, r as Plugin, s as Edit, t as Effect, u as Note } from "./index-Bc9UT9HF.mjs";
|
|
2
|
+
import { a as Controller, c as Mixer, d as Song, f as SongSchema, h as Track, i as Control, l as MixerParameter, m as TempoStep, n as Automation, o as MIXER_PARAMETERS, p as Tempo, r as Bar, s as Meter, t as Amount, u as Role } from "./song-UZ4T_dj9.mjs";
|
|
3
|
+
import { a as NamedSpan, c as Named, i as readSong, n as SongSource, o as Outline, r as SourceIssue, s as SourceComment, t as SongFiles } from "./read-song-CsW4kd7v.mjs";
|
|
4
|
+
import { t as TICKS_PER_WHOLE } from "./index-KxUilka8.mjs";
|
|
5
|
+
export { type Amount, type Automation, type Bar, type Control, type Controller, type Edit, type Effect, type Hit, type Lyric, MIXER_PARAMETERS, type Meter, type Mixer, type MixerParameter, type Named, type NamedSpan, type Note, type Outline, type PlayParam, type Plugin, type PluginArgument, type PluginUse, type PluginValue, type Role, type Slice, type Song, type SongFiles, SongSchema, type SongSource, type SourceComment, type SourceIssue, TICKS_PER_WHOLE, type Tempo, type TempoStep, type Track, readSong };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Array, Boolean, Effect, Function, Match, Option, Order, Predicate, Record, Result, Schema, String as String$1, pipe } from "effect";
|
|
2
|
+
import { t as readSong } from "./read-song-DW8MLsln.mjs";
|
|
3
|
+
import { r as soundingsOf } from "./sounding-DYDZFp4e.mjs";
|
|
4
|
+
import { groupsOf } from "@r_masseater/masseater-utils/text";
|
|
5
|
+
// src/features/check-songs/model/define.ts
|
|
6
|
+
const defineRule = (rule) => rule;
|
|
7
|
+
const definePlugin = (plugin) => plugin;
|
|
8
|
+
// ../lint-host/src/entities/rule/model/setting.ts
|
|
9
|
+
const NO_OPTIONS = {};
|
|
10
|
+
const settingOf = (entry) => Match.value(entry).pipe(Match.when(Match.string, (severity) => ({
|
|
11
|
+
severity,
|
|
12
|
+
options: NO_OPTIONS
|
|
13
|
+
})), Match.orElse(([severity, options]) => ({
|
|
14
|
+
severity,
|
|
15
|
+
options: options ?? NO_OPTIONS
|
|
16
|
+
})));
|
|
17
|
+
const optionsOf = (entry) => Match.value(entry).pipe(Match.when(Match.string, () => Option.none()), Match.orElse(([, options]) => Option.fromUndefinedOr(options)));
|
|
18
|
+
const overridden = (earlier, later) => pipe(optionsOf(later), Option.orElse(() => optionsOf(earlier)), Option.match({
|
|
19
|
+
onNone: () => later,
|
|
20
|
+
onSome: (options) => [settingOf(later).severity, options]
|
|
21
|
+
}));
|
|
22
|
+
const mergedRules = (layers) => {
|
|
23
|
+
const merged = {};
|
|
24
|
+
for (const [name, later] of pipe(layers, Array.flatMap((layer) => Record.toEntries(layer ?? {})))) merged[name] = pipe(Record.get(merged, name), Option.match({
|
|
25
|
+
onNone: () => later,
|
|
26
|
+
onSome: (earlier) => overridden(earlier, later)
|
|
27
|
+
}));
|
|
28
|
+
return merged;
|
|
29
|
+
};
|
|
30
|
+
// ../lint-host/src/entities/rule/model/severity.ts
|
|
31
|
+
const reportedSeverity = (setting) => Match.value(setting.severity).pipe(Match.when("warn", () => "warn"), Match.orElse(() => "error"));
|
|
32
|
+
// ../lint-host/src/entities/rule/model/layers.ts
|
|
33
|
+
const mergedRecords = (records) => pipe(records, Array.flatMap((record) => Record.toEntries(record ?? {})), Record.fromEntries);
|
|
34
|
+
const layersOf = (config) => {
|
|
35
|
+
const { extends: bases = [], ...own } = config;
|
|
36
|
+
return [...pipe(bases, Array.flatMap(layersOf)), own];
|
|
37
|
+
};
|
|
38
|
+
const mergedLayers = (layers) => ({
|
|
39
|
+
plugins: mergedRecords(pipe(layers, Array.map((layer) => layer.plugins))),
|
|
40
|
+
rules: mergedRules(pipe(layers, Array.map((layer) => layer.rules))),
|
|
41
|
+
ignores: pipe(layers, Array.flatMap((layer) => layer.ignores ?? [])),
|
|
42
|
+
overrides: pipe(layers, Array.flatMap((layer) => layer.overrides ?? []))
|
|
43
|
+
});
|
|
44
|
+
// ../lint-host/src/shared/lib/fail.ts
|
|
45
|
+
const taggedError$1 = Schema.TaggedError;
|
|
46
|
+
var NotUtf8Error = class extends taggedError$1()("NotUtf8Error", { path: Schema.String }) {};
|
|
47
|
+
const present = Function.dual(2, (value, build) => Option.match(value, {
|
|
48
|
+
onNone: () => ({}),
|
|
49
|
+
onSome: build
|
|
50
|
+
}));
|
|
51
|
+
// ../lint-host/src/shared/lib/trace.ts
|
|
52
|
+
const SAMPLED = "01";
|
|
53
|
+
const NOT_SAMPLED = "00";
|
|
54
|
+
const LINE_START$1 = 0;
|
|
55
|
+
const flagsOf = (sampled) => Boolean.match(sampled, {
|
|
56
|
+
onFalse: () => NOT_SAMPLED,
|
|
57
|
+
onTrue: () => SAMPLED
|
|
58
|
+
});
|
|
59
|
+
Effect.currentSpan.pipe(Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`), Effect.option);
|
|
60
|
+
const byPosition = Order.combine(Order.mapInput(Order.String, (found) => found.path), Order.combine(Order.mapInput(Order.Number, (found) => found.line), Order.mapInput(Order.Number, (found) => found.column ?? LINE_START$1)));
|
|
61
|
+
const sortByPosition = (found) => Array.sort(found, byPosition);
|
|
62
|
+
// ../lint-host/src/shared/lib/diagnostic.ts
|
|
63
|
+
const diagnosticDetail = (diagnostic) => pipe([diagnostic.detail, diagnostic.context], Array.flatMap((part) => Option.toArray(Option.fromNullishOr(part))), Array.filter((part) => part !== ""), Array.map((part) => ` [${part}]`), Array.join(""));
|
|
64
|
+
const formatDiagnostic = (diagnostic) => {
|
|
65
|
+
const column = pipe(Option.fromNullishOr(diagnostic.column), Option.map((value) => `:${String(value)}`), Option.getOrElse(() => ""));
|
|
66
|
+
return `${diagnostic.path}:${String(diagnostic.line)}${column} ${diagnostic.severity} ${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`;
|
|
67
|
+
};
|
|
68
|
+
const notUtf8 = (tool) => (path) => ({
|
|
69
|
+
path,
|
|
70
|
+
line: 1,
|
|
71
|
+
column: 1,
|
|
72
|
+
rule: "utf8",
|
|
73
|
+
message: `The file is not valid UTF-8, so ${tool} cannot read it`,
|
|
74
|
+
severity: "error"
|
|
75
|
+
});
|
|
76
|
+
// ../lint-host/src/shared/lib/section.ts
|
|
77
|
+
const sectionOf = ({ name, fallback, prepare = Function.identity }) => {
|
|
78
|
+
const hasSection = (value) => Predicate.hasProperty(value, name) && Predicate.isObject(value[name]);
|
|
79
|
+
return (config) => pipe(Option.liftPredicate(config, hasSection), Option.flatMapNullishOr((value) => value[name]), Option.map(prepare), Option.getOrElse(() => fallback));
|
|
80
|
+
};
|
|
81
|
+
const pathspecsOf = ({ defaults, unowned = [] }) => ({ config, patterns = [] }) => [
|
|
82
|
+
...Array.match(patterns, {
|
|
83
|
+
onEmpty: () => defaults,
|
|
84
|
+
onNonEmpty: Function.identity
|
|
85
|
+
}),
|
|
86
|
+
...unowned,
|
|
87
|
+
...pipe(config.ignores ?? [], Array.map((glob) => `:(glob,exclude)${glob}`))
|
|
88
|
+
];
|
|
89
|
+
// src/features/check-songs/model/extend.ts
|
|
90
|
+
const flattenConfig = (config) => {
|
|
91
|
+
const { plugins, rules, ignores } = mergedLayers(layersOf(config));
|
|
92
|
+
return {
|
|
93
|
+
plugins,
|
|
94
|
+
rules,
|
|
95
|
+
ignores
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
// src/features/check-songs/model/read.ts
|
|
99
|
+
const SEPARATOR$1 = "/";
|
|
100
|
+
const pathOf = (input) => `${input.root}${SEPARATOR$1}${input.file}`;
|
|
101
|
+
const readSongFile = Effect.fn("fumx.lint.read")(function* readSongFile(input) {
|
|
102
|
+
const source = yield* readSong({
|
|
103
|
+
path: pathOf(input),
|
|
104
|
+
read: input.read
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
file: input.file,
|
|
108
|
+
source
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
// src/features/check-songs/model/resolve.ts
|
|
112
|
+
const SEPARATOR = "/";
|
|
113
|
+
const START = 0;
|
|
114
|
+
const ENABLED = settingOf("error");
|
|
115
|
+
const idOf = (plugin, name) => `${plugin}${SEPARATOR}${name}`;
|
|
116
|
+
const pluginOf = (id) => pipe(String$1.indexOf(SEPARATOR)(id), Option.match({
|
|
117
|
+
onNone: () => id,
|
|
118
|
+
onSome: (slash) => String$1.slice(START, slash)(id)
|
|
119
|
+
}));
|
|
120
|
+
const rulesOf$2 = (config) => ([plugin, value]) => pipe(Record.toEntries(value.rules), Array.map(([name, rule]) => {
|
|
121
|
+
const id = idOf(plugin, name);
|
|
122
|
+
return {
|
|
123
|
+
id,
|
|
124
|
+
rule,
|
|
125
|
+
setting: pipe(config.rules ?? {}, Record.get(id), Option.map(settingOf), Option.getOrElse(() => ENABLED))
|
|
126
|
+
};
|
|
127
|
+
}), Array.filter(({ setting }) => setting.severity !== "off"));
|
|
128
|
+
const resolve = (config) => pipe(Record.toEntries(config.plugins ?? {}), Array.flatMap(rulesOf$2(config)));
|
|
129
|
+
const unknownPlugins = (config) => pipe(Record.keys(config.rules ?? {}), Array.map(pluginOf), Array.filter((plugin) => !Record.has(config.plugins ?? {}, plugin)), Array.dedupe);
|
|
130
|
+
const ruleNameOf = (id) => pipe(String$1.indexOf(SEPARATOR)(id), Option.match({
|
|
131
|
+
onNone: () => "",
|
|
132
|
+
onSome: (slash) => String$1.slice(slash + 1)(id)
|
|
133
|
+
}));
|
|
134
|
+
const isKnownRule = (config) => (id) => pipe(Record.get(config.plugins ?? {}, pluginOf(id)), Option.match({
|
|
135
|
+
onNone: () => true,
|
|
136
|
+
onSome: (plugin) => Record.has(plugin.rules, ruleNameOf(id))
|
|
137
|
+
}));
|
|
138
|
+
const unknownRules = (config) => pipe(Record.keys(config.rules ?? {}), Array.filter((id) => !isKnownRule(config)(id)));
|
|
139
|
+
// src/shared/lib/errors.ts
|
|
140
|
+
const taggedError = Schema.TaggedError;
|
|
141
|
+
var LintError = class extends taggedError()("LintError", { message: Schema.String }) {};
|
|
142
|
+
const failedWith = (message) => (cause) => LintError.make({ message: `${message}: ${String(cause)}` });
|
|
143
|
+
// src/features/check-songs/model/suppressions.ts
|
|
144
|
+
const DIRECTIVE = /^fumx-(?<kind>ignore-next-line|ignore-file|ignore|disable|enable)(?:\s(?<rest>[\s\S]*))?$/u;
|
|
145
|
+
const REASON = /\s-{2,}(?:\s|$)/u;
|
|
146
|
+
const BLOCK_START = "/*";
|
|
147
|
+
const BLOCK_END = "*/";
|
|
148
|
+
const LIST = ",";
|
|
149
|
+
const NEXT = 1;
|
|
150
|
+
const LINE_START = 0;
|
|
151
|
+
const kindOf = (text) => Match.value(text).pipe(Match.when("ignore-file", () => "ignore-file"), Match.when("ignore-next-line", () => "ignore-next-line"), Match.when("disable", () => "disable"), Match.when("enable", () => "enable"), Match.orElse(() => "ignore"));
|
|
152
|
+
const bodyOf = (text) => {
|
|
153
|
+
if (String$1.startsWith(BLOCK_START)(text)) return pipe(text, String$1.slice(2), String$1.replace(BLOCK_END, ""), String$1.trim);
|
|
154
|
+
return pipe(text, String$1.slice(2), String$1.trim);
|
|
155
|
+
};
|
|
156
|
+
const rulesOf$1 = (rest) => pipe(String$1.split(` ${rest}`, REASON), Array.head, Option.getOrElse(() => ""), String$1.split(LIST), Array.map(String$1.trim), Array.filter(String$1.isNonEmpty));
|
|
157
|
+
const directiveOf = (comment) => pipe(groupsOf(DIRECTIVE)(bodyOf(comment.text)), Option.map((groups) => ({
|
|
158
|
+
line: comment.line,
|
|
159
|
+
column: comment.column,
|
|
160
|
+
kind: kindOf(groups["kind"] ?? ""),
|
|
161
|
+
rules: rulesOf$1(groups["rest"] ?? "")
|
|
162
|
+
})));
|
|
163
|
+
const names = (rule) => (directive) => !Array.isReadonlyArrayNonEmpty(directive.rules) || Array.contains(directive.rules, rule);
|
|
164
|
+
const isRange = (directive) => directive.kind === "disable" || directive.kind === "enable";
|
|
165
|
+
const coversLine = (found) => (directive) => names(found.rule)(directive) && Match.value(directive.kind).pipe(Match.when("ignore-file", () => true), Match.when("ignore-next-line", () => directive.line + NEXT === found.line), Match.when("ignore", () => directive.line === found.line), Match.orElse(() => false));
|
|
166
|
+
const isAfter = (found) => (directive) => directive.line < found.line || directive.line === found.line && directive.column <= (found.column ?? LINE_START);
|
|
167
|
+
const insideRange = (directives) => (found) => pipe(directives, Array.filter((directive) => isRange(directive) && isAfter(found)(directive) && names(found.rule)(directive)), Array.last, Option.exists((directive) => directive.kind === "disable"));
|
|
168
|
+
const suppressionsOf = (comments) => {
|
|
169
|
+
const directives = pipe(comments, Array.map(directiveOf), Array.getSomes);
|
|
170
|
+
return (found) => pipe(directives, Array.some(coversLine(found))) || insideRange(directives)(found);
|
|
171
|
+
};
|
|
172
|
+
// src/features/check-songs/model/run.ts
|
|
173
|
+
const diagnosticOf = (path, rule) => (report) => ({
|
|
174
|
+
path,
|
|
175
|
+
line: report.line,
|
|
176
|
+
rule: rule.id,
|
|
177
|
+
message: report.message,
|
|
178
|
+
severity: reportedSeverity(rule.setting),
|
|
179
|
+
...present(Option.fromNullishOr(report.column), (column) => ({ column })),
|
|
180
|
+
...present(Option.fromNullishOr(report.detail), (detail) => ({ detail }))
|
|
181
|
+
});
|
|
182
|
+
const runOne = (input, soundings) => Effect.fn("fumx.lint.rule")(function* run(rule) {
|
|
183
|
+
yield* Effect.annotateCurrentSpan({ "fumx.lint.rule": rule.id });
|
|
184
|
+
const reports = [];
|
|
185
|
+
yield* Effect.try({
|
|
186
|
+
try: () => {
|
|
187
|
+
rule.rule.check({
|
|
188
|
+
filename: input.path,
|
|
189
|
+
song: input.song,
|
|
190
|
+
soundings,
|
|
191
|
+
options: rule.setting.options,
|
|
192
|
+
report: (report) => {
|
|
193
|
+
reports.push(report);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
catch: failedWith(`${rule.id} failed`)
|
|
198
|
+
});
|
|
199
|
+
return pipe(reports, Array.map(diagnosticOf(input.path, rule)));
|
|
200
|
+
});
|
|
201
|
+
const runRules = Effect.fn("fumx.lint.rules")(function* runRules(input) {
|
|
202
|
+
const soundings = soundingsOf(input.song);
|
|
203
|
+
const suppressed = suppressionsOf(input.comments);
|
|
204
|
+
const found = yield* pipe(input.rules, Effect.forEach(runOne(input, soundings), { concurrency: 1 }));
|
|
205
|
+
return pipe(Array.flatten(found), Array.filter((diagnostic) => !suppressed(diagnostic)));
|
|
206
|
+
});
|
|
207
|
+
// src/app/run-lint.ts
|
|
208
|
+
const PARSE_RULE = "fumx/parse";
|
|
209
|
+
const failIfAny = (problem) => (names) => Array.match(names, {
|
|
210
|
+
onEmpty: () => Effect.void,
|
|
211
|
+
onNonEmpty: (found) => Effect.fail(LintError.make({ message: `${problem}: ${Array.join(found, ", ")}` }))
|
|
212
|
+
});
|
|
213
|
+
const UNKNOWN_PLUGINS = failIfAny("rules name plugins that are not configured");
|
|
214
|
+
const UNKNOWN_RULES = failIfAny("rules name rules that their plugins do not have");
|
|
215
|
+
const checkPlugins = (config) => {
|
|
216
|
+
const rules = UNKNOWN_RULES(unknownRules(config));
|
|
217
|
+
return UNKNOWN_PLUGINS(unknownPlugins(config)).pipe(Effect.andThen(rules));
|
|
218
|
+
};
|
|
219
|
+
const rulesOf = (config) => {
|
|
220
|
+
const flat = flattenConfig(config ?? {});
|
|
221
|
+
return checkPlugins(flat).pipe(Effect.as(resolve(flat)));
|
|
222
|
+
};
|
|
223
|
+
const parseDiagnosticsOf = (file) => (issues) => pipe(issues, Array.map((issue) => ({
|
|
224
|
+
path: file,
|
|
225
|
+
line: issue.line,
|
|
226
|
+
column: issue.column,
|
|
227
|
+
rule: PARSE_RULE,
|
|
228
|
+
message: issue.message,
|
|
229
|
+
severity: "error"
|
|
230
|
+
})));
|
|
231
|
+
const lintFile = (rules) => (song) => {
|
|
232
|
+
if (song.source.status === "invalid") return Effect.succeed(parseDiagnosticsOf(song.file)(song.source.issues));
|
|
233
|
+
return runRules({
|
|
234
|
+
path: song.file,
|
|
235
|
+
comments: song.source.outline.comments,
|
|
236
|
+
song: song.source.song,
|
|
237
|
+
rules
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
const notFound = (path) => Effect.fail(LintError.make({ message: `could not read ${path}` }));
|
|
241
|
+
const readerOf = (input) => (path) => {
|
|
242
|
+
if (path === input.path) return Effect.succeed(input.text);
|
|
243
|
+
return (input.read ?? notFound)(path);
|
|
244
|
+
};
|
|
245
|
+
const lintTracked = (rules, input) => Effect.fnUntraced(function* lintOne(file) {
|
|
246
|
+
const path = pathOf({
|
|
247
|
+
root: input.root,
|
|
248
|
+
file
|
|
249
|
+
});
|
|
250
|
+
const read = yield* Effect.result(input.read(path));
|
|
251
|
+
if (Result.isFailure(read) && Schema.is(NotUtf8Error)(read.failure)) return [notUtf8("fumx lint")(file)];
|
|
252
|
+
const reader = Result.match(read, {
|
|
253
|
+
onFailure: () => input.read,
|
|
254
|
+
onSuccess: (text) => readerOf({
|
|
255
|
+
path,
|
|
256
|
+
text,
|
|
257
|
+
read: input.read
|
|
258
|
+
})
|
|
259
|
+
});
|
|
260
|
+
const source = yield* readSongFile({
|
|
261
|
+
root: input.root,
|
|
262
|
+
file,
|
|
263
|
+
read: reader
|
|
264
|
+
});
|
|
265
|
+
return yield* lintFile(rules)(source);
|
|
266
|
+
});
|
|
267
|
+
const lint = Effect.fn("fumx.lint.lint")(function* lint(input) {
|
|
268
|
+
const rules = yield* rulesOf(input.config);
|
|
269
|
+
const found = yield* Effect.forEach(input.files, lintTracked(rules, input), { concurrency: "unbounded" });
|
|
270
|
+
return sortByPosition(Array.flatten(found));
|
|
271
|
+
});
|
|
272
|
+
const lintText = Effect.fn("fumx.lint.lintText")(function* lintText(input) {
|
|
273
|
+
const rules = yield* rulesOf(input.config);
|
|
274
|
+
const source = yield* readSong({
|
|
275
|
+
path: input.path,
|
|
276
|
+
read: readerOf(input)
|
|
277
|
+
});
|
|
278
|
+
const found = yield* lintFile(rules)({
|
|
279
|
+
file: input.path,
|
|
280
|
+
source
|
|
281
|
+
});
|
|
282
|
+
return sortByPosition(found);
|
|
283
|
+
});
|
|
284
|
+
// src/app/section.ts
|
|
285
|
+
const fumxSection = sectionOf({
|
|
286
|
+
name: "fumx",
|
|
287
|
+
fallback: {}
|
|
288
|
+
});
|
|
289
|
+
const lintSection = (config) => pipe(Option.fromUndefinedOr(fumxSection(config).lint), Option.match({
|
|
290
|
+
onNone: () => ({}),
|
|
291
|
+
onSome: flattenConfig
|
|
292
|
+
}));
|
|
293
|
+
const songPathspecs = pathspecsOf({ defaults: ["*.fumx"] });
|
|
294
|
+
export { LintError as a, defineRule as c, lintText as i, songPathspecs as n, formatDiagnostic as o, lint as r, definePlugin as s, lintSection as t };
|
|
295
|
+
|
|
296
|
+
//# sourceMappingURL=lint-Bnl4l0aI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-Bnl4l0aI.mjs","names":["Arr","Rec","Arr","Rec","taggedError","Fn","LINE_START","Bool","Arr","Arr","Fn","Arr","SEPARATOR","Str","rulesOf","Rec","Arr","Str","rulesOf","Arr","Arr","Arr"],"sources":["../src/features/check-songs/model/define.ts","../../lint-host/src/entities/rule/model/setting.ts","../../lint-host/src/entities/rule/model/severity.ts","../../lint-host/src/entities/rule/model/layers.ts","../../lint-host/src/shared/lib/fail.ts","../../lint-host/src/shared/lib/present.ts","../../lint-host/src/shared/lib/trace.ts","../../lint-host/src/shared/lib/diagnostic.ts","../../lint-host/src/shared/lib/section.ts","../src/features/check-songs/model/extend.ts","../src/features/check-songs/model/read.ts","../src/features/check-songs/model/resolve.ts","../src/shared/lib/errors.ts","../src/features/check-songs/model/suppressions.ts","../src/features/check-songs/model/run.ts","../src/app/run-lint.ts","../src/app/section.ts"],"sourcesContent":["import type { Plugin, Rule } from \"./types.ts\";\n\nexport const defineRule = (rule: Rule): Rule => rule;\n\nexport const definePlugin = (plugin: Plugin): Plugin => plugin;\n","import { Array as Arr, Match, Option, Record as Rec, pipe } from \"effect\";\n\nexport type Severity = \"off\" | \"warn\" | \"error\";\n\nexport type RuleOptions = Readonly<Record<string, unknown>>;\n\nexport type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];\n\nexport interface Setting {\n readonly severity: Severity;\n readonly options: RuleOptions;\n}\n\nconst NO_OPTIONS: RuleOptions = {};\n\nexport const settingOf = (entry: RuleEntry): Setting =>\n Match.value(entry).pipe(\n Match.when(Match.string, (severity): Setting => ({ severity, options: NO_OPTIONS })),\n Match.orElse(([severity, options]): Setting => ({\n severity,\n options: options ?? NO_OPTIONS,\n })),\n );\n\nconst optionsOf = (entry: RuleEntry): Option.Option<RuleOptions> =>\n Match.value(entry).pipe(\n Match.when(Match.string, () => Option.none()),\n Match.orElse(([, options]) => Option.fromUndefinedOr(options)),\n );\n\nconst overridden = (earlier: RuleEntry, later: RuleEntry): RuleEntry =>\n pipe(\n optionsOf(later),\n Option.orElse(() => optionsOf(earlier)),\n Option.match({\n onNone: () => later,\n onSome: (options): RuleEntry => [settingOf(later).severity, options],\n }),\n );\n\nexport const mergedRules = (\n layers: readonly (Readonly<Record<string, RuleEntry>> | undefined)[],\n): Readonly<Record<string, RuleEntry>> => {\n const merged: Record<string, RuleEntry> = {};\n for (const [name, later] of pipe(\n layers,\n Arr.flatMap((layer) => Rec.toEntries(layer ?? {})),\n )) {\n merged[name] = pipe(\n Rec.get(merged, name),\n Option.match({\n onNone: () => later,\n onSome: (earlier) => overridden(earlier, later),\n }),\n );\n }\n return merged;\n};\n","import { Match } from \"effect\";\n\nimport type { Setting, Severity } from \"./setting.ts\";\n\nexport const reportedSeverity = (setting: Setting): Exclude<Severity, \"off\"> =>\n Match.value(setting.severity).pipe(\n Match.when(\"warn\", (): Exclude<Severity, \"off\"> => \"warn\"),\n Match.orElse((): Exclude<Severity, \"off\"> => \"error\"),\n );\n","import { Array as Arr, Record as Rec, pipe } from \"effect\";\n\nimport { mergedRules } from \"./setting.ts\";\nimport type { RuleEntry } from \"./setting.ts\";\n\nexport interface Layer<Plugin, Override> {\n readonly plugins?: Readonly<Record<string, Plugin>>;\n readonly rules?: Readonly<Record<string, RuleEntry>>;\n readonly ignores?: readonly string[];\n readonly overrides?: readonly Override[];\n}\n\nexport interface Merged<Plugin, Override> {\n readonly plugins: Readonly<Record<string, Plugin>>;\n readonly rules: Readonly<Record<string, RuleEntry>>;\n readonly ignores: readonly string[];\n readonly overrides: readonly Override[];\n}\n\nexport const mergedRecords = <Value>(\n records: readonly (Readonly<Record<string, Value>> | undefined)[],\n): Readonly<Record<string, Value>> =>\n pipe(\n records,\n Arr.flatMap((record) => Rec.toEntries(record ?? {})),\n Rec.fromEntries,\n );\n\nexport const layersOf = <Config extends { readonly extends?: readonly Config[] }>(\n config: Config,\n): readonly Omit<Config, \"extends\">[] => {\n const { extends: bases = [], ...own } = config;\n return [...pipe(bases, Arr.flatMap(layersOf)), own];\n};\n\nexport const mergedLayers = <Plugin, Override>(\n layers: readonly Layer<Plugin, Override>[],\n): Merged<Plugin, Override> => ({\n plugins: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.plugins),\n ),\n ),\n rules: mergedRules(\n pipe(\n layers,\n Arr.map((layer) => layer.rules),\n ),\n ),\n ignores: pipe(\n layers,\n Arr.flatMap((layer) => layer.ignores ?? []),\n ),\n overrides: pipe(\n layers,\n Arr.flatMap((layer) => layer.overrides ?? []),\n ),\n});\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class NotUtf8Error extends taggedError<NotUtf8Error, { readonly brand: unique symbol }>()(\n \"NotUtf8Error\",\n { path: Schema.String },\n) {}\n\nexport type FailWith<Failure> = (message: string) => (cause: unknown) => Failure;\n","import { Function as Fn, Option } from \"effect\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const present: {\n <Value, Fields extends object>(\n build: (value: Value) => Fields,\n ): (value: Option.Option<Value>) => Partial<Fields>;\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields> => Option.match(value, { onNone: (): Partial<Fields> => ({}), onSome: build }),\n);\n","import { Array as Arr, Boolean as Bool, Effect, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst SAMPLED = \"01\";\nconst NOT_SAMPLED = \"00\";\n\nexport interface Positioned {\n readonly path: string;\n readonly line: number;\n readonly column?: number;\n}\n\nconst LINE_START = 0;\n\nconst flagsOf = (sampled: boolean): string =>\n Bool.match(sampled, { onFalse: () => NOT_SAMPLED, onTrue: () => SAMPLED });\n\nexport const traceparent: Effect.Effect<Option.Option<string>> = Effect.currentSpan.pipe(\n Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`),\n Effect.option,\n);\n\nconst byPosition: Order.Order<Positioned> = Order.combine(\n Order.mapInput(Order.String, (found: Positioned) => found.path),\n Order.combine(\n Order.mapInput(Order.Number, (found: Positioned) => found.line),\n Order.mapInput(Order.Number, (found: Positioned) => found.column ?? LINE_START),\n ),\n);\n\nexport const sortByPosition = <Found extends Positioned>(found: readonly Found[]): Found[] =>\n Arr.sort(found, byPosition);\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nexport interface Reportable {\n readonly path: string;\n readonly line: number;\n readonly column?: number | undefined;\n readonly rule: string;\n readonly message: string;\n readonly detail?: string | undefined;\n readonly context?: string | undefined;\n readonly severity: string;\n}\n\nexport const diagnosticDetail = (diagnostic: Reportable): string =>\n pipe(\n [diagnostic.detail, diagnostic.context],\n Arr.flatMap((part) => Option.toArray(Option.fromNullishOr(part))),\n Arr.filter((part) => part !== \"\"),\n Arr.map((part) => ` [${part}]`),\n Arr.join(\"\"),\n );\n\nexport const formatDiagnostic = (diagnostic: Reportable): string => {\n const column = pipe(\n Option.fromNullishOr(diagnostic.column),\n Option.map((value) => `:${String(value)}`),\n Option.getOrElse(() => \"\"),\n );\n return `${diagnostic.path}:${String(diagnostic.line)}${column} ${diagnostic.severity} ${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`;\n};\n\nexport interface NotUtf8 {\n readonly path: string;\n readonly line: number;\n readonly column: number;\n readonly rule: string;\n readonly message: string;\n readonly severity: \"error\";\n}\n\nexport const notUtf8 =\n (tool: string) =>\n (path: string): NotUtf8 => ({\n path,\n line: 1,\n column: 1,\n rule: \"utf8\",\n message: `The file is not valid UTF-8, so ${tool} cannot read it`,\n severity: \"error\",\n });\n","import { Array as Arr, Function as Fn, Option, Predicate, pipe } from \"effect\";\n\nexport interface SectionRequest<Config extends object> {\n readonly name: string;\n readonly fallback: Config;\n readonly prepare?: (section: Config) => Config;\n}\n\nexport const sectionOf = <Config extends object>({\n name,\n fallback,\n prepare = Fn.identity,\n}: SectionRequest<Config>): ((config: unknown) => Config) => {\n const hasSection = (value: unknown): value is Readonly<Record<string, Config>> =>\n Predicate.hasProperty(value, name) && Predicate.isObject(value[name]);\n return (config) =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.flatMapNullishOr((value) => value[name]),\n Option.map(prepare),\n Option.getOrElse(() => fallback),\n );\n};\n\nexport interface Ignoring {\n readonly ignores?: readonly string[] | undefined;\n}\n\nexport interface Pathspecs {\n readonly defaults: readonly string[];\n readonly unowned?: readonly string[];\n}\n\nexport const pathspecsOf =\n ({ defaults, unowned = [] }: Pathspecs) =>\n ({\n config,\n patterns = [],\n }: {\n readonly config: Ignoring;\n readonly patterns?: readonly string[];\n }): readonly string[] => [\n ...Arr.match(patterns, { onEmpty: () => defaults, onNonEmpty: Fn.identity }),\n ...unowned,\n ...pipe(\n config.ignores ?? [],\n Arr.map((glob) => `:(glob,exclude)${glob}`),\n ),\n ];\n","import { layersOf, mergedLayers } from \"@masseater.dev/lint-host\";\n\nimport type { LintConfig } from \"./types.ts\";\n\nexport const flattenConfig = (config: LintConfig): LintConfig => {\n const { plugins, rules, ignores } = mergedLayers(layersOf(config));\n return { plugins, rules, ignores };\n};\n","import type { NotUtf8Error } from \"@masseater.dev/lint-host\";\nimport { Effect } from \"effect\";\n\nimport { readSong } from \"#/features/read-song/@x/check-songs.ts\";\nimport type { SongSource } from \"#/features/read-song/@x/check-songs.ts\";\nimport type { LintError } from \"#/shared/lib/errors.ts\";\n\nconst SEPARATOR = \"/\";\n\nexport interface SongFile {\n readonly file: string;\n readonly source: SongSource;\n}\n\nexport type Read = (path: string) => Effect.Effect<string, LintError | NotUtf8Error>;\n\nexport interface ReadInput {\n readonly root: string;\n readonly file: string;\n readonly read: Read;\n}\n\nexport const pathOf = (input: Omit<ReadInput, \"read\">): string =>\n `${input.root}${SEPARATOR}${input.file}`;\n\nexport const readSongFile = Effect.fn(\"fumx.lint.read\")(function* readSongFile(input: ReadInput) {\n const source = yield* readSong({ path: pathOf(input), read: input.read });\n return { file: input.file, source } satisfies SongFile;\n});\n","import { settingOf } from \"@masseater.dev/lint-host\";\nimport type { Setting } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport type { LintConfig, Plugin, Rule } from \"./types.ts\";\n\nconst SEPARATOR = \"/\";\nconst START = 0;\nconst ENABLED: Setting = settingOf(\"error\");\n\nexport interface ResolvedRule {\n readonly id: string;\n readonly rule: Rule;\n readonly setting: Setting;\n}\n\ntype PluginEntry = readonly [string, Plugin];\n\nconst idOf = (plugin: string, name: string): string => `${plugin}${SEPARATOR}${name}`;\n\nconst pluginOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => id,\n onSome: (slash) => Str.slice(START, slash)(id),\n }),\n );\n\nconst rulesOf =\n (config: LintConfig) =>\n ([plugin, value]: PluginEntry): readonly ResolvedRule[] =>\n pipe(\n Rec.toEntries(value.rules),\n Arr.map(([name, rule]): ResolvedRule => {\n const id = idOf(plugin, name);\n return {\n id,\n rule,\n setting: pipe(\n config.rules ?? {},\n Rec.get(id),\n Option.map(settingOf),\n Option.getOrElse(() => ENABLED),\n ),\n };\n }),\n Arr.filter(({ setting }) => setting.severity !== \"off\"),\n );\n\nexport const resolve = (config: LintConfig): readonly ResolvedRule[] =>\n pipe(Rec.toEntries(config.plugins ?? {}), Arr.flatMap(rulesOf(config)));\n\nexport const unknownPlugins = (config: LintConfig): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.map(pluginOf),\n Arr.filter((plugin) => !Rec.has(config.plugins ?? {}, plugin)),\n Arr.dedupe,\n );\n\nconst ruleNameOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => \"\",\n onSome: (slash) => Str.slice(slash + SEPARATOR.length)(id),\n }),\n );\n\nconst isKnownRule =\n (config: LintConfig) =>\n (id: string): boolean =>\n pipe(\n Rec.get(config.plugins ?? {}, pluginOf(id)),\n Option.match({\n onNone: () => true,\n onSome: (plugin) => Rec.has(plugin.rules, ruleNameOf(id)),\n }),\n );\n\nexport const unknownRules = (config: LintConfig): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.filter((id) => !isKnownRule(config)(id)),\n );\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class LintError extends taggedError<LintError, { readonly brand: unique symbol }>()(\n \"LintError\",\n { message: Schema.String },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): LintError =>\n LintError.make({ message: `${message}: ${String(cause)}` });\n","import { groupsOf } from \"@r_masseater/masseater-utils/text\";\nimport { Array as Arr, Match, Option, String as Str, pipe } from \"effect\";\n\nimport type { SourceComment } from \"#/features/read-song/@x/check-songs.ts\";\n\nconst DIRECTIVE =\n /^fumx-(?<kind>ignore-next-line|ignore-file|ignore|disable|enable)(?:\\s(?<rest>[\\s\\S]*))?$/u;\nconst REASON = /\\s-{2,}(?:\\s|$)/u;\nconst LINE_MARK = \"//\";\nconst BLOCK_START = \"/*\";\nconst BLOCK_END = \"*/\";\nconst LIST = \",\";\nconst NEXT = 1;\nconst LINE_START = 0;\n\ntype Kind = \"ignore\" | \"ignore-next-line\" | \"ignore-file\" | \"disable\" | \"enable\";\n\ninterface Directive {\n readonly line: number;\n readonly column: number;\n readonly kind: Kind;\n readonly rules: readonly string[];\n}\n\nexport interface Suppressed {\n readonly line: number;\n readonly column?: number;\n readonly rule: string;\n}\n\nconst kindOf = (text: string): Kind =>\n Match.value(text).pipe(\n Match.when(\"ignore-file\", (): Kind => \"ignore-file\"),\n Match.when(\"ignore-next-line\", (): Kind => \"ignore-next-line\"),\n Match.when(\"disable\", (): Kind => \"disable\"),\n Match.when(\"enable\", (): Kind => \"enable\"),\n Match.orElse((): Kind => \"ignore\"),\n );\n\nconst bodyOf = (text: string): string => {\n if (Str.startsWith(BLOCK_START)(text)) {\n return pipe(text, Str.slice(BLOCK_START.length), Str.replace(BLOCK_END, \"\"), Str.trim);\n }\n return pipe(text, Str.slice(LINE_MARK.length), Str.trim);\n};\n\nconst rulesOf = (rest: string): readonly string[] =>\n pipe(\n Str.split(` ${rest}`, REASON),\n Arr.head,\n Option.getOrElse(() => \"\"),\n Str.split(LIST),\n Arr.map(Str.trim),\n Arr.filter(Str.isNonEmpty),\n );\n\nconst directiveOf = (comment: SourceComment): Option.Option<Directive> =>\n pipe(\n groupsOf(DIRECTIVE)(bodyOf(comment.text)),\n Option.map((groups) => ({\n line: comment.line,\n column: comment.column,\n kind: kindOf(groups[\"kind\"] ?? \"\"),\n rules: rulesOf(groups[\"rest\"] ?? \"\"),\n })),\n );\n\nconst names =\n (rule: string) =>\n (directive: Directive): boolean =>\n !Arr.isReadonlyArrayNonEmpty(directive.rules) || Arr.contains(directive.rules, rule);\n\nconst isRange = (directive: Directive): boolean =>\n directive.kind === \"disable\" || directive.kind === \"enable\";\n\nconst coversLine =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n names(found.rule)(directive) &&\n Match.value(directive.kind).pipe(\n Match.when(\"ignore-file\", () => true),\n Match.when(\"ignore-next-line\", () => directive.line + NEXT === found.line),\n Match.when(\"ignore\", () => directive.line === found.line),\n Match.orElse(() => false),\n );\n\nconst isAfter =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n directive.line < found.line ||\n (directive.line === found.line && directive.column <= (found.column ?? LINE_START));\n\nconst insideRange =\n (directives: readonly Directive[]) =>\n (found: Suppressed): boolean =>\n pipe(\n directives,\n Arr.filter(\n (directive) =>\n isRange(directive) && isAfter(found)(directive) && names(found.rule)(directive),\n ),\n Arr.last,\n Option.exists((directive) => directive.kind === \"disable\"),\n );\n\nexport const suppressionsOf = (\n comments: readonly SourceComment[],\n): ((found: Suppressed) => boolean) => {\n const directives = pipe(comments, Arr.map(directiveOf), Arr.getSomes);\n return (found) => pipe(directives, Arr.some(coversLine(found))) || insideRange(directives)(found);\n};\n","import { present, reportedSeverity } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { Song } from \"#/entities/song/index.ts\";\nimport { soundingsOf } from \"#/features/analyze-song/@x/check-songs.ts\";\nimport type { Sounding } from \"#/features/analyze-song/@x/check-songs.ts\";\nimport type { SourceComment } from \"#/features/read-song/@x/check-songs.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { LintError } from \"#/shared/lib/errors.ts\";\n\nimport type { ResolvedRule } from \"./resolve.ts\";\nimport { suppressionsOf } from \"./suppressions.ts\";\nimport type { Diagnostic, Report } from \"./types.ts\";\n\nexport interface RunInput {\n readonly path: string;\n readonly comments: readonly SourceComment[];\n readonly song: Song;\n readonly rules: readonly ResolvedRule[];\n}\n\nconst diagnosticOf =\n (path: string, rule: ResolvedRule) =>\n (report: Report): Diagnostic => ({\n path,\n line: report.line,\n rule: rule.id,\n message: report.message,\n severity: reportedSeverity(rule.setting),\n ...present(Option.fromNullishOr(report.column), (column) => ({ column })),\n ...present(Option.fromNullishOr(report.detail), (detail) => ({ detail })),\n });\n\nconst runOne = (\n input: RunInput,\n soundings: readonly Sounding[],\n): ((rule: ResolvedRule) => Effect.Effect<readonly Diagnostic[], LintError>) =>\n Effect.fn(\"fumx.lint.rule\")(function* run(rule: ResolvedRule) {\n yield* Effect.annotateCurrentSpan({ \"fumx.lint.rule\": rule.id });\n const reports: Report[] = [];\n yield* Effect.try({\n try: () => {\n rule.rule.check({\n filename: input.path,\n song: input.song,\n soundings,\n options: rule.setting.options,\n report: (report) => {\n reports.push(report);\n },\n });\n },\n catch: failedWith(`${rule.id} failed`),\n });\n return pipe(reports, Arr.map(diagnosticOf(input.path, rule)));\n });\n\nexport const runRules = Effect.fn(\"fumx.lint.rules\")(function* runRules(input: RunInput) {\n const soundings = soundingsOf(input.song);\n const suppressed = suppressionsOf(input.comments);\n const found = yield* pipe(\n input.rules,\n Effect.forEach(runOne(input, soundings), { concurrency: 1 }),\n );\n return pipe(\n Arr.flatten(found),\n Arr.filter((diagnostic) => !suppressed(diagnostic)),\n );\n});\n","import { NotUtf8Error, notUtf8, sortByPosition } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Effect, Result, Schema, pipe } from \"effect\";\n\nimport { readSong } from \"#/app/index.ts\";\nimport type { SourceIssue } from \"#/app/index.ts\";\nimport {\n flattenConfig,\n pathOf,\n readSongFile,\n resolve,\n runRules,\n unknownPlugins,\n unknownRules,\n} from \"#/features/check-songs/index.ts\";\nimport type {\n Diagnostic,\n LintConfig,\n Read,\n ResolvedRule,\n SongFile,\n} from \"#/features/check-songs/index.ts\";\nimport { LintError } from \"#/shared/lib/errors.ts\";\n\nconst PARSE_RULE = \"fumx/parse\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly read: Read;\n readonly config?: LintConfig;\n}\n\nexport interface TextInput {\n readonly path: string;\n readonly text: string;\n readonly read?: Read;\n readonly config?: LintConfig;\n}\n\nconst failIfAny =\n (problem: string) =>\n (names: readonly string[]): Effect.Effect<void, LintError> =>\n Arr.match(names, {\n onEmpty: () => Effect.void,\n onNonEmpty: (found) =>\n Effect.fail(LintError.make({ message: `${problem}: ${Arr.join(found, \", \")}` })),\n });\n\nconst UNKNOWN_PLUGINS = failIfAny(\"rules name plugins that are not configured\");\nconst UNKNOWN_RULES = failIfAny(\"rules name rules that their plugins do not have\");\n\nconst checkPlugins = (config: LintConfig): Effect.Effect<void, LintError> => {\n const rules = UNKNOWN_RULES(unknownRules(config));\n return UNKNOWN_PLUGINS(unknownPlugins(config)).pipe(Effect.andThen(rules));\n};\n\nconst rulesOf = (\n config: LintConfig | undefined,\n): Effect.Effect<readonly ResolvedRule[], LintError> => {\n const flat = flattenConfig(config ?? {});\n return checkPlugins(flat).pipe(Effect.as(resolve(flat)));\n};\n\nconst parseDiagnosticsOf =\n (file: string) =>\n (issues: readonly SourceIssue[]): readonly Diagnostic[] =>\n pipe(\n issues,\n Arr.map((issue): Diagnostic => ({\n path: file,\n line: issue.line,\n column: issue.column,\n rule: PARSE_RULE,\n message: issue.message,\n severity: \"error\",\n })),\n );\n\nconst lintFile =\n (rules: readonly ResolvedRule[]) =>\n (song: SongFile): Effect.Effect<readonly Diagnostic[], LintError> => {\n if (song.source.status === \"invalid\") {\n return Effect.succeed(parseDiagnosticsOf(song.file)(song.source.issues));\n }\n return runRules({\n path: song.file,\n comments: song.source.outline.comments,\n song: song.source.song,\n rules,\n });\n };\n\nconst notFound = (path: string): Effect.Effect<string, LintError> =>\n Effect.fail(LintError.make({ message: `could not read ${path}` }));\n\nconst readerOf =\n (input: TextInput): Read =>\n (path) => {\n if (path === input.path) {\n return Effect.succeed(input.text);\n }\n return (input.read ?? notFound)(path);\n };\n\nconst lintTracked = (\n rules: readonly ResolvedRule[],\n input: LintInput,\n): ((file: string) => Effect.Effect<readonly Diagnostic[], LintError>) =>\n Effect.fnUntraced(function* lintOne(\n file: string,\n ): Effect.fn.Return<readonly Diagnostic[], LintError> {\n const path = pathOf({ root: input.root, file });\n const read = yield* Effect.result(input.read(path));\n if (Result.isFailure(read) && Schema.is(NotUtf8Error)(read.failure)) {\n return [notUtf8(\"fumx lint\")(file)];\n }\n const reader = Result.match(read, {\n onFailure: () => input.read,\n onSuccess: (text): Read => readerOf({ path, text, read: input.read }),\n });\n const source = yield* readSongFile({ root: input.root, file, read: reader });\n return yield* lintFile(rules)(source);\n });\n\nexport const lint = Effect.fn(\"fumx.lint.lint\")(function* lint(input: LintInput) {\n const rules = yield* rulesOf(input.config);\n const found = yield* Effect.forEach(input.files, lintTracked(rules, input), {\n concurrency: \"unbounded\",\n });\n return sortByPosition<Diagnostic>(Arr.flatten(found));\n});\n\nexport const lintText = Effect.fn(\"fumx.lint.lintText\")(function* lintText(input: TextInput) {\n const rules = yield* rulesOf(input.config);\n const source = yield* readSong({ path: input.path, read: readerOf(input) });\n const found = yield* lintFile(rules)({ file: input.path, source });\n return sortByPosition<Diagnostic>(found);\n});\n","import { pathspecsOf, sectionOf } from \"@masseater.dev/lint-host\";\nimport type { PathspecRequest } from \"@masseater.dev/lint-host\";\nimport { Option, pipe } from \"effect\";\n\nimport { flattenConfig } from \"#/features/check-songs/index.ts\";\nimport type { FumxConfig, LintConfig } from \"#/features/check-songs/index.ts\";\n\nexport type PathspecInput = PathspecRequest<LintConfig>;\n\nconst fumxSection = sectionOf<FumxConfig>({ name: \"fumx\", fallback: {} });\n\nexport const lintSection = (config: unknown): LintConfig =>\n pipe(\n Option.fromUndefinedOr(fumxSection(config).lint),\n Option.match({ onNone: (): LintConfig => ({}), onSome: flattenConfig }),\n );\n\nexport const songPathspecs = pathspecsOf({ defaults: [\"*.fumx\"] });\n"],"mappings":";;;;;AAEA,MAAa,cAAc,SAAqB;AAEhD,MAAa,gBAAgB,WAA2B;;ACSxD,MAAM,aAA0B,CAAC;AAEjC,MAAa,aAAa,UACxB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,MAAM,SAAS,cAAuB;CAAE;CAAU,SAAS;AAAW,EAAE,GACnF,MAAM,QAAQ,CAAC,UAAU,cAAuB;CAC9C;CACA,SAAS,WAAW;AACtB,EAAE,CACJ;AAEF,MAAM,aAAa,UACjB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,MAAM,cAAc,OAAO,KAAK,CAAC,GAC5C,MAAM,QAAQ,GAAG,aAAa,OAAO,gBAAgB,OAAO,CAAC,CAC/D;AAEF,MAAM,cAAc,SAAoB,UACtC,KACE,UAAU,KAAK,GACf,OAAO,aAAa,UAAU,OAAO,CAAC,GACtC,OAAO,MAAM;CACX,cAAc;CACd,SAAS,YAAuB,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,OAAO;AACrE,CAAC,CACH;AAEF,MAAa,eACX,WACwC;CACxC,MAAM,SAAoC,CAAC;CAC3C,KAAK,MAAM,CAAC,MAAM,UAAU,KAC1B,QACAA,MAAI,SAAS,UAAUC,OAAI,UAAU,SAAS,CAAC,CAAC,CAAC,CACnD,GACE,OAAO,QAAQ,KACbA,OAAI,IAAI,QAAQ,IAAI,GACpB,OAAO,MAAM;EACX,cAAc;EACd,SAAS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AAU,KAAK,OAAkB;CAC/E,MAAM,QAAQ,OAAO,QAAQ,MAAM,MAAM;CACzC,MAAM,QAAQ,OAAO,OAAO,QAAQ,MAAM,OAAO,YAAY,OAAO,KAAK,GAAG,EAC1E,aAAa,YACf,CAAC;CACD,OAAO,eAA2BA,MAAI,QAAQ,KAAK,CAAC;AACtD,CAAC;AAED,MAAa,WAAW,OAAO,GAAG,oBAAoB,CAAC,CAAC,UAAU,SAAS,OAAkB;CAC3F,MAAM,QAAQ,OAAO,QAAQ,MAAM,MAAM;CACzC,MAAM,SAAS,OAAO,SAAS;EAAE,MAAM,MAAM;EAAM,MAAM,SAAS,KAAK;CAAE,CAAC;CAC1E,MAAM,QAAQ,OAAO,SAAS,KAAK,CAAC,CAAC;EAAE,MAAM,MAAM;EAAM;CAAO,CAAC;CACjE,OAAO,eAA2B,KAAK;AACzC,CAAC;;AChID,MAAM,cAAc,UAAsB;CAAE,MAAM;CAAQ,UAAU,CAAC;AAAE,CAAC;AAExE,MAAa,eAAe,WAC1B,KACE,OAAO,gBAAgB,YAAY,MAAM,CAAC,CAAC,IAAI,GAC/C,OAAO,MAAM;CAAE,eAA2B,CAAC;CAAI,QAAQ;AAAc,CAAC,CACxE;AAEF,MAAa,gBAAgB,YAAY,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { a as Diagnostic, f as PathspecRequest, n as LintError, s as LintConfig, t as Read } from "./index-DOfjU43D.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
interface Reportable {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly line: number;
|
|
6
|
+
readonly column?: number | undefined;
|
|
7
|
+
readonly rule: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly detail?: string | undefined;
|
|
10
|
+
readonly context?: string | undefined;
|
|
11
|
+
readonly severity: string;
|
|
12
|
+
}
|
|
13
|
+
declare const formatDiagnostic: (diagnostic: Reportable) => string;
|
|
14
|
+
interface Ignoring {
|
|
15
|
+
readonly ignores?: readonly string[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface LintInput {
|
|
18
|
+
readonly root: string;
|
|
19
|
+
readonly files: readonly string[];
|
|
20
|
+
readonly read: Read;
|
|
21
|
+
readonly config?: LintConfig;
|
|
22
|
+
}
|
|
23
|
+
interface TextInput {
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly text: string;
|
|
26
|
+
readonly read?: Read;
|
|
27
|
+
readonly config?: LintConfig;
|
|
28
|
+
}
|
|
29
|
+
declare const lint: (input: LintInput) => Effect.Effect<Diagnostic[], LintError, never>;
|
|
30
|
+
declare const lintText: (input: TextInput) => Effect.Effect<Diagnostic[], LintError, never>;
|
|
31
|
+
type PathspecInput = PathspecRequest<LintConfig>;
|
|
32
|
+
declare const lintSection: (config: unknown) => LintConfig;
|
|
33
|
+
declare const songPathspecs: ({ config, patterns }: {
|
|
34
|
+
readonly config: Ignoring;
|
|
35
|
+
readonly patterns?: readonly string[];
|
|
36
|
+
}) => readonly string[];
|
|
37
|
+
export { TextInput as a, formatDiagnostic as c, LintInput as i, lintSection as n, lint as o, songPathspecs as r, lintText as s, PathspecInput as t };
|
package/dist/lint.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as Diagnostic, c as Plugin, d as RuleContext, h as Severity, i as defineRule, l as Report, m as RuleOptions, n as LintError, o as FumxConfig, p as RuleEntry, r as definePlugin, s as LintConfig, t as Read, u as Rule } from "./index-DOfjU43D.mjs";
|
|
2
|
+
import { a as TextInput, c as formatDiagnostic, i as LintInput, n as lintSection, o as lint, r as songPathspecs, s as lintText, t as PathspecInput } from "./lint-CJ5lq-Fr.mjs";
|
|
3
|
+
export { type Diagnostic, type FumxConfig, type LintConfig, LintError, type LintInput, type PathspecInput, type Plugin, type Read, type Report, type Rule, type RuleContext, type RuleEntry, type RuleOptions, type Severity, type TextInput, definePlugin, defineRule, formatDiagnostic as format, lint, lintSection, lintText, songPathspecs };
|
package/dist/lint.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { a as LintError, s as definePlugin, c as defineRule, o as format, r as lint, t as lintSection, i as lintText, n as songPathspecs } from "./lint-Bnl4l0aI.mjs";
|
package/dist/mapper.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { flatMap, promise, runPromise } from "effect/Effect";
|
|
2
|
+
import { runContentMapper } from "ts-content-mapper";
|
|
3
|
+
// src/app/mapper.ts
|
|
4
|
+
runContentMapper({
|
|
5
|
+
diagnosticSource: "fumx",
|
|
6
|
+
transform: ({ fileName, content }, { positionEncoding }) => runPromise(promise(() => import("./transform-CeFBPHqb.mjs")).pipe(flatMap(({ transform }) => promise(() => transform({
|
|
7
|
+
fileName,
|
|
8
|
+
content,
|
|
9
|
+
positionEncoding
|
|
10
|
+
})))))
|
|
11
|
+
});
|
|
12
|
+
export {};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=mapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.mjs","names":[],"sources":["../src/app/mapper.ts"],"sourcesContent":["import { flatMap, promise, runPromise } from \"effect/Effect\";\nimport { runContentMapper } from \"ts-content-mapper\";\n\nrunContentMapper({\n diagnosticSource: \"fumx\",\n transform: ({ fileName, content }, { positionEncoding }) =>\n runPromise(\n promise(() => import(\"#/app/transform.ts\")).pipe(\n flatMap(({ transform }) =>\n promise(() => transform({ fileName, content, positionEncoding })),\n ),\n ),\n ),\n});\n"],"mappings":";;;AAGA,iBAAiB;CACf,kBAAkB;CAClB,YAAY,EAAE,UAAU,WAAW,EAAE,uBACnC,WACE,cAAc,OAAO,2BAAqB,CAAC,CAAC,KAC1C,SAAS,EAAE,gBACT,cAAc,UAAU;EAAE;EAAU;EAAS;CAAiB,CAAC,CAAC,CAClE,CACF,CACF;AACJ,CAAC"}
|