@rafters/veneer 0.0.3 → 0.0.4
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/bin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as relativeFile } from "./lint-
|
|
3
|
-
import { t as check } from "./check-
|
|
2
|
+
import { i as relativeFile } from "./lint-Bqu-nKvP.mjs";
|
|
3
|
+
import { t as check } from "./check-vsAQPYCD.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { existsSync, realpathSync } from "node:fs";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveComponents, c as readConfig, n as report, o as ProjectError, r as compareCodePoints, s as openProject, t as lint } from "./lint-
|
|
1
|
+
import { a as resolveComponents, c as readConfig, n as report, o as ProjectError, r as compareCodePoints, s as openProject, t as lint } from "./lint-Bqu-nKvP.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { lstatSync } from "node:fs";
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as report, o as ProjectError, s as openProject, t as lint } from "./lint-
|
|
2
|
-
import { n as writeDocs, t as check } from "./check-
|
|
1
|
+
import { n as report, o as ProjectError, s as openProject, t as lint } from "./lint-Bqu-nKvP.mjs";
|
|
2
|
+
import { n as writeDocs, t as check } from "./check-vsAQPYCD.mjs";
|
|
3
3
|
export { ProjectError, check, lint, openProject, report, writeDocs };
|
|
@@ -812,6 +812,7 @@ const CLASS_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
812
812
|
]);
|
|
813
813
|
const MAX_RESOLVE_STEPS = 8;
|
|
814
814
|
const realPath = (file) => existsSync(file) ? realpathSync(file) : file;
|
|
815
|
+
const isClassesFile = (file) => file.endsWith(".classes.ts");
|
|
815
816
|
function qualifies(reader, sourceFile) {
|
|
816
817
|
const { fileName } = sourceFile;
|
|
817
818
|
const stem = fileName.replace(/\.(tsx|astro)$/, "");
|
|
@@ -879,11 +880,21 @@ function utilityOf(className) {
|
|
|
879
880
|
}
|
|
880
881
|
return className.slice(start);
|
|
881
882
|
}
|
|
882
|
-
function
|
|
883
|
+
function constInitializer(reader, identifier) {
|
|
883
884
|
const { ts, tc } = reader;
|
|
884
885
|
const declaration = resolveSymbol(reader, tc.getSymbolAtLocation(identifier))?.valueDeclaration;
|
|
885
|
-
|
|
886
|
-
|
|
886
|
+
return declaration && ts.isVariableDeclaration(declaration) && ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const ? declaration.initializer : void 0;
|
|
887
|
+
}
|
|
888
|
+
function constString(reader, identifier) {
|
|
889
|
+
const initializer = constInitializer(reader, identifier);
|
|
890
|
+
return initializer && reader.ts.isStringLiteralLike(initializer) ? initializer : void 0;
|
|
891
|
+
}
|
|
892
|
+
function constProperty(reader, { expression, name }) {
|
|
893
|
+
const { ts } = reader;
|
|
894
|
+
let object = ts.isIdentifier(expression) ? constInitializer(reader, expression) : void 0;
|
|
895
|
+
while (object && (ts.isAsExpression(object) || ts.isSatisfiesExpression(object))) object = object.expression;
|
|
896
|
+
if (!object || !ts.isObjectLiteralExpression(object)) return void 0;
|
|
897
|
+
for (const property of object.properties) if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) && property.name.text === name.text) return ts.isStringLiteralLike(property.initializer) ? property.initializer : void 0;
|
|
887
898
|
}
|
|
888
899
|
function collectClassStrings(reader, sourceFile, isOwnSource, node, found) {
|
|
889
900
|
const { ts } = reader;
|
|
@@ -894,9 +905,17 @@ function collectClassStrings(reader, sourceFile, isOwnSource, node, found) {
|
|
|
894
905
|
if (!literal || !declaredIn) return;
|
|
895
906
|
if (declaredIn === sourceFile) found.set(literal, literal);
|
|
896
907
|
else if (isOwnSource(declaredIn.fileName)) found.set(node, literal);
|
|
897
|
-
} else
|
|
898
|
-
|
|
899
|
-
|
|
908
|
+
} else {
|
|
909
|
+
const literal = ts.isPropertyAccessExpression(node) ? constProperty(reader, node) : void 0;
|
|
910
|
+
const declaredIn = literal?.getSourceFile();
|
|
911
|
+
if (literal && declaredIn && (declaredIn === sourceFile || isOwnSource(declaredIn.fileName))) {
|
|
912
|
+
found.set(node, literal);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
ts.forEachChild(node, (child) => {
|
|
916
|
+
collectClassStrings(reader, sourceFile, isOwnSource, child, found);
|
|
917
|
+
});
|
|
918
|
+
}
|
|
900
919
|
}
|
|
901
920
|
function bracketsInLiteral(reader, file, sourceFile, at, literal) {
|
|
902
921
|
return [...literal.getText(literal.getSourceFile()).slice(1, -1).matchAll(/\S+/g)].flatMap((match) => {
|
|
@@ -920,8 +939,12 @@ function bracketsInLiteral(reader, file, sourceFile, at, literal) {
|
|
|
920
939
|
function bracketValues(reader, file, sourceFile, isOwnSource) {
|
|
921
940
|
const { ts } = reader;
|
|
922
941
|
const strings = /* @__PURE__ */ new Map();
|
|
942
|
+
const everyLiteral = isClassesFile(sourceFile.fileName);
|
|
943
|
+
if (everyLiteral && !isOwnSource(sourceFile.fileName)) return [];
|
|
923
944
|
const visit = (node) => {
|
|
924
|
-
if (
|
|
945
|
+
if (everyLiteral) {
|
|
946
|
+
if (ts.isStringLiteralLike(node)) strings.set(node, node);
|
|
947
|
+
} else if (ts.isJsxAttribute(node) && node.initializer) {
|
|
925
948
|
const { name } = node;
|
|
926
949
|
const attribute = ts.isJsxNamespacedName(name) ? `${name.namespace.text}:${name.name.text}` : name.text;
|
|
927
950
|
if (CLASS_ATTRIBUTES.has(attribute)) collectClassStrings(reader, sourceFile, isOwnSource, node.initializer, strings);
|
|
@@ -969,7 +992,7 @@ function valueAttributes({ ts }, sourceFile) {
|
|
|
969
992
|
return found;
|
|
970
993
|
}
|
|
971
994
|
async function lint(project, options) {
|
|
972
|
-
const files = options.files ?? project.checker.getRootFileNames().filter((file) => file.endsWith(".tsx") || file.endsWith(".astro")).map((file) => relativeFile(project.root, file));
|
|
995
|
+
const files = options.files?.filter((file) => !file.endsWith(".ts") || isClassesFile(file)) ?? project.checker.getRootFileNames().filter((file) => file.endsWith(".tsx") || file.endsWith(".astro") || isClassesFile(file)).map((file) => relativeFile(project.root, file));
|
|
973
996
|
const perFile = [];
|
|
974
997
|
for (const file of files) perFile.push([file, await project.diagnostics(file)]);
|
|
975
998
|
const program = project.program();
|
package/dist/worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as readConfig, s as openProject, t as lint } from "./lint-
|
|
1
|
+
import { c as readConfig, s as openProject, t as lint } from "./lint-Bqu-nKvP.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { promisify } from "node:util";
|