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
|
export type TestId = string
|
||||||
|
|
||||||
type CssEscapeRuntime = {
|
type CSSEscapeRuntime = {
|
||||||
CSS?: {
|
CSS?: {
|
||||||
escape?: (value: string) => string
|
escape?: (value: string) => string
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ export function acpPermissionOptionTestId(kind: string): TestId {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cssEscape(value: string): string {
|
function cssEscape(value: string): string {
|
||||||
const runtime = globalThis as CssEscapeRuntime
|
const runtime = globalThis as CSSEscapeRuntime
|
||||||
const nativeEscape = runtime.CSS?.escape
|
const nativeEscape = runtime.CSS?.escape
|
||||||
if (typeof nativeEscape === 'function') {
|
if (typeof nativeEscape === 'function') {
|
||||||
return nativeEscape(value)
|
return nativeEscape(value)
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,18 @@ import { afterEach, describe, expect, test } from 'bun:test'
|
||||||
|
|
||||||
import { testIdSelector } from '@open-pencil/vue'
|
import { testIdSelector } from '@open-pencil/vue'
|
||||||
|
|
||||||
const originalCssDescriptor = Reflect.getOwnPropertyDescriptor(globalThis, 'CSS')
|
const originalCSSDescriptor = Reflect.getOwnPropertyDescriptor(globalThis, 'CSS')
|
||||||
|
|
||||||
function restoreCssGlobal() {
|
function restoreCSSGlobal() {
|
||||||
if (originalCssDescriptor) {
|
if (originalCSSDescriptor) {
|
||||||
Object.defineProperty(globalThis, 'CSS', originalCssDescriptor)
|
Object.defineProperty(globalThis, 'CSS', originalCSSDescriptor)
|
||||||
} else {
|
} else {
|
||||||
Reflect.deleteProperty(globalThis, 'CSS')
|
Reflect.deleteProperty(globalThis, 'CSS')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
restoreCssGlobal()
|
restoreCSSGlobal()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('testIdSelector', () => {
|
describe('testIdSelector', () => {
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,14 @@ import { join } from 'node:path'
|
||||||
|
|
||||||
import { publicPackageDirs } from '../packages'
|
import { publicPackageDirs } from '../packages'
|
||||||
|
|
||||||
interface PackageJson {
|
interface PackageJSON { name: string
|
||||||
name: string
|
version: string
|
||||||
version: string
|
main?: string
|
||||||
main?: string
|
types?: string
|
||||||
types?: string
|
files?: string[]
|
||||||
files?: string[]
|
bin?: Record<string, string> | string
|
||||||
bin?: Record<string, string> | string
|
exports?: unknown
|
||||||
exports?: unknown
|
publishConfig?: Record<string, unknown> }
|
||||||
publishConfig?: Record<string, unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
const errors: string[] = []
|
const errors: string[] = []
|
||||||
|
|
||||||
|
|
@ -20,11 +18,11 @@ function isDeclarationPath(value: string): boolean {
|
||||||
return /\.d\.[cm]?ts$/.test(value)
|
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'))
|
return JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootPackage = readPackageJson('.')
|
const rootPackage = readPackageJSON('.')
|
||||||
const expectedVersion = rootPackage.version
|
const expectedVersion = rootPackage.version
|
||||||
|
|
||||||
function checkRuntimePath(packageName: string, field: string, value: string): void {
|
function checkRuntimePath(packageName: string, field: string, value: string): void {
|
||||||
|
|
@ -96,7 +94,7 @@ function walkExports(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const packageDir of publicPackageDirs) {
|
for (const packageDir of publicPackageDirs) {
|
||||||
const pkg = readPackageJson(packageDir)
|
const pkg = readPackageJSON(packageDir)
|
||||||
|
|
||||||
if (pkg.version !== expectedVersion) {
|
if (pkg.version !== expectedVersion) {
|
||||||
errors.push(`${pkg.name}: version ${pkg.version} must match root 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)
|
run([tsgoBin, '--noEmit', '-p', 'tsconfig.package-smoke.json'], cwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PackageJson {
|
interface PackageJSON { name: string
|
||||||
name: string
|
types?: string
|
||||||
types?: string
|
exports?: unknown }
|
||||||
exports?: unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||||
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
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'))
|
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)}`
|
return `${packageName}/${exportKey.slice(2)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectPublicImportSpecifiers(packageJSON: PackageJson): string[] {
|
function collectPublicImportSpecifiers(packageJSON: PackageJSON): string[] {
|
||||||
const { exports } = packageJSON
|
const { exports } = packageJSON
|
||||||
if (!exports) return []
|
if (!exports) return []
|
||||||
if (typeof exports === 'string') return [packageJSON.name]
|
if (typeof exports === 'string') return [packageJSON.name]
|
||||||
|
|
@ -180,7 +178,7 @@ try {
|
||||||
const tarballs: string[] = []
|
const tarballs: string[] = []
|
||||||
const publicImportSpecifiers = new Set<string>()
|
const publicImportSpecifiers = new Set<string>()
|
||||||
for (const packageDir of publicPackageDirs) {
|
for (const packageDir of publicPackageDirs) {
|
||||||
const packageJSON = readPackageJson(packageDir)
|
const packageJSON = readPackageJSON(packageDir)
|
||||||
for (const specifier of collectPublicImportSpecifiers(packageJSON)) {
|
for (const specifier of collectPublicImportSpecifiers(packageJSON)) {
|
||||||
publicImportSpecifiers.add(specifier)
|
publicImportSpecifiers.add(specifier)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue