chore: align adapted checks with current conventions
- Preserve uppercase acronym casing in package tooling and CSS helpers - Keep selector escaping without restoring removed test ID prop APIs Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
This commit is contained in:
parent
15ea98d8fb
commit
2c064c5a79
|
|
@ -1,6 +1,6 @@
|
|||
export type TestId = string
|
||||
|
||||
type CssEscapeRuntime = {
|
||||
type CSSEscapeRuntime = {
|
||||
CSS?: {
|
||||
escape?: (value: string) => string
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ export function acpPermissionOptionTestId(kind: string): TestId {
|
|||
}
|
||||
|
||||
function cssEscape(value: string): string {
|
||||
const runtime = globalThis as CssEscapeRuntime
|
||||
const runtime = globalThis as CSSEscapeRuntime
|
||||
const nativeEscape = runtime.CSS?.escape
|
||||
if (typeof nativeEscape === 'function') {
|
||||
return nativeEscape(value)
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@ import { afterEach, describe, expect, test } from 'bun:test'
|
|||
|
||||
import { testIdSelector } from '@open-pencil/vue'
|
||||
|
||||
const originalCssDescriptor = Reflect.getOwnPropertyDescriptor(globalThis, 'CSS')
|
||||
const originalCSSDescriptor = Reflect.getOwnPropertyDescriptor(globalThis, 'CSS')
|
||||
|
||||
function restoreCssGlobal() {
|
||||
if (originalCssDescriptor) {
|
||||
Object.defineProperty(globalThis, 'CSS', originalCssDescriptor)
|
||||
function restoreCSSGlobal() {
|
||||
if (originalCSSDescriptor) {
|
||||
Object.defineProperty(globalThis, 'CSS', originalCSSDescriptor)
|
||||
} else {
|
||||
Reflect.deleteProperty(globalThis, 'CSS')
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
restoreCssGlobal()
|
||||
restoreCSSGlobal()
|
||||
})
|
||||
|
||||
describe('testIdSelector', () => {
|
||||
|
|
|
|||
|
|
@ -3,16 +3,14 @@ import { join } from 'node:path'
|
|||
|
||||
import { publicPackageDirs } from '../packages'
|
||||
|
||||
interface PackageJson {
|
||||
name: string
|
||||
version: string
|
||||
main?: string
|
||||
types?: string
|
||||
files?: string[]
|
||||
bin?: Record<string, string> | string
|
||||
exports?: unknown
|
||||
publishConfig?: Record<string, unknown>
|
||||
}
|
||||
interface PackageJSON { name: string
|
||||
version: string
|
||||
main?: string
|
||||
types?: string
|
||||
files?: string[]
|
||||
bin?: Record<string, string> | string
|
||||
exports?: unknown
|
||||
publishConfig?: Record<string, unknown> }
|
||||
|
||||
const errors: string[] = []
|
||||
|
||||
|
|
@ -20,11 +18,11 @@ function isDeclarationPath(value: string): boolean {
|
|||
return /\.d\.[cm]?ts$/.test(value)
|
||||
}
|
||||
|
||||
function readPackageJson(packageDir: string): PackageJson {
|
||||
function readPackageJSON(packageDir: string): PackageJSON {
|
||||
return JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'))
|
||||
}
|
||||
|
||||
const rootPackage = readPackageJson('.')
|
||||
const rootPackage = readPackageJSON('.')
|
||||
const expectedVersion = rootPackage.version
|
||||
|
||||
function checkRuntimePath(packageName: string, field: string, value: string): void {
|
||||
|
|
@ -96,7 +94,7 @@ function walkExports(
|
|||
}
|
||||
|
||||
for (const packageDir of publicPackageDirs) {
|
||||
const pkg = readPackageJson(packageDir)
|
||||
const pkg = readPackageJSON(packageDir)
|
||||
|
||||
if (pkg.version !== expectedVersion) {
|
||||
errors.push(`${pkg.name}: version ${pkg.version} must match root version ${expectedVersion}`)
|
||||
|
|
|
|||
|
|
@ -110,17 +110,15 @@ function checkTypeConsumer(cwd: string): void {
|
|||
run([tsgoBin, '--noEmit', '-p', 'tsconfig.package-smoke.json'], cwd)
|
||||
}
|
||||
|
||||
interface PackageJson {
|
||||
name: string
|
||||
types?: string
|
||||
exports?: unknown
|
||||
}
|
||||
interface PackageJSON { name: string
|
||||
types?: string
|
||||
exports?: unknown }
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function readPackageJson(packageDir: string): PackageJson {
|
||||
function readPackageJSON(packageDir: string): PackageJSON {
|
||||
return JSON.parse(readFileSync(join(rootDir, packageDir, 'package.json'), 'utf8'))
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +150,7 @@ function exportKeyToSpecifier(packageName: string, exportKey: string): string |
|
|||
return `${packageName}/${exportKey.slice(2)}`
|
||||
}
|
||||
|
||||
function collectPublicImportSpecifiers(packageJSON: PackageJson): string[] {
|
||||
function collectPublicImportSpecifiers(packageJSON: PackageJSON): string[] {
|
||||
const { exports } = packageJSON
|
||||
if (!exports) return []
|
||||
if (typeof exports === 'string') return [packageJSON.name]
|
||||
|
|
@ -180,7 +178,7 @@ try {
|
|||
const tarballs: string[] = []
|
||||
const publicImportSpecifiers = new Set<string>()
|
||||
for (const packageDir of publicPackageDirs) {
|
||||
const packageJSON = readPackageJson(packageDir)
|
||||
const packageJSON = readPackageJSON(packageDir)
|
||||
for (const specifier of collectPublicImportSpecifiers(packageJSON)) {
|
||||
publicImportSpecifiers.add(specifier)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue