Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI check for forbidden texts #157

Merged
merged 8 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
- uses: actions/checkout@v4
- uses: wyvox/action-setup-pnpm@v3
- run: pnpm build
- name: "Ensure Certain dependencies don't end up in the production bundles"
run: node ./workspace/scripts/build-verify.js

test:
name: "Tests"
Expand Down
8 changes: 4 additions & 4 deletions packages/preact/preact/tests/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
// @vitest-environment jsdom

import { install, setup } from "@starbeam/preact";
Expand Down
8 changes: 4 additions & 4 deletions packages/preact/preact/tests/reactive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
// @vitest-environment jsdom

import { install, setupReactive, useReactive } from "@starbeam/preact";
Expand Down
8 changes: 4 additions & 4 deletions packages/preact/preact/tests/resources.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
// @vitest-environment jsdom

import { install, setupResource, useResource } from "@starbeam/preact";
Expand Down
8 changes: 4 additions & 4 deletions packages/preact/preact/tests/services.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
// @vitest-environment jsdom

import { install, useService } from "@starbeam/preact";
Expand Down
8 changes: 4 additions & 4 deletions packages/preact/preact/tests/sync.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
// @vitest-environment jsdom

import { install, setupSync } from "@starbeam/preact";
Expand Down
5 changes: 4 additions & 1 deletion packages/universal/debug/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"root": true,
"extends": ["plugin:@starbeam-dev/library:recommended"]
"extends": ["plugin:@starbeam-dev/library:recommended"],
"rules": {
"etc/no-commented-out-code": "off"
}
}
4 changes: 2 additions & 2 deletions packages/universal/debug/src/call-stack/debug/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
mapArray,
} from "@starbeam/core-utils";
import type { CallStack, StackFrame } from "@starbeam/interfaces";
import { hasType, verified, verify } from "@starbeam/verify";
import StackTracey from "stacktracey";
import { hasType, verified, verify } /*#__PURE__*/ from "@starbeam/verify";
import StackTracey /*#__PURE__*/ from "stacktracey";

import { parseModule } from "./module.js";

Expand Down
3 changes: 2 additions & 1 deletion packages/universal/debug/tests/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"root": true,
"extends": ["plugin:@starbeam-dev/library:recommended"],
"rules": {
"@typescript-eslint/prefer-readonly": "off"
"@typescript-eslint/prefer-readonly": "off",
"etc/no-commented-out-code": "off"
}
}
2 changes: 1 addition & 1 deletion packages/universal/debug/tests/description.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEBUG } from "@starbeam/debug";
import { DEBUG }/*#__PURE__*/ from "@starbeam/debug";
import { expect, test } from "@starbeam-workspace/test-utils";

test("inferred api", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/universal/debug/tests/stack.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
import { DEBUG } from "@starbeam/debug";
import { DEBUG }/*#__PURE__*/ from "@starbeam/debug";
import type { CallStack } from "@starbeam/interfaces";
import { describe, expect, test } from "vitest";

Expand Down
2 changes: 1 addition & 1 deletion packages/universal/debug/tests/tree.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
import { Tree } from "@starbeam/debug";
import { Tree }/*#__PURE__*/ from "@starbeam/debug";
import { describe, expect, test } from "vitest";

describe("a tree", () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/vue/vue/tests/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
// @vitest-environment jsdom

import { Cell } from "@starbeam/universal";
Expand All @@ -12,9 +12,9 @@

describe("create", () => {
test("baseline", async () => {
const app = App(() => () => h("div", ["hello ", "world"]));

Check warning on line 15 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an `any` value

Check warning on line 15 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value

await renderApp(app).andExpect({ output: "<div>hello world</div>" });

Check warning on line 17 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value

Check warning on line 17 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value

Check warning on line 17 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe member access .andExpect on an `any` value
});

test("reactive values render", async () => {
Expand All @@ -30,7 +30,7 @@

const obj = ReactiveObject(events);

const app = App(() => {

Check warning on line 33 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an `any` value

Check warning on line 33 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value
const counter = setupReactive(obj);

return () => [
Expand All @@ -43,7 +43,7 @@
];
});

const result = await renderApp(app, {

Check warning on line 46 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an `any` value

Check warning on line 46 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value

Check warning on line 46 in packages/vue/vue/tests/create.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `any` typed value
output: (count: number) =>
`<p>count: ${count}</p><button>increment</button>`,
events,
Expand Down
6 changes: 3 additions & 3 deletions packages/vue/vue/tests/resources.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
// @vitest-environment jsdom

import { setupResource } from "@starbeam/vue";
Expand Down
8 changes: 4 additions & 4 deletions packages/vue/vue/tests/services.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
// @vitest-environment jsdom

import { setupService } from "@starbeam/vue";
Expand Down
8 changes: 6 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions workspace/dev-compile/src/rollup/plugins/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ import type { RollupPlugin } from "../utils.js";
* @param {PackageInfo} pkg
* @returns {import("rollup").Plugin}
*/
export default function externals(pkg: PackageInfo): RollupPlugin {
const isExternal = external(pkg);
export default function externals(pkg: PackageInfo, mode: 'development' | 'production'): RollupPlugin {
const isExternal = external(pkg, mode);

return {
name: "starbeam:externals",
Expand All @@ -222,7 +222,7 @@ export default function externals(pkg: PackageInfo): RollupPlugin {
* @param {PackageInfo} pkg
* @returns
*/
function external(pkg: PackageInfo) {
function external(pkg: PackageInfo, mode: 'development' | 'production') {
/**
* @param {string} id
* @returns {boolean}
Expand All @@ -233,8 +233,15 @@ function external(pkg: PackageInfo) {
return INLINE;
}

if (mode === 'production') {
if (id.startsWith('@starbeam/debug') || id.startsWith('@starbeam/verify')) {
return INLINE;
}
}

// Resolve custom rules. These rules include the default behavior of
// well-known helper libraries.
console.log(pkg.starbeam);
for (const rule of pkg.starbeam.inline) {
const isExternal = resolveIsExternal(rule, id);
if (isExternal !== undefined) return isExternal;
Expand Down
27 changes: 12 additions & 15 deletions workspace/dev-compile/src/rollup/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { execSync } from 'node:child_process';
import { join, resolve } from "node:path";

import terser from '@rollup/plugin-terser';
import type {PackageInfo} from "@starbeam-dev/core";
import { Package, rootAt } from "@starbeam-dev/core";
import type { PackageInfo } from "@starbeam-dev/core";
import { Package, rootAt } from "@starbeam-dev/core";
import type { RollupOptions } from "rollup";
import copy from 'rollup-plugin-copy'

Expand Down Expand Up @@ -63,14 +63,11 @@ function compilePackage(pkg: PackageInfo, options: CompileOptions): RollupOption
PLUGINS.push(importMeta(mode));
}

const deps = Object.keys(pkg.dependencies);

const entries = entryPoints(pkg, mode).map((options) => ({
...options,
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved
external: deps,
plugins: [
...PLUGINS,
externals(pkg),
externals(pkg, mode),
typescript(mode)(pkg, {
target: "esnext",
module: "esnext",
Expand Down Expand Up @@ -125,15 +122,15 @@ function entryPoints(
hoistTransitiveImports: false,
exports: "auto",
},
onwarn: (warning, warn) => {
switch (warning.code) {
case "CIRCULAR_DEPENDENCY":
case "EMPTY_BUNDLE":
return;
default:
warn(warning);
}
},
// onwarn: (warning, warn) => {
// switch (warning.code) {
// case "CIRCULAR_DEPENDENCY":
// case "EMPTY_BUNDLE":
// return;
// default:
// warn(warning);
// }
// },
};
}

Expand Down
28 changes: 28 additions & 0 deletions workspace/scripts/build-verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { globby } from "globby";
import { readFile } from "node:fs/promises";

const FORBIDDEN = ["stacktracey", "@starbeam/debug", "@starbeam/verify"];

let files = await globby("**/index.production.js", {
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved
ignore: ["node_modules", "**/node_modules"],
});

let errors = [];

for (let filePath of files) {
let file = await readFile(filePath);
let content = file.toString();

for (let searchFor of FORBIDDEN) {
if (content.includes(searchFor)) {
errors.push({ filePath, found: searchFor });
}
}
}

if (errors.length > 0) {
console.error(errors);
throw new Error(`The forbidden texts were encountered in the above files`);
}

console.info("No forbidden texts!");
8 changes: 8 additions & 0 deletions workspace/scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"private": true,
"name": "@starbeam-workspace/scripts",
"type": "module",
"devDependencies": {
"globby": "^13.2.2"
}
}
Loading