Skip to content

Commit 2ead77a

Browse files
authored
chore: missing linting error (#48)
1 parent 5af3538 commit 2ead77a

5 files changed

Lines changed: 83 additions & 83 deletions

File tree

NOTICE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This Software contains code from the following open source projects:
66

77
| Name | Installed version | License | Code |
88
| :--------------- | :---------------- | :----------- | :--------------------------------------------------- |
9+
| [@ast-grep/napi](https://www.npmjs.com/package/@ast-grep/napi) | 0.37.0 | MIT | https://ast-grep.github.io |
910
| [@hookform/resolvers](https://www.npmjs.com/package/@hookform/resolvers) | 5.2.2 | MIT | https://react-hook-form.com |
1011
| [@opentelemetry/api](https://www.npmjs.com/package/@opentelemetry/api) | 1.9.0 | Apache-2.0 | https://github.com/open-telemetry/opentelemetry-js/tree/main/api |
1112
| [@opentelemetry/api-logs](https://www.npmjs.com/package/@opentelemetry/api-logs) | 0.208.0 | Apache-2.0 | https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/api-logs |

packages/appkit/bin/appkit-lint.js

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function lintFile(filePath, rules) {
8888
column: range.start.column + 1,
8989
rule: rule.id,
9090
message: rule.message,
91-
code: code.length > 80 ? code.slice(0, 77) + "..." : code,
91+
code: code.length > 80 ? `${code.slice(0, 77)}...` : code,
9292
});
9393
}
9494
}

tools/build-notice.ts

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,9 @@
11
#!/usr/bin/env node
2-
import { execSync } from "node:child_process";
3-
import { readFileSync } from "node:fs";
4-
import { join } from "node:path";
5-
6-
type Package = {
7-
name: string;
8-
versions: string[];
9-
paths: string[];
10-
license: string;
11-
homepage: string;
12-
};
13-
14-
type PackageJson = {
15-
dependencies?: Record<string, string>;
16-
};
17-
18-
// Packages whose direct dependencies we want to include in NOTICE.md
19-
const PUBLISHED_PACKAGES = [
20-
"packages/appkit",
21-
"packages/appkit-ui",
22-
"packages/shared",
23-
];
24-
25-
function getDirectDependencies(): Set<string> {
26-
const directDeps = new Set<string>();
27-
28-
for (const pkgPath of PUBLISHED_PACKAGES) {
29-
const pkgJsonPath = join(process.cwd(), pkgPath, "package.json");
30-
try {
31-
const content = readFileSync(pkgJsonPath, "utf8");
32-
const pkgJson: PackageJson = JSON.parse(content);
33-
34-
if (pkgJson.dependencies) {
35-
for (const depName of Object.keys(pkgJson.dependencies)) {
36-
if (!pkgJson.dependencies[depName].startsWith("workspace:")) {
37-
directDeps.add(depName);
38-
}
39-
}
40-
}
41-
} catch (err) {
42-
console.error(`Warning: Could not read ${pkgJsonPath}:`, err);
43-
}
44-
}
45-
46-
return directDeps;
47-
}
2+
import { type Package, getDirectDependencyLicenses } from "./license-utils";
483

494
try {
50-
const output = execSync("pnpm licenses list --json --production", {
51-
encoding: "utf8",
52-
});
53-
const licenses: Record<string, Package[]> = JSON.parse(output);
54-
const directDeps = getDirectDependencies();
55-
56-
const dependencies: Package[] = [];
57-
58-
for (const [licenseName, packages] of Object.entries(licenses)) {
59-
for (const pkg of packages) {
60-
// Only include direct dependencies
61-
if (directDeps.has(pkg.name)) {
62-
dependencies.push({ ...pkg, license: licenseName });
63-
}
64-
}
65-
}
66-
67-
main(dependencies);
5+
const packages = getDirectDependencyLicenses();
6+
main(packages);
687
} catch (err) {
698
console.error("❌ Error running license check:", err);
709
process.exit(1);
@@ -96,7 +35,7 @@ This Software contains code from the following open source projects:
9635
}
9736
notice += `| [${dep.name}](https://www.npmjs.com/package/${
9837
dep.name
99-
}) | ${dep.versions.join(", ")} | ${dep.license} | ${dep.homepage} |\n`;
38+
}) | ${dep.versions.join(", ")} | ${dep.license} | ${dep.homepage ?? ""} |\n`;
10039
}
10140
// eslint-disable-next-line no-console
10241
console.log(notice);

tools/check-licenses.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { execSync } from "node:child_process";
2+
import { type Package, getDirectDependencyLicenses } from "./license-utils";
33

44
const allowedLicenses = new Set([
55
"MIT",
@@ -27,28 +27,18 @@ const disallowedPatterns = [
2727
/SEE LICEN[CS]E/i,
2828
];
2929

30-
type Package = {
31-
name: string;
32-
versions: string[];
33-
paths: string[];
34-
license: string;
35-
};
36-
3730
try {
38-
const output = execSync("pnpm licenses list --json", { encoding: "utf8" });
39-
const licenses: Record<string, Package[]> = JSON.parse(output);
31+
const packages = getDirectDependencyLicenses();
4032

41-
const violations = [];
33+
const violations: Package[] = [];
4234

43-
for (const [licenseName, packages] of Object.entries(licenses)) {
44-
if (allowedLicenses.has(licenseName)) continue;
35+
for (const pkg of packages) {
36+
if (allowedLicenses.has(pkg.license)) continue;
4537

46-
const isDisallowed = disallowedPatterns.some((rx) => rx.test(licenseName));
38+
const isDisallowed = disallowedPatterns.some((rx) => rx.test(pkg.license));
4739
if (!isDisallowed) continue;
4840

49-
for (const pkg of packages) {
50-
violations.push({ ...pkg, license: licenseName });
51-
}
41+
violations.push(pkg);
5242
}
5343

5444
if (violations.length > 0) {

tools/license-utils.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { execSync } from "node:child_process";
2+
import { readFileSync } from "node:fs";
3+
import { join } from "node:path";
4+
5+
export type Package = {
6+
name: string;
7+
versions: string[];
8+
paths: string[];
9+
license: string;
10+
homepage?: string;
11+
};
12+
13+
type PackageJson = {
14+
dependencies?: Record<string, string>;
15+
};
16+
17+
// Packages whose direct dependencies we want to include in published artifacts
18+
export const PUBLISHED_PACKAGES = [
19+
"packages/appkit",
20+
"packages/appkit-ui",
21+
"packages/shared",
22+
];
23+
24+
export function getDirectDependencies(): Set<string> {
25+
const directDeps = new Set<string>();
26+
27+
for (const pkgPath of PUBLISHED_PACKAGES) {
28+
const pkgJsonPath = join(process.cwd(), pkgPath, "package.json");
29+
try {
30+
const content = readFileSync(pkgJsonPath, "utf8");
31+
const pkgJson: PackageJson = JSON.parse(content);
32+
33+
if (pkgJson.dependencies) {
34+
for (const depName of Object.keys(pkgJson.dependencies)) {
35+
if (!pkgJson.dependencies[depName].startsWith("workspace:")) {
36+
directDeps.add(depName);
37+
}
38+
}
39+
}
40+
} catch (err) {
41+
console.error(`Warning: Could not read ${pkgJsonPath}:`, err);
42+
}
43+
}
44+
45+
return directDeps;
46+
}
47+
48+
/**
49+
* Fetches license data from pnpm and filters to only include direct dependencies
50+
* of published packages.
51+
*/
52+
export function getDirectDependencyLicenses(): Package[] {
53+
const output = execSync("pnpm licenses list --json --production", {
54+
encoding: "utf8",
55+
});
56+
const licenses: Record<string, Package[]> = JSON.parse(output);
57+
const directDeps = getDirectDependencies();
58+
59+
const dependencies: Package[] = [];
60+
61+
for (const [licenseName, packages] of Object.entries(licenses)) {
62+
for (const pkg of packages) {
63+
if (directDeps.has(pkg.name)) {
64+
dependencies.push({ ...pkg, license: licenseName });
65+
}
66+
}
67+
}
68+
69+
return dependencies;
70+
}

0 commit comments

Comments
 (0)