@r_masseater/msch 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-contract-ChzTJ0Na.mjs → cli-contract-c3l4AjvJ.mjs} +2 -2
- package/dist/cli-contract-c3l4AjvJ.mjs.map +1 -0
- package/dist/cli.mjs +4 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/comment-directives-DApQXgQf.mjs.map +1 -1
- package/dist/{dependencies-x3j9tLcR.mjs → dependencies-CVEeDVp2.mjs} +2 -1
- package/dist/dependencies-CVEeDVp2.mjs.map +1 -0
- package/dist/inline-exports.d.mts +8 -0
- package/dist/inline-exports.mjs +370 -0
- package/dist/inline-exports.mjs.map +1 -0
- package/dist/lint.d.mts +22 -14
- package/dist/lint.mjs +21 -0
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/oxlint.mjs.map +1 -1
- package/dist/workspace-settings.d.mts +9 -9
- package/dist/workspace-settings.mjs +2 -2
- package/dist/workspace-settings.mjs.map +1 -1
- package/dist/{workspace-tasks-CRL-gm__.mjs → workspace-tasks-DqSpU9ij.mjs} +2 -2
- package/dist/workspace-tasks-DqSpU9ij.mjs.map +1 -0
- package/package.json +5 -1
- package/src/vite.d.ts +7 -17
- package/dist/cli-contract-ChzTJ0Na.mjs.map +0 -1
- package/dist/dependencies-x3j9tLcR.mjs.map +0 -1
- package/dist/workspace-tasks-CRL-gm__.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-directives-DApQXgQf.mjs","names":[],"sources":["../src/lint/comment-directives.ts"],"sourcesContent":["const COMMENT_DIRECTIVES: readonly string[] = [\n \"oxlint-disable\",\n \"oxlint-enable\",\n \"eslint-disable\",\n \"eslint-enable\",\n \"textlint-disable\",\n \"textlint-enable\",\n String.raw`\\* @internal \\*?$`,\n String.raw`\\* @msch \\S+ \\*?$`,\n \"/usr/bin/env node$\",\n String.raw`shellcheck \\w`,\n String.raw`zizmor: ignore\\[`,\n \"renovate:\",\n \"yaml-language-server:\",\n \"> statement-breakpoint$\",\n];\n
|
|
1
|
+
{"version":3,"file":"comment-directives-DApQXgQf.mjs","names":[],"sources":["../src/lint/comment-directives.ts"],"sourcesContent":["export const COMMENT_DIRECTIVES: readonly string[] = [\n \"oxlint-disable\",\n \"oxlint-enable\",\n \"eslint-disable\",\n \"eslint-enable\",\n \"textlint-disable\",\n \"textlint-enable\",\n String.raw`\\* @internal \\*?$`,\n String.raw`\\* @msch \\S+ \\*?$`,\n \"/usr/bin/env node$\",\n String.raw`shellcheck \\w`,\n String.raw`zizmor: ignore\\[`,\n \"renovate:\",\n \"yaml-language-server:\",\n \"> statement-breakpoint$\",\n];\n"],"mappings":";AAAA,MAAa,qBAAwC;CACnD;CACA;CACA;CACA;CACA;CACA;CACA,OAAO,GAAG;CACV,OAAO,GAAG;CACV;CACA,OAAO,GAAG;CACV,OAAO,GAAG;CACV;CACA;CACA;AACF"}
|
|
@@ -2,6 +2,7 @@ import { Array, Context, Effect, FileSystem, Layer, Option, Order, Path, Predica
|
|
|
2
2
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
3
3
|
import { NodeChildProcessSpawner, NodeFileSystem, NodePath, NodeStdio } from "@effect/platform-node-shared";
|
|
4
4
|
// src/node-services.ts
|
|
5
|
+
/** @internal */
|
|
5
6
|
const nodeServicesLayer = Layer.provideMerge(NodeChildProcessSpawner.layer, Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer));
|
|
6
7
|
// src/repository-files.ts
|
|
7
8
|
const MISSING_SIZE = 0;
|
|
@@ -183,4 +184,4 @@ const dependencyEntries = Effect.fn("dependencyEntries")(function* dependencyEnt
|
|
|
183
184
|
});
|
|
184
185
|
export { workspaceDependencies as a, nodeServicesLayer as c, readManifest as i, NODE_MODULES as n, RepositoryFiles as o, dependencyEntries as r, nodeRepositoryFiles as s, MANIFEST_FILE as t };
|
|
185
186
|
|
|
186
|
-
//# sourceMappingURL=dependencies-
|
|
187
|
+
//# sourceMappingURL=dependencies-CVEeDVp2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies-CVEeDVp2.mjs","names":["Str","Arr","Rec","Arr","Str"],"sources":["../src/node-services.ts","../src/repository-files.ts","../src/dependencies.ts"],"sourcesContent":["import {\n NodeChildProcessSpawner,\n NodeFileSystem,\n NodePath,\n NodeStdio,\n} from \"@effect/platform-node-shared\";\nimport { Layer } from \"effect\";\n\n/** @internal */\nexport const nodeServicesLayer = Layer.provideMerge(\n NodeChildProcessSpawner.layer,\n Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer),\n);\n","import {\n Array as Arr,\n Context,\n Effect,\n FileSystem,\n Layer,\n Path,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport type { Option } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { nodeServicesLayer } from \"./node-services.ts\";\n\nconst MISSING_SIZE = 0;\nconst GENERATED_PATHSPEC = \":(attr:linguist-generated)\";\nconst LISTED_ARGS = [\"--cached\", \"--others\", \"--exclude-standard\"];\n\nexport class RepositoryFiles extends Context.Service<\n RepositoryFiles,\n {\n readonly readFile: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly exists: (file: string) => Effect.Effect<boolean>;\n readonly realPath: (file: string) => Effect.Effect<string>;\n readonly readDirectory: (directory: string) => Effect.Effect<readonly string[]>;\n readonly generatedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly listedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly matchingFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly isDirectory: (file: string) => Effect.Effect<Option.Option<boolean>>;\n readonly fileSize: (file: string) => Effect.Effect<number>;\n readonly join: (...segments: readonly string[]) => string;\n readonly resolve: (...segments: readonly string[]) => string;\n readonly relative: (from: string, to: string) => string;\n readonly dirname: (file: string) => string;\n readonly basename: (file: string) => string;\n }\n>()(\"@r_masseater/msch/repository-files/RepositoryFiles\") {}\n\nexport const nodeRepositoryFiles = Layer.effect(\n RepositoryFiles,\n Effect.gen(function* nodeRepositoryFiles() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const gitFiles = (root: string, args: readonly string[]): Effect.Effect<readonly string[]> =>\n Effect.gen(function* listFiles() {\n const handle = yield* ChildProcess.make(\"git\", [\"ls-files\", \"-z\", ...args], {\n cwd: root,\n stdin: \"ignore\",\n });\n const listed = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n return pipe(Str.split(listed, \"\\0\"), Arr.filter(Str.isNonEmpty));\n }).pipe(\n Effect.scoped,\n Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),\n Effect.orElseSucceed((): readonly string[] => []),\n );\n return RepositoryFiles.of({\n generatedFiles: (root) =>\n gitFiles(root, [\"--\", GENERATED_PATHSPEC]).pipe(\n Effect.map(Arr.map((file) => path.join(root, file))),\n ),\n listedFiles: (root) => gitFiles(root, LISTED_ARGS),\n matchingFiles: (root, pathspecs) => gitFiles(root, [...LISTED_ARGS, \"--\", ...pathspecs]),\n readFile: (file) => fs.readFileString(file).pipe(Effect.option),\n exists: (file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false)),\n realPath: (file) => fs.realPath(file).pipe(Effect.orElseSucceed(() => file)),\n readDirectory: (directory) =>\n fs.readDirectory(directory).pipe(Effect.orElseSucceed((): readonly string[] => [])),\n isDirectory: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => info.type === \"Directory\"),\n Effect.option,\n ),\n fileSize: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => Number(info.size)),\n Effect.orElseSucceed(() => MISSING_SIZE),\n ),\n join: (...segments) => path.join(...segments),\n resolve: (...segments) => path.resolve(...segments),\n relative: (from, to) => path.relative(from, to),\n dirname: (file) => path.dirname(file),\n basename: (file) => path.basename(file),\n });\n }),\n).pipe(Layer.provide(nodeServicesLayer));\n","import {\n Array as Arr,\n Effect,\n Option,\n Order,\n Predicate,\n Schema,\n String as Str,\n Record as Rec,\n pipe,\n} from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nexport interface DependencyEntry {\n readonly packageName: string;\n readonly specifier: string;\n readonly declarationsPath: string;\n}\n\nconst DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));\n\nconst PackageManifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n dependencies: DependencyMap,\n devDependencies: DependencyMap,\n peerDependencies: DependencyMap,\n exports: Schema.optional(Schema.Unknown),\n types: Schema.optional(Schema.String),\n typings: Schema.optional(Schema.String),\n main: Schema.optional(Schema.String),\n});\n\nexport type Manifest = typeof PackageManifest.Type;\n\nexport const MANIFEST_FILE = \"package.json\";\nexport const NODE_MODULES = \"node_modules\";\nconst WORKSPACE_PROTOCOL = \"workspace:\";\nconst ROOT_SUBPATH = \".\";\nconst SUBPATH_PREFIX = \"./\";\nconst WILDCARD = \"*\";\nconst TYPES_CONDITION = \"types\";\nconst TYPES_SCOPE = \"@types/\";\nconst TYPES_SCOPE_SEPARATOR = \"__\";\nconst CONDITION_DEPTH_LIMIT = 8;\nconst ROOT_DEPTH = 0;\nconst DEPTH_STEP = 1;\nconst DECLARATIONS_SUFFIX = /\\.d\\.[cm]?ts$|\\.[cm]?tsx?$/u;\nconst SCRIPT_SUFFIX = /\\.(?<module>[cm]?)js$/u;\n\nexport const readManifest = Effect.fn(\"readManifest\")(function* readManifest(directory: string) {\n const files = yield* RepositoryFiles;\n const manifestText = yield* files.readFile(files.join(directory, MANIFEST_FILE));\n const text = yield* Effect.fromOption(manifestText);\n return yield* Schema.decodeEffect(Schema.fromJsonString(PackageManifest))(text);\n}, Effect.option);\n\nconst conditionsOf = (held: unknown): readonly (readonly [string, unknown])[] => {\n if (!Predicate.isObject(held)) {\n return [];\n }\n return Rec.toEntries(held);\n};\n\nconst typesConditionIn = (held: unknown, depth: number): Option.Option<string> => {\n if (depth > CONDITION_DEPTH_LIMIT) {\n return Option.none();\n }\n const entries = conditionsOf(held);\n const declared = Arr.findFirst(entries, ([condition, target]) =>\n Option.liftPredicate(\n target,\n (candidate) => condition === TYPES_CONDITION && Predicate.isString(candidate),\n ),\n ).pipe(Option.filter(Predicate.isString));\n return Option.orElse(declared, () =>\n Arr.findFirst(entries, ([, nested]) => typesConditionIn(nested, depth + DEPTH_STEP)),\n );\n};\n\nconst anyConditionIn = (held: unknown, depth: number): Option.Option<string> => {\n if (Predicate.isString(held)) {\n return Option.some(held);\n }\n if (depth > CONDITION_DEPTH_LIMIT) {\n return Option.none();\n }\n return Arr.findFirst(conditionsOf(held), ([, nested]) =>\n anyConditionIn(nested, depth + DEPTH_STEP),\n );\n};\n\nconst targetPathsOf = (target: unknown): readonly string[] =>\n Arr.getSomes([typesConditionIn(target, ROOT_DEPTH), anyConditionIn(target, ROOT_DEPTH)]);\n\ninterface SubpathTarget {\n readonly subpath: string;\n readonly target: unknown;\n}\n\nconst subpathTargetsOf = (exportsField: unknown): readonly SubpathTarget[] => {\n if (Predicate.isString(exportsField)) {\n return [{ subpath: ROOT_SUBPATH, target: exportsField }];\n }\n const entries = conditionsOf(exportsField);\n if (\n !pipe(\n entries,\n Arr.some(([subpath]) => Str.startsWith(ROOT_SUBPATH)(subpath)),\n )\n ) {\n return Arr.match(entries, {\n onEmpty: () => [],\n onNonEmpty: () => [{ subpath: ROOT_SUBPATH, target: exportsField }],\n });\n }\n return pipe(\n entries,\n Arr.filter(([subpath]) => subpath === ROOT_SUBPATH || Str.startsWith(SUBPATH_PREFIX)(subpath)),\n Arr.filter(([subpath]) => !Str.includes(WILDCARD)(subpath)),\n Arr.map(([subpath, target]) => ({ subpath, target })),\n );\n};\n\nconst declarationsCandidateFor = (entryPath: string): Option.Option<string> => {\n if (DECLARATIONS_SUFFIX.test(entryPath)) {\n return Option.some(entryPath);\n }\n if (!SCRIPT_SUFFIX.test(entryPath)) {\n return Option.none();\n }\n return Option.some(Str.replace(SCRIPT_SUFFIX, \".d.$<module>ts\")(entryPath));\n};\n\nconst firstDeclarationsAmong = Effect.fn(\"firstDeclarationsAmong\")(function* firstDeclarations(\n directory: string,\n entryPaths: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const candidates = Arr.getSomes(\n pipe(\n entryPaths,\n Arr.map((entryPath) => declarationsCandidateFor(entryPath)),\n ),\n );\n const existing = yield* Effect.filter(\n pipe(\n candidates,\n Arr.map((candidate) => files.join(directory, candidate)),\n ),\n (candidate) => files.exists(candidate),\n );\n return yield* Option.match(Arr.head(existing), {\n onNone: (): Effect.Effect<Option.Option<string>> => Effect.succeedNone,\n onSome: (candidate) => files.realPath(candidate).pipe(Effect.asSome),\n });\n});\n\nconst importNameOf = (packageName: string): string => {\n if (!Str.startsWith(TYPES_SCOPE)(packageName)) {\n return packageName;\n }\n const unscoped = Str.slice(TYPES_SCOPE.length)(packageName);\n if (!Str.includes(TYPES_SCOPE_SEPARATOR)(unscoped)) {\n return unscoped;\n }\n return `@${Str.replace(TYPES_SCOPE_SEPARATOR, \"/\")(unscoped)}`;\n};\n\nconst specifierFor = (packageName: string, subpath: string): string => {\n const importName = importNameOf(packageName);\n if (subpath === ROOT_SUBPATH) {\n return importName;\n }\n return `${importName}/${Str.slice(SUBPATH_PREFIX.length)(subpath)}`;\n};\n\nconst rootEntryPaths = (manifest: Manifest): readonly string[] =>\n Arr.getSomes([\n Option.fromUndefinedOr(manifest.types),\n Option.fromUndefinedOr(manifest.typings),\n Option.fromUndefinedOr(manifest.main),\n ]);\n\nconst subpathEntriesOf = Effect.fn(\"subpathEntriesOf\")(function* subpathEntriesOf(\n packageName: string,\n directory: string,\n manifest: Manifest,\n) {\n const found = yield* Effect.forEach(subpathTargetsOf(manifest.exports), ({ subpath, target }) =>\n firstDeclarationsAmong(directory, targetPathsOf(target)).pipe(\n Effect.map(\n Option.map((declarationsPath) => ({\n packageName,\n specifier: specifierFor(packageName, subpath),\n declarationsPath,\n })),\n ),\n ),\n );\n return Arr.getSomes(found);\n});\n\nconst entriesOfDependency = Effect.fn(\"entriesOfDependency\")(function* entriesOfDependency(\n packageName: string,\n directory: string,\n) {\n const manifest = yield* readManifest(directory);\n if (Option.isNone(manifest)) {\n return [];\n }\n const subpathEntries = yield* subpathEntriesOf(packageName, directory, manifest.value);\n const rootSpecifier = specifierFor(packageName, ROOT_SUBPATH);\n if (\n pipe(\n subpathEntries,\n Arr.some((entry) => entry.specifier === rootSpecifier),\n )\n ) {\n return subpathEntries;\n }\n const rootDeclarations = yield* firstDeclarationsAmong(directory, rootEntryPaths(manifest.value));\n const rootEntries = rootDeclarations.pipe(\n Option.map((declarationsPath) => ({ packageName, specifier: rootSpecifier, declarationsPath })),\n Option.toArray,\n );\n return [...rootEntries, ...subpathEntries];\n});\n\nconst declaredDependencies = (manifest: Manifest): readonly string[] =>\n pipe(\n Rec.toEntries({\n ...manifest.dependencies,\n ...manifest.devDependencies,\n ...manifest.peerDependencies,\n }),\n Arr.filter(([, range]) => !Str.startsWith(WORKSPACE_PROTOCOL)(range)),\n Arr.map(([packageName]) => packageName),\n );\n\nexport const workspaceDependencies = (manifest: Manifest): readonly string[] =>\n pipe(\n Rec.toEntries({ ...manifest.dependencies, ...manifest.devDependencies }),\n Arr.filter(([, range]) => Str.startsWith(WORKSPACE_PROTOCOL)(range)),\n Arr.map(([packageName]) => packageName),\n );\n\nconst entryOrder = Order.mapInput(Order.String, (entry: DependencyEntry) => entry.specifier);\n\nexport const dependencyEntries = Effect.fn(\"dependencyEntries\")(function* dependencyEntries(\n packageDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(packageDirectory);\n if (Option.isNone(manifest)) {\n return [];\n }\n const entries = yield* Effect.forEach(declaredDependencies(manifest.value), (packageName) =>\n entriesOfDependency(packageName, files.join(packageDirectory, NODE_MODULES, packageName)),\n );\n return Arr.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,GACxB,OAAO,CAAC;CAEV,MAAM,UAAU,OAAO,OAAO,QAAQ,qBAAqB,SAAS,KAAK,IAAI,gBAC3E,oBAAoB,aAAa,MAAM,KAAK,kBAAkB,cAAc,WAAW,CAAC,CAC1F;CACA,OAAOA,MAAI,KACTA,MAAI,WAAW,QAAQ,KAAK,IAAI,MAAM,UAAU,KAAK,cAAc,MAAM,SAAS,GAClF,UACF;AACF,CAAC"}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { Array, Boolean, Option, Schema, String, pipe } from "effect";
|
|
2
|
+
// src/lint/inline-exports-resolve.ts
|
|
3
|
+
const DEFAULT_NAME$1 = "default";
|
|
4
|
+
const CLASS_DECLARATION = "ClassDeclaration";
|
|
5
|
+
const TYPE_DECLARATIONS = /* @__PURE__ */ new Set(["TSTypeAliasDeclaration", "TSInterfaceDeclaration"]);
|
|
6
|
+
const isTypeOnly = (list) => (specifier) => list.typeOnly || specifier.typeOnly;
|
|
7
|
+
const exportsAsItself = (list) => (name) => pipe(list.specifiers, Array.some((specifier) => Option.contains(specifier.local, name) && specifier.exported === name));
|
|
8
|
+
const declarationOf$1 = (list, specifier) => (statements) => {
|
|
9
|
+
const whole = pipe(statements, Array.every((statement) => pipe(statement.names, Array.every(exportsAsItself(list)))));
|
|
10
|
+
const keepsKind = !isTypeOnly(list)(specifier) || pipe(statements, Array.every((statement) => TYPE_DECLARATIONS.has(statement.type)));
|
|
11
|
+
if (!whole || !keepsKind) return Option.none();
|
|
12
|
+
return Option.some({
|
|
13
|
+
kind: "declaration",
|
|
14
|
+
statements
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const declarationsNamed = (list, name) => pipe(list.body, Array.filter((statement) => statement.kind === "declaration" && pipe(statement.names, Array.contains(name))));
|
|
18
|
+
const importIn = (name) => (statement) => {
|
|
19
|
+
if (statement.kind !== "import") return Option.none();
|
|
20
|
+
return pipe(statement.bindings, Array.findFirst((binding) => binding.local === name), Option.map((binding) => ({
|
|
21
|
+
kind: "import",
|
|
22
|
+
statement,
|
|
23
|
+
binding
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
const isTypeOnlyClass = (list) => (specifier) => isTypeOnly(list)(specifier) && pipe(specifier.local, Option.exists((local) => {
|
|
27
|
+
const statements = declarationsNamed(list, local);
|
|
28
|
+
return Array.isReadonlyArrayNonEmpty(statements) && pipe(statements, Array.every((statement) => statement.type === CLASS_DECLARATION));
|
|
29
|
+
}));
|
|
30
|
+
const resolutionOf = (list) => (specifier) => pipe(specifier.local, Option.flatMap((local) => {
|
|
31
|
+
if (specifier.exported === DEFAULT_NAME$1) return Option.some({
|
|
32
|
+
kind: "default",
|
|
33
|
+
name: local
|
|
34
|
+
});
|
|
35
|
+
if (local !== specifier.exported) return Option.none();
|
|
36
|
+
const statements = declarationsNamed(list, local);
|
|
37
|
+
if (Array.isReadonlyArrayNonEmpty(statements)) return declarationOf$1(list, specifier)(statements);
|
|
38
|
+
return pipe(list.body, Array.findFirst(importIn(local)));
|
|
39
|
+
}));
|
|
40
|
+
const kindOf = (kind) => (resolved) => pipe(resolved.resolution, Option.filter((found) => found.kind === kind), Option.toArray);
|
|
41
|
+
const restOf = (resolved) => pipe(resolved, Array.filter((entry) => Option.isNone(entry.resolution)), Array.map((entry) => entry.specifier));
|
|
42
|
+
const resolvedOf = (list) => pipe(list.specifiers, Array.map((specifier) => ({
|
|
43
|
+
specifier,
|
|
44
|
+
resolution: resolutionOf(list)(specifier)
|
|
45
|
+
})));
|
|
46
|
+
// src/lint/inline-exports-text.ts
|
|
47
|
+
const START$2 = 0;
|
|
48
|
+
const END$2 = 1;
|
|
49
|
+
const NEXT = 1;
|
|
50
|
+
const NEWLINE$1 = "\n";
|
|
51
|
+
const textOf = (source) => (range) => pipe(source.text, String.slice(range[START$2], range[END$2]));
|
|
52
|
+
const lineStartOf = (source, offset) => pipe(source.text, String.slice(START$2, offset), String.lastIndexOf(NEWLINE$1), Option.match({
|
|
53
|
+
onNone: () => START$2,
|
|
54
|
+
onSome: (index) => index + NEXT
|
|
55
|
+
}));
|
|
56
|
+
const indentOf = (source) => (offset) => textOf(source)([lineStartOf(source, offset), offset]);
|
|
57
|
+
const lineRangeOf = (source) => (range) => {
|
|
58
|
+
const indented = String.isEmpty(String.trim(indentOf(source)(range[START$2])));
|
|
59
|
+
const endsLine = pipe(source.text, String.charAt(range[END$2]), Option.contains(NEWLINE$1));
|
|
60
|
+
return [Boolean.match(indented, {
|
|
61
|
+
onFalse: () => range[START$2],
|
|
62
|
+
onTrue: () => lineStartOf(source, range[START$2])
|
|
63
|
+
}), Boolean.match(endsLine, {
|
|
64
|
+
onFalse: () => range[END$2],
|
|
65
|
+
onTrue: () => range[END$2] + NEXT
|
|
66
|
+
})];
|
|
67
|
+
};
|
|
68
|
+
const commentsBefore = (source) => (start) => pipe(source.comments, Array.findLast((comment) => comment[END$2] <= start), Option.filter((comment) => String.isEmpty(String.trim(textOf(source)([comment[END$2], start])))), Option.match({
|
|
69
|
+
onNone: () => [],
|
|
70
|
+
onSome: (comment) => [...commentsBefore(source)(comment[START$2]), comment]
|
|
71
|
+
}));
|
|
72
|
+
const leadingTextOf = (source) => (start) => pipe(commentsBefore(source)(start), Array.map(textOf(source)), Array.join(NEWLINE$1));
|
|
73
|
+
// src/lint/inline-exports-plan.ts
|
|
74
|
+
const NAMESPACE_NAME$1 = "*";
|
|
75
|
+
const START$1 = 0;
|
|
76
|
+
const END$1 = 1;
|
|
77
|
+
const SINGLE = 1;
|
|
78
|
+
const NEWLINE = "\n";
|
|
79
|
+
const EXPORT = "export ";
|
|
80
|
+
const KINDS = [false, true];
|
|
81
|
+
const keywordOf = (typeOnly) => Boolean.match(typeOnly, {
|
|
82
|
+
onFalse: () => "export",
|
|
83
|
+
onTrue: () => "export type"
|
|
84
|
+
});
|
|
85
|
+
const reexportsOf = (list, resolved) => pipe(resolved, Array.flatMap((entry) => pipe(kindOf("import")(entry), Array.map((found) => ({
|
|
86
|
+
statement: found.statement,
|
|
87
|
+
binding: found.binding,
|
|
88
|
+
typeOnly: isTypeOnly(list)(entry.specifier) || found.binding.typeOnly
|
|
89
|
+
})))));
|
|
90
|
+
const statementsOf = (reexports) => pipe(reexports, Array.map((entry) => entry.statement), Array.dedupe);
|
|
91
|
+
const groupOf = (reexports, statement) => (typeOnly) => {
|
|
92
|
+
const bindings = pipe(reexports, Array.filter((entry) => entry.statement === statement && entry.typeOnly === typeOnly), Array.map((entry) => entry.binding));
|
|
93
|
+
if (Array.isReadonlyArrayEmpty(bindings)) return [];
|
|
94
|
+
return [{
|
|
95
|
+
statement,
|
|
96
|
+
bindings,
|
|
97
|
+
typeOnly
|
|
98
|
+
}];
|
|
99
|
+
};
|
|
100
|
+
const splitNamespaces = (group) => {
|
|
101
|
+
if (!(pipe(group.bindings, Array.some((binding) => binding.imported === NAMESPACE_NAME$1)) && group.bindings.length > SINGLE)) return [group];
|
|
102
|
+
return pipe(group.bindings, Array.map((binding) => ({
|
|
103
|
+
...group,
|
|
104
|
+
bindings: [binding]
|
|
105
|
+
})));
|
|
106
|
+
};
|
|
107
|
+
const groupsOf = (reexports) => pipe(statementsOf(reexports), Array.flatMap((statement) => pipe(KINDS, Array.flatMap(groupOf(reexports, statement)))), Array.flatMap(splitNamespaces));
|
|
108
|
+
const renamedOf = (binding) => Boolean.match(binding.imported === binding.local, {
|
|
109
|
+
onFalse: () => `${binding.imported} as ${binding.local}`,
|
|
110
|
+
onTrue: () => binding.imported
|
|
111
|
+
});
|
|
112
|
+
const reexportTextOf = (source) => (group) => {
|
|
113
|
+
const from = textOf(source)(group.statement.from);
|
|
114
|
+
const keyword = keywordOf(group.typeOnly);
|
|
115
|
+
return pipe(group.bindings, Array.findFirst((binding) => binding.imported === NAMESPACE_NAME$1), Option.match({
|
|
116
|
+
onSome: (namespace) => `${keyword} * as ${namespace.local} from ${from};`,
|
|
117
|
+
onNone: () => `${keyword} { ${pipe(group.bindings, Array.map(renamedOf), Array.join(", "))} } from ${from};`
|
|
118
|
+
}));
|
|
119
|
+
};
|
|
120
|
+
const replacementOf = (source, list, resolved) => {
|
|
121
|
+
const rest = restOf(resolved);
|
|
122
|
+
const names = pipe(rest, Array.map((specifier) => textOf(source)(specifier.range)), Array.join(", "));
|
|
123
|
+
const remaining = Boolean.match(Array.isReadonlyArrayEmpty(rest), {
|
|
124
|
+
onFalse: () => [`${keywordOf(list.typeOnly)} { ${names} };`],
|
|
125
|
+
onTrue: () => []
|
|
126
|
+
});
|
|
127
|
+
const defaults = pipe(resolved, Array.flatMap(kindOf("default")), Array.map((found) => `export default ${found.name};`));
|
|
128
|
+
const reexports = pipe(groupsOf(reexportsOf(list, resolved)), Array.map(reexportTextOf(source)));
|
|
129
|
+
return pipe([
|
|
130
|
+
...remaining,
|
|
131
|
+
...defaults,
|
|
132
|
+
...reexports
|
|
133
|
+
], Array.join(NEWLINE));
|
|
134
|
+
};
|
|
135
|
+
const removedOf = (source, reexports) => pipe(statementsOf(reexports), Array.filter((statement) => pipe(statement.bindings, Array.every((binding) => pipe(reexports, Array.some((entry) => entry.statement === statement && entry.binding === binding)) && !pipe(source.usedOutside, Array.contains(binding.local))))));
|
|
136
|
+
const prefixOf = (source, comments) => (statement) => {
|
|
137
|
+
const start = statement.range[START$1];
|
|
138
|
+
if (String.isEmpty(comments) || pipe(leadingTextOf(source)(start), String.includes(comments))) return EXPORT;
|
|
139
|
+
return `${comments}${NEWLINE}${indentOf(source)(start)}${EXPORT}`;
|
|
140
|
+
};
|
|
141
|
+
const listEditOf = (source, list, text) => {
|
|
142
|
+
if (!String.isEmpty(text)) return {
|
|
143
|
+
range: list.range,
|
|
144
|
+
text
|
|
145
|
+
};
|
|
146
|
+
const start = pipe(commentsBefore(source)(list.range[START$1]), Array.head, Option.match({
|
|
147
|
+
onNone: () => list.range[START$1],
|
|
148
|
+
onSome: (first) => first[START$1]
|
|
149
|
+
}));
|
|
150
|
+
return {
|
|
151
|
+
range: lineRangeOf(source)([start, list.range[END$1]]),
|
|
152
|
+
text: ""
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const editsOf = (source) => (list) => {
|
|
156
|
+
const resolved = resolvedOf(list);
|
|
157
|
+
if (restOf(resolved).length === list.specifiers.length) return Option.none();
|
|
158
|
+
const prefix = prefixOf(source, leadingTextOf(source)(list.range[START$1]));
|
|
159
|
+
const declarations = pipe(resolved, Array.flatMap(kindOf("declaration")), Array.flatMap((found) => found.statements), Array.dedupe, Array.map((statement) => ({
|
|
160
|
+
range: [statement.range[START$1], statement.range[START$1]],
|
|
161
|
+
text: prefix(statement)
|
|
162
|
+
})));
|
|
163
|
+
const removals = pipe(removedOf(source, reexportsOf(list, resolved)), Array.map((statement) => ({
|
|
164
|
+
range: lineRangeOf(source)(statement.range),
|
|
165
|
+
text: ""
|
|
166
|
+
})));
|
|
167
|
+
return Option.some([
|
|
168
|
+
...declarations,
|
|
169
|
+
...removals,
|
|
170
|
+
listEditOf(source, list, replacementOf(source, list, resolved))
|
|
171
|
+
]);
|
|
172
|
+
};
|
|
173
|
+
// src/lint/inline-exports-source.ts
|
|
174
|
+
const TYPE_KIND = "type";
|
|
175
|
+
const DEFAULT_NAME = "default";
|
|
176
|
+
const NAMESPACE_NAME = "*";
|
|
177
|
+
const RangeSchema = Schema.Tuple([Schema.Finite, Schema.Finite]);
|
|
178
|
+
const KindSchema = Schema.optionalKey(Schema.String);
|
|
179
|
+
const IdentifierSchema = Schema.Struct({
|
|
180
|
+
type: Schema.Literal("Identifier"),
|
|
181
|
+
name: Schema.String
|
|
182
|
+
});
|
|
183
|
+
const StringSchema = Schema.Struct({
|
|
184
|
+
type: Schema.Literal("Literal"),
|
|
185
|
+
value: Schema.String
|
|
186
|
+
});
|
|
187
|
+
const NameSchema = Schema.Union([IdentifierSchema, StringSchema]);
|
|
188
|
+
const PatternSchema = Schema.Union([
|
|
189
|
+
IdentifierSchema,
|
|
190
|
+
Schema.Struct({
|
|
191
|
+
type: Schema.Literal("ObjectPattern"),
|
|
192
|
+
properties: Schema.Array(Schema.Unknown)
|
|
193
|
+
}),
|
|
194
|
+
Schema.Struct({
|
|
195
|
+
type: Schema.Literal("ArrayPattern"),
|
|
196
|
+
elements: Schema.Array(Schema.Unknown)
|
|
197
|
+
}),
|
|
198
|
+
Schema.Struct({
|
|
199
|
+
type: Schema.Literal("Property"),
|
|
200
|
+
value: Schema.Unknown
|
|
201
|
+
}),
|
|
202
|
+
Schema.Struct({
|
|
203
|
+
type: Schema.Literal("AssignmentPattern"),
|
|
204
|
+
left: Schema.Unknown
|
|
205
|
+
}),
|
|
206
|
+
Schema.Struct({
|
|
207
|
+
type: Schema.Literal("RestElement"),
|
|
208
|
+
argument: Schema.Unknown
|
|
209
|
+
})
|
|
210
|
+
]);
|
|
211
|
+
const decodePattern = Schema.decodeUnknownOption(PatternSchema);
|
|
212
|
+
const BindingSchema = Schema.Union([Schema.Struct({
|
|
213
|
+
type: Schema.Literal("ImportSpecifier"),
|
|
214
|
+
local: IdentifierSchema,
|
|
215
|
+
imported: NameSchema,
|
|
216
|
+
importKind: KindSchema
|
|
217
|
+
}), Schema.Struct({
|
|
218
|
+
type: Schema.Literals(["ImportDefaultSpecifier", "ImportNamespaceSpecifier"]),
|
|
219
|
+
local: IdentifierSchema
|
|
220
|
+
})]);
|
|
221
|
+
const RangedSchema = Schema.Struct({ range: RangeSchema });
|
|
222
|
+
const DeclaratorSchema = Schema.Struct({ id: Schema.Unknown });
|
|
223
|
+
const ExportSpecifierSchema = Schema.Struct({
|
|
224
|
+
range: RangeSchema,
|
|
225
|
+
local: NameSchema,
|
|
226
|
+
exported: NameSchema,
|
|
227
|
+
exportKind: KindSchema
|
|
228
|
+
});
|
|
229
|
+
const ParentSchema = Schema.Struct({ body: Schema.Array(Schema.Unknown) });
|
|
230
|
+
const QuotedSchema = Schema.fromJsonString(Schema.String);
|
|
231
|
+
const decodeImport = Schema.decodeUnknownOption(Schema.Struct({
|
|
232
|
+
type: Schema.Literal("ImportDeclaration"),
|
|
233
|
+
range: RangeSchema,
|
|
234
|
+
source: RangedSchema,
|
|
235
|
+
importKind: KindSchema,
|
|
236
|
+
specifiers: Schema.Array(BindingSchema)
|
|
237
|
+
}));
|
|
238
|
+
const decodeVariable = Schema.decodeUnknownOption(Schema.Struct({
|
|
239
|
+
type: Schema.Literal("VariableDeclaration"),
|
|
240
|
+
range: RangeSchema,
|
|
241
|
+
declarations: Schema.Array(DeclaratorSchema)
|
|
242
|
+
}));
|
|
243
|
+
const decodeNamed = Schema.decodeUnknownOption(Schema.Struct({
|
|
244
|
+
type: Schema.String,
|
|
245
|
+
range: RangeSchema,
|
|
246
|
+
id: IdentifierSchema
|
|
247
|
+
}));
|
|
248
|
+
const decodeList = Schema.decodeUnknownOption(Schema.Struct({
|
|
249
|
+
range: RangeSchema,
|
|
250
|
+
source: Schema.Null,
|
|
251
|
+
declaration: Schema.Null,
|
|
252
|
+
exportKind: KindSchema,
|
|
253
|
+
specifiers: Schema.Array(ExportSpecifierSchema),
|
|
254
|
+
parent: ParentSchema
|
|
255
|
+
}));
|
|
256
|
+
const nameOf = (name) => {
|
|
257
|
+
if (name.type === "Literal") return name.value;
|
|
258
|
+
return name.name;
|
|
259
|
+
};
|
|
260
|
+
const identifierOf = (name) => {
|
|
261
|
+
if (name.type === "Literal") return Option.none();
|
|
262
|
+
return Option.some(name.name);
|
|
263
|
+
};
|
|
264
|
+
const childOf = (pattern) => {
|
|
265
|
+
if (pattern.type === "Property") return pattern.value;
|
|
266
|
+
if (pattern.type === "AssignmentPattern") return pattern.left;
|
|
267
|
+
return pattern.argument;
|
|
268
|
+
};
|
|
269
|
+
const childrenOf = (pattern) => {
|
|
270
|
+
if (pattern.type === "ObjectPattern") return pattern.properties;
|
|
271
|
+
if (pattern.type === "ArrayPattern") return pattern.elements;
|
|
272
|
+
if (pattern.type === "Identifier") return [];
|
|
273
|
+
return [childOf(pattern)];
|
|
274
|
+
};
|
|
275
|
+
const bindingNames = (node) => pipe(decodePattern(node), Option.match({
|
|
276
|
+
onNone: () => [],
|
|
277
|
+
onSome: (pattern) => {
|
|
278
|
+
if (pattern.type === "Identifier") return [pattern.name];
|
|
279
|
+
return pipe(childrenOf(pattern), Array.flatMap(bindingNames));
|
|
280
|
+
}
|
|
281
|
+
}));
|
|
282
|
+
const importedOf = (binding) => {
|
|
283
|
+
if (binding.type === "ImportSpecifier") {
|
|
284
|
+
if (binding.imported.type === "Literal") {
|
|
285
|
+
const { value } = binding.imported;
|
|
286
|
+
return pipe(Schema.encodeOption(QuotedSchema)(value), Option.getOrElse(() => value));
|
|
287
|
+
}
|
|
288
|
+
return binding.imported.name;
|
|
289
|
+
}
|
|
290
|
+
if (binding.type === "ImportDefaultSpecifier") return DEFAULT_NAME;
|
|
291
|
+
return NAMESPACE_NAME;
|
|
292
|
+
};
|
|
293
|
+
const typeOnlyOf = (binding) => binding.type === "ImportSpecifier" && binding.importKind === TYPE_KIND;
|
|
294
|
+
const importOf = (node) => pipe(decodeImport(node), Option.map((statement) => ({
|
|
295
|
+
kind: "import",
|
|
296
|
+
range: statement.range,
|
|
297
|
+
from: statement.source.range,
|
|
298
|
+
bindings: pipe(statement.specifiers, Array.map((binding) => ({
|
|
299
|
+
local: binding.local.name,
|
|
300
|
+
imported: importedOf(binding),
|
|
301
|
+
typeOnly: statement.importKind === TYPE_KIND || typeOnlyOf(binding)
|
|
302
|
+
})))
|
|
303
|
+
})));
|
|
304
|
+
const declarationOf = (node) => pipe(decodeVariable(node), Option.map((statement) => ({
|
|
305
|
+
kind: "declaration",
|
|
306
|
+
type: statement.type,
|
|
307
|
+
range: statement.range,
|
|
308
|
+
names: pipe(statement.declarations, Array.flatMap((declarator) => bindingNames(declarator.id)))
|
|
309
|
+
})), Option.orElse(() => pipe(decodeNamed(node), Option.map((statement) => ({
|
|
310
|
+
kind: "declaration",
|
|
311
|
+
type: statement.type,
|
|
312
|
+
range: statement.range,
|
|
313
|
+
names: [statement.id.name]
|
|
314
|
+
})))));
|
|
315
|
+
const statementOf = (node) => pipe(importOf(node), Option.orElse(() => declarationOf(node)));
|
|
316
|
+
const exportListOf = (node) => pipe(decodeList(node), Option.filter((list) => Array.isReadonlyArrayNonEmpty(list.specifiers)), Option.map((list) => ({
|
|
317
|
+
range: list.range,
|
|
318
|
+
typeOnly: list.exportKind === TYPE_KIND,
|
|
319
|
+
specifiers: pipe(list.specifiers, Array.map((specifier) => ({
|
|
320
|
+
range: specifier.range,
|
|
321
|
+
local: identifierOf(specifier.local),
|
|
322
|
+
exported: nameOf(specifier.exported),
|
|
323
|
+
typeOnly: specifier.exportKind === TYPE_KIND
|
|
324
|
+
}))),
|
|
325
|
+
body: pipe(list.parent.body, Array.map(statementOf), Array.getSomes)
|
|
326
|
+
})));
|
|
327
|
+
// src/lint/inline-exports.ts
|
|
328
|
+
const MESSAGE = "export は宣言に付ける(export const・export function など)。ファイルの末尾で export { … } にまとめない。";
|
|
329
|
+
const START = 0;
|
|
330
|
+
const END = 1;
|
|
331
|
+
const outside = (list) => (range) => range[START] < list[START] || range[END] > list[END];
|
|
332
|
+
const usedOutside = (context, list) => pipe(context.sourceCode.scopeManager.scopes, Array.flatMap((scope) => scope.variables), Array.filter((variable) => pipe(variable.references, Array.some((reference) => outside(list.range)(reference.identifier.range)))), Array.map((variable) => variable.name));
|
|
333
|
+
const sourceOf = (context, list) => ({
|
|
334
|
+
text: context.sourceCode.text,
|
|
335
|
+
comments: pipe(context.sourceCode.getAllComments(), Array.map((comment) => comment.range)),
|
|
336
|
+
usedOutside: usedOutside(context, list)
|
|
337
|
+
});
|
|
338
|
+
const reportList = (context, node, list) => {
|
|
339
|
+
pipe(editsOf(sourceOf(context, list))(list), Option.match({
|
|
340
|
+
onNone: () => {
|
|
341
|
+
context.report({
|
|
342
|
+
node,
|
|
343
|
+
message: MESSAGE
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
onSome: (edits) => {
|
|
347
|
+
context.report({
|
|
348
|
+
node,
|
|
349
|
+
message: MESSAGE,
|
|
350
|
+
fix: (fixer) => pipe(edits, Array.map((edit) => fixer.replaceTextRange([edit.range[START], edit.range[END]], edit.text)))
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}));
|
|
354
|
+
};
|
|
355
|
+
const plugin = {
|
|
356
|
+
meta: { name: "msch-lint" },
|
|
357
|
+
rules: { "inline-exports": {
|
|
358
|
+
meta: {
|
|
359
|
+
type: "suggestion",
|
|
360
|
+
fixable: "code"
|
|
361
|
+
},
|
|
362
|
+
create: (context) => ({ ExportNamedDeclaration: (node) => {
|
|
363
|
+
const list = exportListOf(node);
|
|
364
|
+
if (Option.isSome(list) && !pipe(list.value.specifiers, Array.every(isTypeOnlyClass(list.value)))) reportList(context, node, list.value);
|
|
365
|
+
} })
|
|
366
|
+
} }
|
|
367
|
+
};
|
|
368
|
+
export { plugin as default };
|
|
369
|
+
|
|
370
|
+
//# sourceMappingURL=inline-exports.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-exports.mjs","names":["DEFAULT_NAME","Arr","declarationOf","START","END","NEWLINE","Str","Bool","Arr","NAMESPACE_NAME","START","END","Bool","Arr","Str","Arr","Arr"],"sources":["../src/lint/inline-exports-resolve.ts","../src/lint/inline-exports-text.ts","../src/lint/inline-exports-plan.ts","../src/lint/inline-exports-source.ts","../src/lint/inline-exports.ts"],"sourcesContent":["import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type {\n Declaration,\n ExportList,\n Import,\n ImportBinding,\n Specifier,\n Statement,\n} from \"./inline-exports-source.ts\";\n\nexport interface DeclarationResolution {\n readonly kind: \"declaration\";\n readonly statements: readonly Declaration[];\n}\n\nexport interface ImportResolution {\n readonly kind: \"import\";\n readonly statement: Import;\n readonly binding: ImportBinding;\n}\n\nexport interface DefaultResolution {\n readonly kind: \"default\";\n readonly name: string;\n}\n\nexport type Resolution = DeclarationResolution | ImportResolution | DefaultResolution;\n\nexport interface Resolved {\n readonly specifier: Specifier;\n readonly resolution: Option.Option<Resolution>;\n}\n\nconst DEFAULT_NAME = \"default\";\nconst CLASS_DECLARATION = \"ClassDeclaration\";\nconst TYPE_DECLARATIONS: ReadonlySet<string> = new Set([\n \"TSTypeAliasDeclaration\",\n \"TSInterfaceDeclaration\",\n]);\n\nexport const isTypeOnly =\n (list: ExportList) =>\n (specifier: Specifier): boolean =>\n list.typeOnly || specifier.typeOnly;\n\nconst exportsAsItself =\n (list: ExportList) =>\n (name: string): boolean =>\n pipe(\n list.specifiers,\n Arr.some(\n (specifier) => Option.contains(specifier.local, name) && specifier.exported === name,\n ),\n );\n\nconst declarationOf =\n (list: ExportList, specifier: Specifier) =>\n (statements: readonly Declaration[]): Option.Option<Resolution> => {\n const whole = pipe(\n statements,\n Arr.every((statement) => pipe(statement.names, Arr.every(exportsAsItself(list)))),\n );\n const keepsKind =\n !isTypeOnly(list)(specifier) ||\n pipe(\n statements,\n Arr.every((statement) => TYPE_DECLARATIONS.has(statement.type)),\n );\n if (!whole || !keepsKind) {\n return Option.none();\n }\n return Option.some({ kind: \"declaration\", statements });\n };\n\nconst declarationsNamed = (list: ExportList, name: string): readonly Declaration[] =>\n pipe(\n list.body,\n Arr.filter(\n (statement): statement is Declaration =>\n statement.kind === \"declaration\" && pipe(statement.names, Arr.contains(name)),\n ),\n );\n\nconst importIn =\n (name: string) =>\n (statement: Statement): Option.Option<Resolution> => {\n if (statement.kind !== \"import\") {\n return Option.none();\n }\n return pipe(\n statement.bindings,\n Arr.findFirst((binding) => binding.local === name),\n Option.map((binding): Resolution => ({ kind: \"import\", statement, binding })),\n );\n };\n\nexport const isTypeOnlyClass =\n (list: ExportList) =>\n (specifier: Specifier): boolean =>\n isTypeOnly(list)(specifier) &&\n pipe(\n specifier.local,\n Option.exists((local) => {\n const statements = declarationsNamed(list, local);\n return (\n Arr.isReadonlyArrayNonEmpty(statements) &&\n pipe(\n statements,\n Arr.every((statement) => statement.type === CLASS_DECLARATION),\n )\n );\n }),\n );\n\nconst resolutionOf =\n (list: ExportList) =>\n (specifier: Specifier): Option.Option<Resolution> =>\n pipe(\n specifier.local,\n Option.flatMap((local): Option.Option<Resolution> => {\n if (specifier.exported === DEFAULT_NAME) {\n return Option.some({ kind: \"default\", name: local });\n }\n if (local !== specifier.exported) {\n return Option.none();\n }\n const statements = declarationsNamed(list, local);\n if (Arr.isReadonlyArrayNonEmpty(statements)) {\n return declarationOf(list, specifier)(statements);\n }\n return pipe(list.body, Arr.findFirst(importIn(local)));\n }),\n );\n\nexport const kindOf =\n <Kind extends Resolution[\"kind\"]>(kind: Kind) =>\n (resolved: Resolved): readonly Extract<Resolution, { readonly kind: Kind }>[] =>\n pipe(\n resolved.resolution,\n Option.filter(\n (found): found is Extract<Resolution, { readonly kind: Kind }> => found.kind === kind,\n ),\n Option.toArray,\n );\n\nexport const restOf = (resolved: readonly Resolved[]): readonly Specifier[] =>\n pipe(\n resolved,\n Arr.filter((entry) => Option.isNone(entry.resolution)),\n Arr.map((entry) => entry.specifier),\n );\n\nexport const resolvedOf = (list: ExportList): readonly Resolved[] =>\n pipe(\n list.specifiers,\n Arr.map((specifier) => ({ specifier, resolution: resolutionOf(list)(specifier) })),\n );\n","import { Array as Arr, Boolean as Bool, Option, String as Str, pipe } from \"effect\";\n\nimport type { Range } from \"./inline-exports-source.ts\";\n\nexport interface Source {\n readonly text: string;\n readonly comments: readonly Range[];\n readonly usedOutside: readonly string[];\n}\n\nconst START = 0;\nconst END = 1;\nconst NEXT = 1;\nconst NEWLINE = \"\\n\";\n\nexport const textOf =\n (source: Source) =>\n (range: Range): string =>\n pipe(source.text, Str.slice(range[START], range[END]));\n\nconst lineStartOf = (source: Source, offset: number): number =>\n pipe(\n source.text,\n Str.slice(START, offset),\n Str.lastIndexOf(NEWLINE),\n Option.match({ onNone: () => START, onSome: (index) => index + NEXT }),\n );\n\nexport const indentOf =\n (source: Source) =>\n (offset: number): string =>\n textOf(source)([lineStartOf(source, offset), offset]);\n\nexport const lineRangeOf =\n (source: Source) =>\n (range: Range): Range => {\n const indented = Str.isEmpty(Str.trim(indentOf(source)(range[START])));\n const endsLine = pipe(source.text, Str.charAt(range[END]), Option.contains(NEWLINE));\n return [\n Bool.match(indented, {\n onFalse: () => range[START],\n onTrue: () => lineStartOf(source, range[START]),\n }),\n Bool.match(endsLine, { onFalse: () => range[END], onTrue: () => range[END] + NEXT }),\n ];\n };\n\nexport const commentsBefore =\n (source: Source) =>\n (start: number): readonly Range[] =>\n pipe(\n source.comments,\n Arr.findLast((comment) => comment[END] <= start),\n Option.filter((comment) => Str.isEmpty(Str.trim(textOf(source)([comment[END], start])))),\n Option.match({\n onNone: (): readonly Range[] => [],\n onSome: (comment) => [...commentsBefore(source)(comment[START]), comment],\n }),\n );\n\nexport const leadingTextOf =\n (source: Source) =>\n (start: number): string =>\n pipe(commentsBefore(source)(start), Arr.map(textOf(source)), Arr.join(NEWLINE));\n","import { Array as Arr, Boolean as Bool, Option, String as Str, pipe } from \"effect\";\n\nimport { isTypeOnly, kindOf, restOf, resolvedOf } from \"./inline-exports-resolve.ts\";\nimport type { Resolved } from \"./inline-exports-resolve.ts\";\nimport type {\n Declaration,\n ExportList,\n Import,\n ImportBinding,\n Range,\n} from \"./inline-exports-source.ts\";\nimport {\n commentsBefore,\n indentOf,\n leadingTextOf,\n lineRangeOf,\n textOf,\n} from \"./inline-exports-text.ts\";\nimport type { Source } from \"./inline-exports-text.ts\";\n\nexport interface Edit {\n readonly range: Range;\n readonly text: string;\n}\n\ninterface Reexport {\n readonly statement: Import;\n readonly binding: ImportBinding;\n readonly typeOnly: boolean;\n}\n\ninterface Group {\n readonly statement: Import;\n readonly bindings: readonly ImportBinding[];\n readonly typeOnly: boolean;\n}\n\nconst NAMESPACE_NAME = \"*\";\nconst START = 0;\nconst END = 1;\nconst SINGLE = 1;\nconst NEWLINE = \"\\n\";\nconst EXPORT = \"export \";\nconst KINDS = [false, true] as const;\n\nconst keywordOf = (typeOnly: boolean): string =>\n Bool.match(typeOnly, { onFalse: () => \"export\", onTrue: () => \"export type\" });\n\nconst reexportsOf = (list: ExportList, resolved: readonly Resolved[]): readonly Reexport[] =>\n pipe(\n resolved,\n Arr.flatMap((entry) =>\n pipe(\n kindOf(\"import\")(entry),\n Arr.map((found) => ({\n statement: found.statement,\n binding: found.binding,\n typeOnly: isTypeOnly(list)(entry.specifier) || found.binding.typeOnly,\n })),\n ),\n ),\n );\n\nconst statementsOf = (reexports: readonly Reexport[]): readonly Import[] =>\n pipe(\n reexports,\n Arr.map((entry) => entry.statement),\n Arr.dedupe,\n );\n\nconst groupOf =\n (reexports: readonly Reexport[], statement: Import) =>\n (typeOnly: boolean): readonly Group[] => {\n const bindings = pipe(\n reexports,\n Arr.filter((entry) => entry.statement === statement && entry.typeOnly === typeOnly),\n Arr.map((entry) => entry.binding),\n );\n if (Arr.isReadonlyArrayEmpty(bindings)) {\n return [];\n }\n return [{ statement, bindings, typeOnly }];\n };\n\nconst splitNamespaces = (group: Group): readonly Group[] => {\n const mixed =\n pipe(\n group.bindings,\n Arr.some((binding) => binding.imported === NAMESPACE_NAME),\n ) && group.bindings.length > SINGLE;\n if (!mixed) {\n return [group];\n }\n return pipe(\n group.bindings,\n Arr.map((binding) => ({ ...group, bindings: [binding] })),\n );\n};\n\nconst groupsOf = (reexports: readonly Reexport[]): readonly Group[] =>\n pipe(\n statementsOf(reexports),\n Arr.flatMap((statement) => pipe(KINDS, Arr.flatMap(groupOf(reexports, statement)))),\n Arr.flatMap(splitNamespaces),\n );\n\nconst renamedOf = (binding: ImportBinding): string =>\n Bool.match(binding.imported === binding.local, {\n onFalse: () => `${binding.imported} as ${binding.local}`,\n onTrue: () => binding.imported,\n });\n\nconst reexportTextOf =\n (source: Source) =>\n (group: Group): string => {\n const from = textOf(source)(group.statement.from);\n const keyword = keywordOf(group.typeOnly);\n return pipe(\n group.bindings,\n Arr.findFirst((binding) => binding.imported === NAMESPACE_NAME),\n Option.match({\n onSome: (namespace) => `${keyword} * as ${namespace.local} from ${from};`,\n onNone: () =>\n `${keyword} { ${pipe(group.bindings, Arr.map(renamedOf), Arr.join(\", \"))} } from ${from};`,\n }),\n );\n };\n\nconst replacementOf = (source: Source, list: ExportList, resolved: readonly Resolved[]): string => {\n const rest = restOf(resolved);\n const names = pipe(\n rest,\n Arr.map((specifier) => textOf(source)(specifier.range)),\n Arr.join(\", \"),\n );\n const remaining = Bool.match(Arr.isReadonlyArrayEmpty(rest), {\n onFalse: () => [`${keywordOf(list.typeOnly)} { ${names} };`],\n onTrue: (): readonly string[] => [],\n });\n const defaults = pipe(\n resolved,\n Arr.flatMap(kindOf(\"default\")),\n Arr.map((found) => `export default ${found.name};`),\n );\n const reexports = pipe(groupsOf(reexportsOf(list, resolved)), Arr.map(reexportTextOf(source)));\n return pipe([...remaining, ...defaults, ...reexports], Arr.join(NEWLINE));\n};\n\nconst removedOf = (source: Source, reexports: readonly Reexport[]): readonly Import[] =>\n pipe(\n statementsOf(reexports),\n Arr.filter((statement) =>\n pipe(\n statement.bindings,\n Arr.every(\n (binding) =>\n pipe(\n reexports,\n Arr.some((entry) => entry.statement === statement && entry.binding === binding),\n ) && !pipe(source.usedOutside, Arr.contains(binding.local)),\n ),\n ),\n ),\n );\n\nconst prefixOf =\n (source: Source, comments: string) =>\n (statement: Declaration): string => {\n const start = statement.range[START];\n if (Str.isEmpty(comments) || pipe(leadingTextOf(source)(start), Str.includes(comments))) {\n return EXPORT;\n }\n return `${comments}${NEWLINE}${indentOf(source)(start)}${EXPORT}`;\n };\n\nconst listEditOf = (source: Source, list: ExportList, text: string): Edit => {\n if (!Str.isEmpty(text)) {\n return { range: list.range, text };\n }\n const start = pipe(\n commentsBefore(source)(list.range[START]),\n Arr.head,\n Option.match({ onNone: () => list.range[START], onSome: (first) => first[START] }),\n );\n return { range: lineRangeOf(source)([start, list.range[END]]), text: \"\" };\n};\n\nexport const editsOf =\n (source: Source) =>\n (list: ExportList): Option.Option<readonly Edit[]> => {\n const resolved = resolvedOf(list);\n if (restOf(resolved).length === list.specifiers.length) {\n return Option.none();\n }\n const prefix = prefixOf(source, leadingTextOf(source)(list.range[START]));\n const declarations = pipe(\n resolved,\n Arr.flatMap(kindOf(\"declaration\")),\n Arr.flatMap((found) => found.statements),\n Arr.dedupe,\n Arr.map((statement): Edit => ({\n range: [statement.range[START], statement.range[START]],\n text: prefix(statement),\n })),\n );\n const removals = pipe(\n removedOf(source, reexportsOf(list, resolved)),\n Arr.map((statement) => ({ range: lineRangeOf(source)(statement.range), text: \"\" })),\n );\n return Option.some([\n ...declarations,\n ...removals,\n listEditOf(source, list, replacementOf(source, list, resolved)),\n ]);\n };\n","import { Array as Arr, Option, Schema, pipe } from \"effect\";\n\nexport type Range = readonly [number, number];\n\nexport interface Declaration {\n readonly kind: \"declaration\";\n readonly type: string;\n readonly range: Range;\n readonly names: readonly string[];\n}\n\nexport interface ImportBinding {\n readonly local: string;\n readonly imported: string;\n readonly typeOnly: boolean;\n}\n\nexport interface Import {\n readonly kind: \"import\";\n readonly range: Range;\n readonly from: Range;\n readonly bindings: readonly ImportBinding[];\n}\n\nexport type Statement = Declaration | Import;\n\nexport interface Specifier {\n readonly range: Range;\n readonly local: Option.Option<string>;\n readonly exported: string;\n readonly typeOnly: boolean;\n}\n\nexport interface ExportList {\n readonly range: Range;\n readonly typeOnly: boolean;\n readonly specifiers: readonly Specifier[];\n readonly body: readonly Statement[];\n}\n\nconst TYPE_KIND = \"type\";\nconst DEFAULT_NAME = \"default\";\nconst NAMESPACE_NAME = \"*\";\n\nconst RangeSchema = Schema.Tuple([Schema.Finite, Schema.Finite]);\nconst KindSchema = Schema.optionalKey(Schema.String);\nconst IdentifierSchema = Schema.Struct({ type: Schema.Literal(\"Identifier\"), name: Schema.String });\nconst StringSchema = Schema.Struct({ type: Schema.Literal(\"Literal\"), value: Schema.String });\nconst NameSchema = Schema.Union([IdentifierSchema, StringSchema]);\n\nconst PatternSchema = Schema.Union([\n IdentifierSchema,\n Schema.Struct({\n type: Schema.Literal(\"ObjectPattern\"),\n properties: Schema.Array(Schema.Unknown),\n }),\n Schema.Struct({ type: Schema.Literal(\"ArrayPattern\"), elements: Schema.Array(Schema.Unknown) }),\n Schema.Struct({ type: Schema.Literal(\"Property\"), value: Schema.Unknown }),\n Schema.Struct({ type: Schema.Literal(\"AssignmentPattern\"), left: Schema.Unknown }),\n Schema.Struct({ type: Schema.Literal(\"RestElement\"), argument: Schema.Unknown }),\n]);\nconst decodePattern = Schema.decodeUnknownOption(PatternSchema);\n\nconst BindingSchema = Schema.Union([\n Schema.Struct({\n type: Schema.Literal(\"ImportSpecifier\"),\n local: IdentifierSchema,\n imported: NameSchema,\n importKind: KindSchema,\n }),\n Schema.Struct({\n type: Schema.Literals([\"ImportDefaultSpecifier\", \"ImportNamespaceSpecifier\"]),\n local: IdentifierSchema,\n }),\n]);\n\nconst RangedSchema = Schema.Struct({ range: RangeSchema });\nconst DeclaratorSchema = Schema.Struct({ id: Schema.Unknown });\nconst ExportSpecifierSchema = Schema.Struct({\n range: RangeSchema,\n local: NameSchema,\n exported: NameSchema,\n exportKind: KindSchema,\n});\nconst ParentSchema = Schema.Struct({ body: Schema.Array(Schema.Unknown) });\nconst QuotedSchema = Schema.fromJsonString(Schema.String);\n\nconst decodeImport = Schema.decodeUnknownOption(\n Schema.Struct({\n type: Schema.Literal(\"ImportDeclaration\"),\n range: RangeSchema,\n source: RangedSchema,\n importKind: KindSchema,\n specifiers: Schema.Array(BindingSchema),\n }),\n);\nconst decodeVariable = Schema.decodeUnknownOption(\n Schema.Struct({\n type: Schema.Literal(\"VariableDeclaration\"),\n range: RangeSchema,\n declarations: Schema.Array(DeclaratorSchema),\n }),\n);\nconst decodeNamed = Schema.decodeUnknownOption(\n Schema.Struct({ type: Schema.String, range: RangeSchema, id: IdentifierSchema }),\n);\nconst decodeList = Schema.decodeUnknownOption(\n Schema.Struct({\n range: RangeSchema,\n source: Schema.Null,\n declaration: Schema.Null,\n exportKind: KindSchema,\n specifiers: Schema.Array(ExportSpecifierSchema),\n parent: ParentSchema,\n }),\n);\n\ntype Pattern = typeof PatternSchema.Type;\ntype SinglePattern = Extract<\n Pattern,\n { readonly type: \"Property\" | \"AssignmentPattern\" | \"RestElement\" }\n>;\ntype Binding = typeof BindingSchema.Type;\ntype Name = typeof NameSchema.Type;\n\nconst nameOf = (name: Name): string => {\n if (name.type === \"Literal\") {\n return name.value;\n }\n return name.name;\n};\n\nconst identifierOf = (name: Name): Option.Option<string> => {\n if (name.type === \"Literal\") {\n return Option.none();\n }\n return Option.some(name.name);\n};\n\nconst childOf = (pattern: SinglePattern): unknown => {\n if (pattern.type === \"Property\") {\n return pattern.value;\n }\n if (pattern.type === \"AssignmentPattern\") {\n return pattern.left;\n }\n return pattern.argument;\n};\n\nconst childrenOf = (pattern: Pattern): readonly unknown[] => {\n if (pattern.type === \"ObjectPattern\") {\n return pattern.properties;\n }\n if (pattern.type === \"ArrayPattern\") {\n return pattern.elements;\n }\n if (pattern.type === \"Identifier\") {\n return [];\n }\n return [childOf(pattern)];\n};\n\nconst bindingNames = (node: unknown): readonly string[] =>\n pipe(\n decodePattern(node),\n Option.match({\n onNone: () => [],\n onSome: (pattern) => {\n if (pattern.type === \"Identifier\") {\n return [pattern.name];\n }\n return pipe(childrenOf(pattern), Arr.flatMap(bindingNames));\n },\n }),\n );\n\nconst importedOf = (binding: Binding): string => {\n if (binding.type === \"ImportSpecifier\") {\n if (binding.imported.type === \"Literal\") {\n const { value } = binding.imported;\n return pipe(\n Schema.encodeOption(QuotedSchema)(value),\n Option.getOrElse(() => value),\n );\n }\n return binding.imported.name;\n }\n if (binding.type === \"ImportDefaultSpecifier\") {\n return DEFAULT_NAME;\n }\n return NAMESPACE_NAME;\n};\n\nconst typeOnlyOf = (binding: Binding): boolean =>\n binding.type === \"ImportSpecifier\" && binding.importKind === TYPE_KIND;\n\nconst importOf = (node: unknown): Option.Option<Statement> =>\n pipe(\n decodeImport(node),\n Option.map((statement): Statement => ({\n kind: \"import\",\n range: statement.range,\n from: statement.source.range,\n bindings: pipe(\n statement.specifiers,\n Arr.map((binding) => ({\n local: binding.local.name,\n imported: importedOf(binding),\n typeOnly: statement.importKind === TYPE_KIND || typeOnlyOf(binding),\n })),\n ),\n })),\n );\n\nconst declarationOf = (node: unknown): Option.Option<Statement> =>\n pipe(\n decodeVariable(node),\n Option.map((statement): Statement => ({\n kind: \"declaration\",\n type: statement.type,\n range: statement.range,\n names: pipe(\n statement.declarations,\n Arr.flatMap((declarator) => bindingNames(declarator.id)),\n ),\n })),\n Option.orElse(() =>\n pipe(\n decodeNamed(node),\n Option.map((statement): Statement => ({\n kind: \"declaration\",\n type: statement.type,\n range: statement.range,\n names: [statement.id.name],\n })),\n ),\n ),\n );\n\nconst statementOf = (node: unknown): Option.Option<Statement> =>\n pipe(\n importOf(node),\n Option.orElse(() => declarationOf(node)),\n );\n\nexport const exportListOf = (node: unknown): Option.Option<ExportList> =>\n pipe(\n decodeList(node),\n Option.filter((list) => Arr.isReadonlyArrayNonEmpty(list.specifiers)),\n Option.map((list) => ({\n range: list.range,\n typeOnly: list.exportKind === TYPE_KIND,\n specifiers: pipe(\n list.specifiers,\n Arr.map((specifier) => ({\n range: specifier.range,\n local: identifierOf(specifier.local),\n exported: nameOf(specifier.exported),\n typeOnly: specifier.exportKind === TYPE_KIND,\n })),\n ),\n body: pipe(list.parent.body, Arr.map(statementOf), Arr.getSomes),\n })),\n );\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport type { Context, ESTree, Plugin, Rule } from \"vite-plus/lint/plugins\";\n\nimport { editsOf } from \"./inline-exports-plan.ts\";\nimport { isTypeOnlyClass } from \"./inline-exports-resolve.ts\";\nimport { exportListOf } from \"./inline-exports-source.ts\";\nimport type { ExportList, Range } from \"./inline-exports-source.ts\";\nimport type { Source } from \"./inline-exports-text.ts\";\n\nconst MESSAGE =\n \"export は宣言に付ける(export const・export function など)。ファイルの末尾で export { … } にまとめない。\";\nconst START = 0;\nconst END = 1;\n\nconst outside =\n (list: Range) =>\n (range: Range): boolean =>\n range[START] < list[START] || range[END] > list[END];\n\nconst usedOutside = (context: Context, list: ExportList): readonly string[] =>\n pipe(\n context.sourceCode.scopeManager.scopes,\n Arr.flatMap((scope) => scope.variables),\n Arr.filter((variable) =>\n pipe(\n variable.references,\n Arr.some((reference) => outside(list.range)(reference.identifier.range)),\n ),\n ),\n Arr.map((variable) => variable.name),\n );\n\nconst sourceOf = (context: Context, list: ExportList): Source => ({\n text: context.sourceCode.text,\n comments: pipe(\n context.sourceCode.getAllComments(),\n Arr.map((comment) => comment.range),\n ),\n usedOutside: usedOutside(context, list),\n});\n\nconst reportList = (\n context: Context,\n node: ESTree.ExportNamedDeclaration,\n list: ExportList,\n): void => {\n pipe(\n editsOf(sourceOf(context, list))(list),\n Option.match({\n onNone: () => {\n context.report({ node, message: MESSAGE });\n },\n onSome: (edits) => {\n context.report({\n node,\n message: MESSAGE,\n fix: (fixer) =>\n pipe(\n edits,\n Arr.map((edit) =>\n fixer.replaceTextRange([edit.range[START], edit.range[END]], edit.text),\n ),\n ),\n });\n },\n }),\n );\n};\n\nconst inlineExports: Rule = {\n meta: { type: \"suggestion\", fixable: \"code\" },\n create: (context) => ({\n ExportNamedDeclaration: (node): void => {\n const list = exportListOf(node);\n if (\n Option.isSome(list) &&\n !pipe(list.value.specifiers, Arr.every(isTypeOnlyClass(list.value)))\n ) {\n reportList(context, node, list.value);\n }\n },\n }),\n};\n\nconst plugin: Plugin & { readonly meta: { readonly name: string } } = {\n meta: { name: \"msch-lint\" },\n rules: { \"inline-exports\": inlineExports },\n};\n\nexport default plugin;\n"],"mappings":";;AAkCA,MAAMA,iBAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,oCAAyC,IAAI,IAAI,CACrD,0BACA,wBACF,CAAC;AAED,MAAa,cACV,UACA,cACC,KAAK,YAAY,UAAU;AAE/B,MAAM,mBACH,UACA,SACC,KACE,KAAK,YACLC,MAAI,MACD,cAAc,OAAO,SAAS,UAAU,OAAO,IAAI,KAAK,UAAU,aAAa,IAClF,CACF;AAEJ,MAAMC,mBACH,MAAkB,eAClB,eAAkE;C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ACX,cAAc;GACZ,QAAQ,OAAO;IAAE;IAAM,SAAS;GAAQ,CAAC;EAC3C;EACA,SAAS,UAAU;GACjB,QAAQ,OAAO;IACb;IACA,SAAS;IACT,MAAM,UACJ,KACE,OACAA,MAAI,KAAK,SACP,MAAM,iBAAiB,CAAC,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,GAAG,KAAK,IAAI,CACxE,CACF;GACJ,CAAC;EACH;CACF,CAAC,CACH;AACF;AAiBA,MAAM,SAAgE;CACpE,MAAM,EAAE,MAAM,YAAY;CAC1B,OAAO,EAAE,kBAAkB;EAhB3B,MAAM;GAAE,MAAM;GAAc,SAAS;EAAO;EAC5C,SAAS,aAAa,EACpB,yBAAyB,SAAe;GACtC,MAAM,OAAO,aAAa,IAAI;GAC9B,IACE,OAAO,OAAO,IAAI,KAClB,CAAC,KAAK,KAAK,MAAM,YAAYA,MAAI,MAAM,gBAAgB,KAAK,KAAK,CAAC,CAAC,GAEnE,WAAW,SAAS,MAAM,KAAK,KAAK;EAExC,EACF;CAKuC,EAAE;AAC3C"}
|
package/dist/lint.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as _default } from "./decision-rules-BFywSPLT.mjs";
|
|
2
|
-
declare const lint: {
|
|
2
|
+
export declare const lint: {
|
|
3
3
|
ignorePatterns: string[];
|
|
4
4
|
plugins: ("effecttsgo" | "eslint" | "import" | "jsdoc" | "jsx-a11y" | "node" | "oxc" | "promise" | "react" | "react-perf" | "typescript" | "unicorn")[];
|
|
5
5
|
categories: {
|
|
@@ -47,6 +47,9 @@ declare const lint: {
|
|
|
47
47
|
"eslint/sort-keys": "off";
|
|
48
48
|
"import/no-named-export": "off";
|
|
49
49
|
"import/prefer-default-export": "off";
|
|
50
|
+
"import/group-exports": "off";
|
|
51
|
+
"import/exports-last": "off";
|
|
52
|
+
"msch-lint/inline-exports": "error";
|
|
50
53
|
"react/react-in-jsx-scope": "off";
|
|
51
54
|
"eslint/no-undef": "off";
|
|
52
55
|
"typescript/promise-function-async": "off";
|
|
@@ -64,6 +67,12 @@ declare const lint: {
|
|
|
64
67
|
"jsdoc/check-tag-names": ["error", {
|
|
65
68
|
definedTags: string[];
|
|
66
69
|
}];
|
|
70
|
+
"jsdoc/require-param": ["error", {
|
|
71
|
+
exemptedBy: string[];
|
|
72
|
+
}];
|
|
73
|
+
"jsdoc/require-returns": ["error", {
|
|
74
|
+
exemptedBy: string[];
|
|
75
|
+
}];
|
|
67
76
|
"eslint/no-restricted-imports": ["error", {
|
|
68
77
|
paths: (Readonly<{
|
|
69
78
|
name: string;
|
|
@@ -146,18 +155,18 @@ declare const lint: {
|
|
|
146
155
|
reportUnusedDisableDirectives: "error";
|
|
147
156
|
};
|
|
148
157
|
};
|
|
149
|
-
declare const alchemyOverride: {
|
|
158
|
+
export declare const alchemyOverride: {
|
|
150
159
|
files: string[];
|
|
151
160
|
rules: Readonly<Record<string, ["error", ...unknown[]]>>;
|
|
152
161
|
};
|
|
153
|
-
declare const scriptsOverride: {
|
|
162
|
+
export declare const scriptsOverride: {
|
|
154
163
|
files: string[];
|
|
155
164
|
rules: Readonly<Record<string, "off">>;
|
|
156
165
|
};
|
|
157
|
-
declare const INSTRUMENTATION = "計装は Effect のトレーシングだけで扱う";
|
|
158
|
-
declare const INFRASTRUCTURE = "インフラは Alchemy の IaC と Cloudflare だけで扱い、wrangler は使わない";
|
|
159
|
-
declare const requiredStack: Readonly<Record<string, readonly string[]>>;
|
|
160
|
-
declare const restrictedImports: {
|
|
166
|
+
export declare const INSTRUMENTATION = "計装は Effect のトレーシングだけで扱う";
|
|
167
|
+
export declare const INFRASTRUCTURE = "インフラは Alchemy の IaC と Cloudflare だけで扱い、wrangler は使わない";
|
|
168
|
+
export declare const requiredStack: Readonly<Record<string, readonly string[]>>;
|
|
169
|
+
export declare const restrictedImports: {
|
|
161
170
|
paths: (Readonly<{
|
|
162
171
|
name: string;
|
|
163
172
|
message: string;
|
|
@@ -171,20 +180,20 @@ declare const restrictedImports: {
|
|
|
171
180
|
message: string;
|
|
172
181
|
}>[];
|
|
173
182
|
};
|
|
174
|
-
declare const generated: string[];
|
|
175
|
-
declare const allRulesOf: ({ prefix, rules }: Readonly<{
|
|
183
|
+
export declare const generated: string[];
|
|
184
|
+
export declare const allRulesOf: ({ prefix, rules }: Readonly<{
|
|
176
185
|
prefix: string;
|
|
177
186
|
rules: Readonly<Record<string, unknown>>;
|
|
178
187
|
}>) => Readonly<Record<string, "error">>;
|
|
179
|
-
declare const decisionRules: Readonly<Record<string, "error">>;
|
|
180
|
-
declare const decisionTestRules: Record<string, "off">;
|
|
181
|
-
declare const fsdRules: {
|
|
188
|
+
export declare const decisionRules: Readonly<Record<string, "error">>;
|
|
189
|
+
export declare const decisionTestRules: Record<string, "off">;
|
|
190
|
+
export declare const fsdRules: {
|
|
182
191
|
readonly "fsd/insignificant-slice": "off";
|
|
183
192
|
readonly "fsd/no-cross-imports": "error";
|
|
184
193
|
readonly "fsd/no-higher-level-imports": "error";
|
|
185
194
|
readonly "fsd/no-wildcard-exports": "error";
|
|
186
195
|
};
|
|
187
|
-
declare const readonlyParameterAllow: ({
|
|
196
|
+
export declare const readonlyParameterAllow: ({
|
|
188
197
|
from: "package";
|
|
189
198
|
package: string;
|
|
190
199
|
name: string[];
|
|
@@ -208,5 +217,4 @@ declare const readonlyParameterAllow: ({
|
|
|
208
217
|
package: string;
|
|
209
218
|
name: string;
|
|
210
219
|
})[];
|
|
211
|
-
export { INFRASTRUCTURE, INSTRUMENTATION, alchemyOverride, allRulesOf, decisionRules, decisionTestRules, fsdRules, generated, lint, readonlyParameterAllow, requiredStack, restrictedImports, scriptsOverride };
|
|
212
220
|
//# sourceMappingURL=lint.d.mts.map
|