@vvedantb/config 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/android-release-cli.js +0 -40
- package/dist/android-release-version.d.ts +0 -20
- package/dist/android-release-version.js +0 -15
- package/dist/android-release.d.ts +0 -54
- package/dist/android-release.js +0 -20
- package/dist/check-asar-cli.js +0 -1
- package/dist/check-asar.d.ts +0 -2
- package/dist/check-asar.js +0 -7
- package/dist/check-no-comments.js +2 -3
- package/dist/check-no-source-text.js +0 -1
- package/dist/check-shared-ui.d.ts +0 -12
- package/dist/check-shared-ui.js +0 -1
- package/dist/clerk-allow.js +0 -6
- package/dist/doctor.d.ts +0 -7
- package/dist/doctor.js +0 -14
- package/dist/expo.d.ts +0 -14
- package/dist/expo.js +0 -5
- package/dist/extension.d.ts +0 -18
- package/dist/extension.js +0 -2
- package/dist/oxlint-anti-slop/define.js +0 -2
- package/dist/oxlint-anti-slop/index.d.ts +0 -1
- package/dist/oxlint-anti-slop/index.js +0 -1
- package/dist/release-signing.d.ts +0 -36
- package/dist/release-signing.js +0 -7
- package/dist/sync.d.ts +0 -3
- package/dist/versions.d.ts +0 -2
- package/dist/versions.js +0 -2
- package/dist/vite.d.ts +0 -16
- package/dist/vitest-shared-setup.js +0 -8
- package/dist/vitest-shared.d.ts +0 -9
- package/dist/vitest-shared.js +0 -15
- package/oxlint/plugin.mjs +0 -20
- package/oxlint/rules/no-comments.mjs +9 -2
- package/oxlint/rules/no-conditional-tests.mjs +0 -2
- package/oxlint/rules/no-double-cast.mjs +0 -1
- package/oxlint/rules/no-inline-zod-schema.mjs +0 -3
- package/oxlint/rules/no-is-record.mjs +0 -5
- package/oxlint/rules/no-json-parse.mjs +0 -6
- package/oxlint/rules/no-settings-description.mjs +0 -5
- package/oxlint/rules/no-source-text-in-tests.mjs +0 -7
- package/oxlint/rules/no-unknown-shape-probing.mjs +0 -6
- package/oxlint/rules/no-value-block-in-try.mjs +0 -23
- package/oxlint/rules/prefer-schema-inferred-types.mjs +0 -5
- package/oxlint/utils.mjs +0 -2
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -45,14 +45,12 @@ function readJson(path) {
|
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
/** Workspace globs from pnpm-workspace.yaml, parsed without a YAML dependency. */
|
|
49
48
|
function parsePnpmWorkspace(root) {
|
|
50
49
|
const file = join(root, "pnpm-workspace.yaml");
|
|
51
50
|
if (!existsSync(file))
|
|
52
51
|
return [];
|
|
53
52
|
const globs = [];
|
|
54
53
|
let inPackages = false;
|
|
55
|
-
// A leading byte-order mark would hide `packages:` on the first line.
|
|
56
54
|
const text = readFileSync(file, "utf8").replace(/^/, "");
|
|
57
55
|
for (const raw of text.split(/\r?\n/)) {
|
|
58
56
|
if (/^packages\s*:/.test(raw)) {
|
|
@@ -68,12 +66,10 @@ function parsePnpmWorkspace(root) {
|
|
|
68
66
|
}
|
|
69
67
|
if (raw.trim() === "")
|
|
70
68
|
continue;
|
|
71
|
-
// A dedented or indented non-list line ends the `packages:` block.
|
|
72
69
|
inPackages = false;
|
|
73
70
|
}
|
|
74
71
|
return globs;
|
|
75
72
|
}
|
|
76
|
-
/** Workspace globs from a root package.json `workspaces` field. */
|
|
77
73
|
function npmWorkspaceGlobs(json) {
|
|
78
74
|
const field = json?.workspaces;
|
|
79
75
|
if (Array.isArray(field))
|
|
@@ -88,7 +84,6 @@ function segmentMatch(segment, name) {
|
|
|
88
84
|
const pattern = segment.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("*", "[^/]*");
|
|
89
85
|
return new RegExp(`^${pattern}$`).test(name);
|
|
90
86
|
}
|
|
91
|
-
/** Directories under `base` matching the `/`-split glob segments. */
|
|
92
87
|
function walkGlob(base, segments) {
|
|
93
88
|
if (segments.length === 0)
|
|
94
89
|
return [base];
|
|
@@ -111,7 +106,6 @@ function walkGlob(base, segments) {
|
|
|
111
106
|
function matchGlob(root, pattern) {
|
|
112
107
|
return walkGlob(root, pattern.split("/").filter((s) => s.length > 0));
|
|
113
108
|
}
|
|
114
|
-
/** Expand workspace globs to the absolute directories they match, honouring `!` excludes. */
|
|
115
109
|
function expandWorkspaces(root, globs) {
|
|
116
110
|
const include = new Set();
|
|
117
111
|
const exclude = new Set();
|
|
@@ -303,7 +297,6 @@ export function checkConfigVersion(repo, runningVersion) {
|
|
|
303
297
|
}
|
|
304
298
|
return result("config-version", "@vvedantb/config is current to the running minor", details);
|
|
305
299
|
}
|
|
306
|
-
/** Where the shared ci-app.yml lives. A repo may call either one; the first is the one to use from now on. */
|
|
307
300
|
const CI_WORKFLOW_REFS = [
|
|
308
301
|
"vvedantb/workflows/.github/workflows/ci-app.yml",
|
|
309
302
|
"vvedantb/packages/.github/workflows/ci-app.yml",
|
|
@@ -325,7 +318,6 @@ export function checkCiReusableWorkflow(repo) {
|
|
|
325
318
|
found = true;
|
|
326
319
|
}
|
|
327
320
|
catch {
|
|
328
|
-
// Unreadable workflow file: ignore and keep scanning.
|
|
329
321
|
}
|
|
330
322
|
}
|
|
331
323
|
const details = found ? [] : [`no workflow calls ${CI_WORKFLOW_REFS[0]}`];
|
|
@@ -343,7 +335,6 @@ function workflowFiles(root) {
|
|
|
343
335
|
files.push({ name, text: readFileSync(join(dir, name), "utf8") });
|
|
344
336
|
}
|
|
345
337
|
catch {
|
|
346
|
-
// Unreadable workflow file: ignore and keep scanning.
|
|
347
338
|
}
|
|
348
339
|
}
|
|
349
340
|
return files;
|
|
@@ -352,11 +343,6 @@ const BOAT_LABELS = ["boat-small", "boat", "boat-large", "boat-xlarge"];
|
|
|
352
343
|
const BOAT_GUIDANCE = "check jobs use boat; boat-large is for Android release builds";
|
|
353
344
|
const ANDROID_RELEASE_WORKFLOW = /(?:^|\/)(?:release-android-apk|release-gallery-android)\.ya?ml(?:@|$)/;
|
|
354
345
|
const CI_APP_WORKFLOW = /(?:^|\/)ci-app\.ya?ml(?:@|$)/;
|
|
355
|
-
/**
|
|
356
|
-
* Scans a workflow for runner lines and for each job's own `uses:` value (the reusable workflow
|
|
357
|
-
* it calls). Jobs are the keys one level under `jobs:`. A `uses:` counts only at the job's own
|
|
358
|
-
* level, so a step's `uses: actions/checkout` is ignored.
|
|
359
|
-
*/
|
|
360
346
|
function scanRunners(text) {
|
|
361
347
|
const runners = [];
|
|
362
348
|
const jobUses = [];
|
package/dist/expo.d.ts
CHANGED
|
@@ -32,31 +32,17 @@ export interface MetroConfigLike {
|
|
|
32
32
|
export interface NativeWindMetroOptions {
|
|
33
33
|
input: string;
|
|
34
34
|
inlineRem?: number;
|
|
35
|
-
/** NativeWind `configPath` (the Tailwind config). Not passed when unset. */
|
|
36
35
|
configPath?: string;
|
|
37
36
|
}
|
|
38
37
|
export interface ExpoMetroOptions<Config extends MetroConfigLike> {
|
|
39
|
-
/** The app folder: `__dirname`. */
|
|
40
38
|
projectRoot: string;
|
|
41
|
-
/** `getDefaultConfig` from `expo/metro-config`. */
|
|
42
39
|
getDefaultConfig: (projectRoot: string) => Config;
|
|
43
|
-
/** `withNativeWind` from `nativewind/metro`. */
|
|
44
40
|
withNativeWind: (config: Config, options: NativeWindMetroOptions) => Config;
|
|
45
|
-
/** NativeWind CSS entry. Default `"./global.css"`. */
|
|
46
41
|
input?: string;
|
|
47
|
-
/** NativeWind `inlineRem`. Not passed when unset, so NativeWind keeps its default. */
|
|
48
42
|
inlineRem?: number;
|
|
49
|
-
/** NativeWind `configPath` (the Tailwind config), relative to `projectRoot` or absolute. Not passed when unset. */
|
|
50
43
|
nativeWindConfig?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Module names to resolve from the app, not a nested copy, such as
|
|
53
|
-
* `["react", "react-dom"]`. Sets `resolver.resolveRequest` before
|
|
54
|
-
* `withNativeWind`, so a single React instance is used across the monorepo.
|
|
55
|
-
*/
|
|
56
44
|
singletons?: readonly string[];
|
|
57
|
-
/** Monorepo root relative to `projectRoot`, such as `"../.."`. Watches it and resolves from both node_modules folders. */
|
|
58
45
|
monorepoRoot?: string;
|
|
59
|
-
/** Sets `resolver.unstable_enablePackageExports: true`. */
|
|
60
46
|
packageExports?: boolean;
|
|
61
47
|
}
|
|
62
48
|
/**
|
package/dist/expo.js
CHANGED
|
@@ -10,11 +10,6 @@ export function expoBabelConfig(api) {
|
|
|
10
10
|
presets: [["babel-preset-expo", { jsxImportSource: "nativewind" }], "nativewind/babel"],
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Sets `resolver.resolveRequest` so the given module names resolve from the
|
|
15
|
-
* app root (`package.json`), not from a nested copy. Mutates `config` in place,
|
|
16
|
-
* before `withNativeWind` wraps it (NativeWind chains to this resolver).
|
|
17
|
-
*/
|
|
18
13
|
function installSingletonResolver(config, projectRoot, singletons) {
|
|
19
14
|
const resolver = config.resolver;
|
|
20
15
|
if (resolver === undefined)
|
package/dist/extension.d.ts
CHANGED
|
@@ -2,15 +2,8 @@ import { type ReactSetup, type VitePluginOption } from "./vite.js";
|
|
|
2
2
|
export interface ExtensionHostOptions {
|
|
3
3
|
/** Match patterns in every build, for example `"https://app.example.com/*"` or `"<all_urls>"`. */
|
|
4
4
|
hosts: readonly string[];
|
|
5
|
-
/** Match patterns in development builds only (`mode === "development"`), such as staging hosts. */
|
|
6
5
|
devHosts?: readonly string[];
|
|
7
|
-
/** The Vite or WXT mode. */
|
|
8
6
|
mode: string;
|
|
9
|
-
/**
|
|
10
|
-
* Web pages that may message the extension (`externally_connectable.matches`). Off by default.
|
|
11
|
-
* `true`: every host in this build that names one (not `<all_urls>` or a `*` host).
|
|
12
|
-
* A list: those patterns only. Each must be in `hosts` or `devHosts`; dev hosts count in development only.
|
|
13
|
-
*/
|
|
14
7
|
connectable?: boolean | readonly string[];
|
|
15
8
|
}
|
|
16
9
|
export interface ExtensionHostPermissions {
|
|
@@ -53,23 +46,12 @@ export interface VExtensionViteConfig {
|
|
|
53
46
|
};
|
|
54
47
|
}
|
|
55
48
|
export interface VExtensionOptions<Preset, Manifest extends object> extends Omit<ExtensionHostOptions, "mode"> {
|
|
56
|
-
/** Manifest `name`. */
|
|
57
49
|
app: string;
|
|
58
|
-
/** `@vitejs/plugin-react`, as in `defineWebViteConfig`. First plugin. */
|
|
59
50
|
react?: ReactSetup<Preset>;
|
|
60
|
-
/** `@tailwindcss/vite`. Added after React. */
|
|
61
51
|
tailwindcss?: () => VitePluginOption;
|
|
62
|
-
/** App Vite plugins, added last. Falsy entries are dropped. */
|
|
63
52
|
plugins?: VitePluginOption[];
|
|
64
|
-
/** WXT modules by package name, for example `"@wxt-dev/module-react"` instead of `react`. */
|
|
65
53
|
modules?: string[];
|
|
66
|
-
/** `vite.build.target`, for example `"chrome120"`. */
|
|
67
54
|
buildTarget?: string;
|
|
68
|
-
/**
|
|
69
|
-
* The app's other manifest keys (description, version, permissions, ...), or a function of
|
|
70
|
-
* WXT's env that returns them. They win over the preset's keys, except `action`, which is
|
|
71
|
-
* merged over `{ default_icon }`.
|
|
72
|
-
*/
|
|
73
55
|
manifest?: Manifest | ((env: ExtensionConfigEnv) => Manifest);
|
|
74
56
|
}
|
|
75
57
|
export interface VExtensionConfig<Manifest extends object> {
|
package/dist/extension.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { reactPlugins } from "./vite.js";
|
|
2
|
-
/** `<scheme>://<host>/<path>` with an http(s) or `*` scheme. */
|
|
3
2
|
const MATCH_PATTERN = /^(\*|https?):\/\/([^/]+)\/.*$/;
|
|
4
|
-
/** The `externally_connectable` form of a host pattern: same scheme and host, path `/*`. */
|
|
5
3
|
function connectableMatch(pattern) {
|
|
6
4
|
const match = MATCH_PATTERN.exec(pattern);
|
|
7
5
|
if (!match || match[2] === "*")
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
// `@oxlint/plugins` ships `defineRule` and `definePlugin` as identity functions. They are
|
|
2
|
-
// inlined so this package keeps no runtime dependency; the types come from a dev dependency.
|
|
3
1
|
export const defineRule = (rule) => rule;
|
|
4
2
|
export const definePlugin = (plugin) => plugin;
|
|
@@ -9,7 +9,6 @@ import { noUnknownParametersRule } from "./rules/no-unknown-parameters.js";
|
|
|
9
9
|
import { noUnknownTypeAliasesRule } from "./rules/no-unknown-type-aliases.js";
|
|
10
10
|
import { noUnsafeDictionaryTypeRule } from "./rules/no-unsafe-dictionary-type.js";
|
|
11
11
|
import { noWidenThenAssertRule } from "./rules/no-widen-then-assert.js";
|
|
12
|
-
/** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
|
|
13
12
|
const antiSlopPlugin = definePlugin({
|
|
14
13
|
meta: { name: "anti-slop" },
|
|
15
14
|
rules: {
|
|
@@ -1,54 +1,19 @@
|
|
|
1
1
|
/** The keystore.properties / environment variable names the Groovy reads. */
|
|
2
2
|
export interface ReleaseSigningPropertyKeys {
|
|
3
|
-
/** Key for the keystore file path. */
|
|
4
3
|
storeFile: string;
|
|
5
|
-
/** Key for the keystore password. */
|
|
6
4
|
storePassword: string;
|
|
7
|
-
/** Key for the key alias. */
|
|
8
5
|
keyAlias: string;
|
|
9
|
-
/** Key for the key password. */
|
|
10
6
|
keyPassword: string;
|
|
11
7
|
}
|
|
12
8
|
export interface ReleaseSigningOptions {
|
|
13
|
-
/**
|
|
14
|
-
* The marker comment line. It makes the append idempotent and is what a
|
|
15
|
-
* build script greps for. Default `DEFAULT_RELEASE_SIGNING_MARKER`.
|
|
16
|
-
* Set it to the token the app's build script already matches.
|
|
17
|
-
*/
|
|
18
9
|
marker?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Groovy expression for the `keystore.properties` file, read inside
|
|
21
|
-
* `app/build.gradle`. Default `rootProject.file("../../../keystore.properties")`
|
|
22
|
-
* (the repository root, three levels above `android/app`).
|
|
23
|
-
*/
|
|
24
10
|
keystorePropertiesFile?: string;
|
|
25
|
-
/** Environment / properties key names. Default the `ANDROID_*` set. */
|
|
26
11
|
propertyKeys?: Partial<ReleaseSigningPropertyKeys>;
|
|
27
|
-
/** `storeType` for the signing config, such as `"pkcs12"`. Omitted when unset. */
|
|
28
12
|
storeType?: string;
|
|
29
|
-
/** Skip the append when `EAS_BUILD` is set (EAS handles its own signing). Default `false`. */
|
|
30
13
|
skipOnEasBuild?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Groovy boolean expression deciding whether a build signs `release`. It runs
|
|
33
|
-
* inside `gradle.taskGraph.whenReady { graph -> ... }` with `graph` and
|
|
34
|
-
* `project` in scope. Default: any task of this project whose name contains
|
|
35
|
-
* `"release"` (case-insensitive).
|
|
36
|
-
*/
|
|
37
14
|
releaseTaskCondition?: string;
|
|
38
|
-
/**
|
|
39
|
-
* An exact Groovy block to append instead of the generated template. Use it
|
|
40
|
-
* to keep an app's existing Gradle text byte for byte. `marker` is then
|
|
41
|
-
* required and must appear in the block. The template options above
|
|
42
|
-
* (`keystorePropertiesFile`, `propertyKeys`, `storeType`,
|
|
43
|
-
* `releaseTaskCondition`) are ignored.
|
|
44
|
-
*/
|
|
45
15
|
gradleBlock?: string;
|
|
46
|
-
/** Throw when `app/build.gradle` is not Groovy. Default `false`. */
|
|
47
16
|
requireGroovy?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Append the block after `contents.trimEnd()` and a blank line, instead of
|
|
50
|
-
* directly after `contents`. Only applies with `gradleBlock`. Default `false`.
|
|
51
|
-
*/
|
|
52
17
|
trimContentsBeforeAppend?: boolean;
|
|
53
18
|
}
|
|
54
19
|
/** The part of an Expo `appBuildGradle` mod this plugin touches. */
|
|
@@ -61,7 +26,6 @@ export interface AppBuildGradleMod {
|
|
|
61
26
|
/** The part of `withAppBuildGradle` from `expo/config-plugins` this plugin uses. */
|
|
62
27
|
export type WithAppBuildGradle = <Config>(config: Config, action: (mod: AppBuildGradleMod) => AppBuildGradleMod) => Config;
|
|
63
28
|
export interface WithReleaseSigningOptions extends ReleaseSigningOptions {
|
|
64
|
-
/** `withAppBuildGradle` from `expo/config-plugins`. Resolved from the app when unset. */
|
|
65
29
|
withAppBuildGradle?: WithAppBuildGradle;
|
|
66
30
|
}
|
|
67
31
|
export declare const DEFAULT_RELEASE_SIGNING_MARKER = "// @generated @vvedantb/config plugins/withReleaseSigning.js";
|
package/dist/release-signing.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
// The default contains `plugins/withReleaseSigning.js` on purpose: each app's
|
|
4
|
-
// build script greps android/app/build.gradle for that exact substring to
|
|
5
|
-
// confirm signing was patched in, so the default marker satisfies that grep.
|
|
6
|
-
// An app whose own test asserts a different marker passes `marker` to match it.
|
|
7
3
|
export const DEFAULT_RELEASE_SIGNING_MARKER = "// @generated @vvedantb/config plugins/withReleaseSigning.js";
|
|
8
4
|
const DEFAULT_PROPERTY_KEYS = {
|
|
9
5
|
storeFile: "ANDROID_KEYSTORE_PATH",
|
|
@@ -90,9 +86,6 @@ export function appendReleaseSigning(contents, options) {
|
|
|
90
86
|
return contents + releaseSigningGradle(options);
|
|
91
87
|
}
|
|
92
88
|
function loadWithAppBuildGradle() {
|
|
93
|
-
// Resolve from the app (Expo runs config plugins with the app as the working
|
|
94
|
-
// directory), not from this package: under a strict node_modules layout this
|
|
95
|
-
// package cannot see the app's `expo`.
|
|
96
89
|
const require = createRequire(join(process.cwd(), "package.json"));
|
|
97
90
|
const plugins = require("expo/config-plugins");
|
|
98
91
|
return plugins.withAppBuildGradle;
|
package/dist/sync.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
export type PlannedChange = {
|
|
2
|
-
/** Path relative to the consumer repo root, with forward slashes. */
|
|
3
2
|
path: string;
|
|
4
3
|
content: string;
|
|
5
4
|
action: "create" | "update";
|
|
6
5
|
};
|
|
7
6
|
export type SyncOptions = {
|
|
8
7
|
cwd: string;
|
|
9
|
-
/** Report drift without writing. */
|
|
10
8
|
check?: boolean;
|
|
11
9
|
};
|
|
12
10
|
export type SyncResult = {
|
|
13
11
|
changes: PlannedChange[];
|
|
14
|
-
/** Problems that stopped a file from being planned (for example bad JSON). */
|
|
15
12
|
errors: string[];
|
|
16
13
|
};
|
|
17
14
|
/** Installs the Claude Code CLI when missing. Sudo first, then a `~/.local` prefix. */
|
package/dist/versions.d.ts
CHANGED
package/dist/versions.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -44,9 +44,7 @@ export type AliasOptions = Record<string, string> | {
|
|
|
44
44
|
replacement: string;
|
|
45
45
|
}[];
|
|
46
46
|
export interface PathOptions {
|
|
47
|
-
/** Sets `resolve.tsconfigPaths: true` (Vite 8). */
|
|
48
47
|
tsconfigPaths?: boolean;
|
|
49
|
-
/** `resolve.alias`, as given. See `srcAlias`. */
|
|
50
48
|
alias?: AliasOptions;
|
|
51
49
|
}
|
|
52
50
|
export interface ResolveConfig {
|
|
@@ -72,20 +70,14 @@ export interface WebBuildConfig {
|
|
|
72
70
|
};
|
|
73
71
|
}
|
|
74
72
|
export interface WebViteOptions<Preset> extends PathOptions {
|
|
75
|
-
/** `@tailwindcss/vite`. Added first. */
|
|
76
73
|
tailwindcss?: () => VitePluginOption;
|
|
77
|
-
/** `@tanstack/router-plugin/vite`. Added after Tailwind; `autoCodeSplitting: true` is always set. */
|
|
78
74
|
router?: {
|
|
79
75
|
plugin: (options: RouterPluginOptions) => VitePluginOption;
|
|
80
76
|
options?: Omit<RouterPluginOptions, "autoCodeSplitting">;
|
|
81
77
|
};
|
|
82
|
-
/** `@vitejs/plugin-react`. Added after the router. */
|
|
83
78
|
react: ReactSetup<Preset>;
|
|
84
|
-
/** App plugins, added last. Falsy entries are dropped. */
|
|
85
79
|
plugins?: VitePluginOption[];
|
|
86
|
-
/** `resolve.dedupe`, as given. See `REACT_DEDUPE`. */
|
|
87
80
|
dedupe?: readonly string[];
|
|
88
|
-
/** Splits vendor chunks with rolldown. `true` uses the default tests; an object replaces some of them. */
|
|
89
81
|
vendorChunks?: boolean | Partial<Record<VendorChunk, RegExp>>;
|
|
90
82
|
}
|
|
91
83
|
export interface WebViteConfig {
|
|
@@ -95,17 +87,9 @@ export interface WebViteConfig {
|
|
|
95
87
|
}
|
|
96
88
|
export interface WebVitestOptions extends PathOptions {
|
|
97
89
|
plugins?: VitePluginOption[];
|
|
98
|
-
/** Sets `esbuild: { jsx: "automatic" }`, so `.tsx` tests need no React import. */
|
|
99
90
|
automaticJsx?: boolean;
|
|
100
|
-
/** Test globs. Default `["src/**\/*.test.ts"]`. */
|
|
101
91
|
include?: string[];
|
|
102
|
-
/** Packages Vitest transforms instead of loading from node_modules (`test.server.deps.inline`). */
|
|
103
92
|
inline?: string[];
|
|
104
|
-
/**
|
|
105
|
-
* `resolve.dedupe`, as given. See `REACT_DEDUPE`. Set it when the tests load a
|
|
106
|
-
* workspace package from source: without it that package can load another copy
|
|
107
|
-
* of React than the app's.
|
|
108
|
-
*/
|
|
109
93
|
dedupe?: readonly string[];
|
|
110
94
|
}
|
|
111
95
|
export interface WebVitestConfig {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { afterEach, vi } from "vitest";
|
|
2
|
-
// Added to `setupFiles` by `sharedWorkerVitestConfig`. With isolation off, every test
|
|
3
|
-
// file shares one worker, so state set in one test can leak into the next. The preset's
|
|
4
|
-
// config flags (`restoreMocks`, `unstubEnvs`, `unstubGlobals`) reset mocks, env stubs and
|
|
5
|
-
// global stubs after each test; fake timers have no config flag, so reset them here.
|
|
6
|
-
//
|
|
7
|
-
// This does NOT reset module-level state: a module's own top-level variables, caches or
|
|
8
|
-
// singletons created on import persist for the whole run. A test file that mutates that
|
|
9
|
-
// state must restore it itself (see the README cleanup rules).
|
|
10
2
|
afterEach(() => {
|
|
11
3
|
vi.useRealTimers();
|
|
12
4
|
});
|
package/dist/vitest-shared.d.ts
CHANGED
|
@@ -3,24 +3,17 @@ import type { WebVitestConfig } from "./vite.js";
|
|
|
3
3
|
export declare const SHARED_WORKER_SETUP: string;
|
|
4
4
|
/** The `test` fields the shared-worker preset sets. */
|
|
5
5
|
export interface SharedWorkerTestConfig {
|
|
6
|
-
/** Files on the same worker share one environment instead of reloading per file. */
|
|
7
6
|
isolate: false;
|
|
8
|
-
/** Random file order so cross-file state leaks surface. `tests` stays stable by default. */
|
|
9
7
|
sequence: {
|
|
10
8
|
shuffle: {
|
|
11
9
|
files: boolean;
|
|
12
10
|
tests: boolean;
|
|
13
11
|
};
|
|
14
12
|
};
|
|
15
|
-
/** Restore spied/mocked implementations after each test. */
|
|
16
13
|
restoreMocks: true;
|
|
17
|
-
/** Undo `vi.stubEnv` after each test. */
|
|
18
14
|
unstubEnvs: true;
|
|
19
|
-
/** Undo `vi.stubGlobal` after each test. */
|
|
20
15
|
unstubGlobals: true;
|
|
21
|
-
/** The shared reset setup first, then any the caller passed. */
|
|
22
16
|
setupFiles: string[];
|
|
23
|
-
/** Carried over from the base config when present. */
|
|
24
17
|
environment?: string;
|
|
25
18
|
include?: string[];
|
|
26
19
|
server?: {
|
|
@@ -37,9 +30,7 @@ export interface SharedWorkerVitestConfig {
|
|
|
37
30
|
test: SharedWorkerTestConfig;
|
|
38
31
|
}
|
|
39
32
|
export interface SharedWorkerOptions {
|
|
40
|
-
/** Also shuffle test order within each file. Default `false` (only file order shuffles). */
|
|
41
33
|
shuffleTests?: boolean;
|
|
42
|
-
/** Extra setup files, run after the shared reset setup. */
|
|
43
34
|
setupFiles?: string[];
|
|
44
35
|
}
|
|
45
36
|
/**
|
package/dist/vitest-shared.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
// An opt-in Vitest preset that trades isolation for speed. Vitest normally reloads
|
|
3
|
-
// every test file in a fresh environment; with this preset the files that land on a
|
|
4
|
-
// worker share its module graph. Files run in a shuffled order and the common state
|
|
5
|
-
// sinks are reset between tests, so a leak surfaces as a failure instead of hiding.
|
|
6
|
-
// The number of workers is left alone: Vitest still uses every core.
|
|
7
|
-
//
|
|
8
|
-
// Turning isolation off is a real behaviour change, so this is a named export a repo
|
|
9
|
-
// opts into, not part of `defineWebVitestConfig`. See the README section
|
|
10
|
-
// "Shared-worker Vitest preset" for the adoption snippet and the cleanup rules a test
|
|
11
|
-
// file must follow when isolation is off.
|
|
12
|
-
//
|
|
13
|
-
// Only top-level `test` fields are set (`isolate`, `sequence.shuffle`, `restoreMocks`,
|
|
14
|
-
// `unstubEnvs`, `unstubGlobals`, `setupFiles`). `poolOptions` is not used: Vitest 4
|
|
15
|
-
// removed it. `pool` and the worker count are left to the repo. The preset does not
|
|
16
|
-
// support the `vmThreads` / `vmForks` pools, where `isolate` behaves differently.
|
|
17
2
|
/** Absolute path to the setup file that resets per-test state. Added to `setupFiles`. */
|
|
18
3
|
export const SHARED_WORKER_SETUP = fileURLToPath(new URL("./vitest-shared-setup.js", import.meta.url));
|
|
19
4
|
/**
|
package/oxlint/plugin.mjs
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
// Shared oxlint JS plugin for the @vvedantb monorepos. Rule ids have no app
|
|
2
|
-
// prefix; configure them under the plugin name `vvedantb`, for example:
|
|
3
|
-
//
|
|
4
|
-
// // .oxlintrc.json
|
|
5
|
-
// {
|
|
6
|
-
// "jsPlugins": [
|
|
7
|
-
// { "name": "vvedantb", "specifier": "@vvedantb/config/oxlint/plugin.mjs" }
|
|
8
|
-
// ],
|
|
9
|
-
// "rules": {
|
|
10
|
-
// "vvedantb/no-value-block-in-try": "error",
|
|
11
|
-
// "vvedantb/no-source-text-in-tests": "error",
|
|
12
|
-
// "vvedantb/no-double-cast": "error",
|
|
13
|
-
// "vvedantb/no-json-parse": "error",
|
|
14
|
-
// "vvedantb/no-is-record": "error"
|
|
15
|
-
// }
|
|
16
|
-
// }
|
|
17
|
-
//
|
|
18
|
-
// Thirteen rules ship; see the package README for the full list.
|
|
19
|
-
// oxlint reports each as `vvedantb(<rule>)`.
|
|
20
|
-
|
|
21
1
|
import noDoubleCast from "./rules/no-double-cast.mjs";
|
|
22
2
|
import noJsonParse from "./rules/no-json-parse.mjs";
|
|
23
3
|
import noComments from "./rules/no-comments.mjs";
|
|
@@ -3,13 +3,16 @@ const message =
|
|
|
3
3
|
"Kept: lint and tool directives, license headers, doc comments on exports, and comments with an issue or RFC link.";
|
|
4
4
|
|
|
5
5
|
const directive =
|
|
6
|
-
/^\s*(?:[*/]\s*)?(?:eslint-(?:disable|enable)|oxlint-(?:disable|enable)|@ts-(?:expect-error|ignore|nocheck|check)|[a-z]+(?:-[a-z]+)*-ignore\b|@vite-ignore|@vitest-environment|webpack[A-Z]|[#@]__(?:PURE|NO_SIDE_EFFECTS)__|@refresh\b|@jsx|<reference\b|(?:istanbul|c8|v8) ignore)/;
|
|
6
|
+
/^\s*(?:[*/]\s*)?(?:eslint-(?:disable|enable)|oxlint-(?:disable|enable)|@ts-(?:expect-error|ignore|nocheck|check)|[a-z]+(?:-[a-z]+)*-ignore\b|@vite-ignore|@vitest-environment|check-[a-z]+-allow:|allow-source-read:|webpack[A-Z]|[#@]__(?:PURE|NO_SIDE_EFFECTS)__|@refresh\b|@jsx|<reference\b|(?:istanbul|c8|v8) ignore)/;
|
|
7
7
|
const license = /\b(?:license|copyright|SPDX-License-Identifier)\b/i;
|
|
8
8
|
const link = /https?:\/\//;
|
|
9
9
|
const typeAnnotation = /^\*\s*@(?:type|satisfies)\s*\{/;
|
|
10
10
|
|
|
11
11
|
function isKept(comment, text) {
|
|
12
12
|
const value = comment.value;
|
|
13
|
+
if (comment.type === "Shebang" || text.startsWith("#!", comment.range[0])) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
13
16
|
if (directive.test(value) || license.test(value) || link.test(value) || typeAnnotation.test(value)) {
|
|
14
17
|
return true;
|
|
15
18
|
}
|
|
@@ -92,7 +95,11 @@ export default {
|
|
|
92
95
|
},
|
|
93
96
|
create(context) {
|
|
94
97
|
const filename = (context.filename ?? context.getFilename?.() ?? "").replaceAll("\\", "/");
|
|
95
|
-
if (
|
|
98
|
+
if (
|
|
99
|
+
/\.d\.ts$/.test(filename) ||
|
|
100
|
+
/\/oxlint\/no-effect\.mjs$/.test(filename) ||
|
|
101
|
+
/\/\.(?:claude|agents)\//.test(filename)
|
|
102
|
+
) {
|
|
96
103
|
return {};
|
|
97
104
|
}
|
|
98
105
|
const sourceCode = context.sourceCode;
|
|
@@ -20,7 +20,6 @@ function getCallName(callee) {
|
|
|
20
20
|
callee.type === "MemberExpression" &&
|
|
21
21
|
callee.property?.type === "Identifier"
|
|
22
22
|
) {
|
|
23
|
-
// expect(...).toBe — still report on expect itself via CallExpression on expect
|
|
24
23
|
return callee.property.name;
|
|
25
24
|
}
|
|
26
25
|
return undefined;
|
|
@@ -46,7 +45,6 @@ export default {
|
|
|
46
45
|
return {
|
|
47
46
|
CallExpression(node) {
|
|
48
47
|
if (conditionalDepth === 0) return;
|
|
49
|
-
// Only the bare `expect(...)` call — not `.toBe` member calls.
|
|
50
48
|
if (node.callee?.type !== "Identifier") return;
|
|
51
49
|
if (getCallName(node.callee) !== "expect") return;
|
|
52
50
|
context.report({ node, message });
|
|
@@ -44,7 +44,6 @@ const isBlockInsideFunction = (block) => {
|
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
/** Module scope = not inside functions/methods/control-flow blocks. */
|
|
48
47
|
const isAtModuleScope = (node) => {
|
|
49
48
|
let current = node.parent;
|
|
50
49
|
while (current && current.type !== "Program") {
|
|
@@ -52,7 +51,6 @@ const isAtModuleScope = (node) => {
|
|
|
52
51
|
if (current.type === "BlockStatement" && isBlockInsideFunction(current)) {
|
|
53
52
|
return false;
|
|
54
53
|
}
|
|
55
|
-
// Chained schema methods: z.string().optional().catch(null)
|
|
56
54
|
if (
|
|
57
55
|
current.type === "MemberExpression" &&
|
|
58
56
|
current.parent?.type === "CallExpression"
|
|
@@ -65,7 +63,6 @@ const isAtModuleScope = (node) => {
|
|
|
65
63
|
return current?.type === "Program";
|
|
66
64
|
};
|
|
67
65
|
|
|
68
|
-
/** True if expression is `z.<method>(...)` or chained `z.object(...).strict()`. */
|
|
69
66
|
const isZodSchemaExpression = (node) => {
|
|
70
67
|
if (node?.type !== "CallExpression") return false;
|
|
71
68
|
const callee = node.callee;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message shown when the banned `isRecord` identifier is found anywhere. It is
|
|
3
|
-
* deliberately written as an instruction to whoever (human or agent) is editing
|
|
4
|
-
* the code: the generic `unknown`-narrowing guard is a symptom, not the fix.
|
|
5
|
-
*/
|
|
6
1
|
const message =
|
|
7
2
|
"BANNED: `isRecord`. If you are writing or using `isRecord`, an `unknown` has " +
|
|
8
3
|
"leaked somewhere it should never reach — that `unknown` is the actual bug. " +
|
|
@@ -41,9 +41,6 @@ export default {
|
|
|
41
41
|
create(context) {
|
|
42
42
|
const allowUnknown = context.options?.[0]?.allowUnknownEscapeHatch === true;
|
|
43
43
|
const message = allowUnknown ? lenientMessage : strictMessage;
|
|
44
|
-
// JSON.parse nodes that sit in a disciplined position. Enclosing nodes are
|
|
45
|
-
// visited before the inner JSON.parse (top-down), so this is populated in
|
|
46
|
-
// time for the check below.
|
|
47
44
|
const allowed = new Set();
|
|
48
45
|
const allow = (node) => {
|
|
49
46
|
if (isJsonParse(node)) allowed.add(node);
|
|
@@ -52,7 +49,6 @@ export default {
|
|
|
52
49
|
const visitors = {
|
|
53
50
|
CallExpression(node) {
|
|
54
51
|
const callee = node.callee;
|
|
55
|
-
// `schema.safeParse(JSON.parse(...))` / `schema.parse(JSON.parse(...))`
|
|
56
52
|
if (
|
|
57
53
|
callee?.type === "MemberExpression" &&
|
|
58
54
|
!isIdentifier(callee.object, "JSON") &&
|
|
@@ -69,13 +65,11 @@ export default {
|
|
|
69
65
|
};
|
|
70
66
|
|
|
71
67
|
if (allowUnknown) {
|
|
72
|
-
// `const x: unknown = JSON.parse(...)`
|
|
73
68
|
visitors.VariableDeclarator = (node) => {
|
|
74
69
|
if (isUnknownKeyword(node.id?.typeAnnotation?.typeAnnotation)) {
|
|
75
70
|
allow(node.init);
|
|
76
71
|
}
|
|
77
72
|
};
|
|
78
|
-
// `JSON.parse(...) as unknown`
|
|
79
73
|
visitors.TSAsExpression = (node) => {
|
|
80
74
|
if (isUnknownKeyword(node.typeAnnotation)) allow(node.expression);
|
|
81
75
|
};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// Flags a `description` prop on the settings layout components. A section or
|
|
2
|
-
// row shows a title only; helper text under it is extra reading for the user.
|
|
3
|
-
// Options: `{ "components": ["ProfileCard"] }` adds component names to the
|
|
4
|
-
// built-in list.
|
|
5
|
-
|
|
6
1
|
const DEFAULT_COMPONENTS = ["SettingsSection", "SettingsToggleRow", "LabeledSwitchRow"];
|
|
7
2
|
|
|
8
3
|
function elementName(name) {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message shown when a test reads a repo source file. Written as an
|
|
3
|
-
* instruction to whoever (human or agent) is editing the test.
|
|
4
|
-
*/
|
|
5
1
|
const message =
|
|
6
2
|
"BANNED: tests that read source files as text. A regex over source breaks " +
|
|
7
3
|
"on every refactor and passes on real logic bugs. Import the code and assert " +
|
|
@@ -10,9 +6,7 @@ const message =
|
|
|
10
6
|
|
|
11
7
|
const TEST_FILE =
|
|
12
8
|
/(\.(test|spec)\.[cm]?[jt]sx?$)|(\/__tests__\/)|(\/tests\/[^/]+\.[cm]?[jt]sx?$)/;
|
|
13
|
-
/** A path or file name ending in a source extension, not a bare extension. */
|
|
14
9
|
const SOURCE_PATH = /[^/.][^/]*\.(ts|tsx|mts|css|html)$/;
|
|
15
|
-
/** File reads, plus helpers that wrap them (`read`, `readSource`, `sourceOf`). */
|
|
16
10
|
const READ_CALL = /^(read|source)|Source$/;
|
|
17
11
|
|
|
18
12
|
function calleeName(call) {
|
|
@@ -24,7 +18,6 @@ function calleeName(call) {
|
|
|
24
18
|
return "";
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
/** True when the string is (part of) an argument to a file-read call. */
|
|
28
21
|
function isReadArgument(node) {
|
|
29
22
|
let child = node;
|
|
30
23
|
for (let parent = node.parent; parent; parent = parent.parent) {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { isIdentifier } from "../utils.mjs";
|
|
2
2
|
|
|
3
|
-
// NOTE: intentionally does NOT flag `"key" in x`. In this codebase `in` is the
|
|
4
|
-
// idiomatic, sanctioned way to narrow discriminated unions (`"error" in auth`),
|
|
5
|
-
// walk Errors (`"code" in err`), and refine typed SDK unions (Notion, TipTap) —
|
|
6
|
-
// the eslint `isRecord` ban explicitly prefers that over `Reflect.get` ceremony.
|
|
7
|
-
// Only `Reflect.get` (dynamic property access that defeats the type system in
|
|
8
|
-
// domain code) is flagged here.
|
|
9
3
|
const message =
|
|
10
4
|
"Do not use `Reflect.get` to read properties in domain code. Narrow a typed " +
|
|
11
5
|
"value directly, or parse external input at its boundary with a zod schema " +
|