Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.1] - 2026-11-03

### Fixed

- `scan` comment masking ran in quadratic time on some hostile files: 400 KB of unclosed `/*` or `<!--` lines, or a long CSS line full of `//`, took 10 to 60 s. Every case now finishes in milliseconds.
- `scan` skips one-line regex literals such as `/[//]/` (including after `return`, where `/[/*]/` used to hide code up to the next `*/`) and unquoted CSS `url(http://…)` as text instead of reading `//` inside them as a comment, and masks comments inside template `${…}` expressions.
- `scan` reads versions from npm 6 (`lockfileVersion` 1) lockfiles, and no longer counts a check that a project config flag rules out (`cacheComponents`) as version-unknown.
- tailwind `tw4-leading-important-modifier` finds `!utility` after doubly nested calls inside class helpers, such as `cn(getBase(foo(bar)), '!flex')`.
- The MCP package smoke test packs into a temp directory, so it no longer deletes a tarball already in `mcp/`.
- README: `scan` reads tracked and untracked, non-ignored files; with no install or lockfile entry, a range that pins one major decides the gate alone.
- msw: MSW 3 needs Node.js 22.12+ in the troubleshooting table; the `.nvmrc` example uses `lts/jod`; `moduleResolution` `node16`/`nodenext` must be paired with the matching `module` value.
- playwright: the CI artifact glob includes `.webp` screenshots; full cross-browser runs pass `--project="*"`, so projects with `default: false` run too.
- tailwind `resp-custom-breakpoints`: canonicalization maps to names in the active theme, so `max-[64rem]` matches `max-lg` only with the default breakpoints.

## [3.0.0] - 2026-11-03

### Breaking
Expand Down Expand Up @@ -237,7 +251,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Priority-based skill organization (CRITICAL, HIGH, MEDIUM, LOW)
- Category-based rule grouping for easy navigation

[Unreleased]: https://github.com/PyModel/react-frontend-skills/compare/v3.0.0...HEAD
[Unreleased]: https://github.com/PyModel/react-frontend-skills/compare/v3.0.1...HEAD
[3.0.1]: https://github.com/PyModel/react-frontend-skills/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/PyModel/react-frontend-skills/compare/v2.3.0...v3.0.0
[2.3.0]: https://github.com/PyModel/react-frontend-skills/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/PyModel/react-frontend-skills/compare/v2.1.0...v2.2.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ npx -y @pymodel/react-frontend-skills scan # deprecated/removed API usage
npx -y @pymodel/react-frontend-skills scan --skill zod --json
```

`scan` runs its 35 checks only for packages declared in `package.json`, and only when both the declared range and the installed version are at or above the major where the old API went away (`--all` overrides every gate). Open ranges such as `>=18` defer to the installed version; without `node_modules`, the version comes from `package-lock.json`. Checks whose version stays unknown (a `latest`, `workspace:` or `catalog:` range with no install) are skipped and counted separately. Inside a git work tree it scans what git tracks, so `.gitignore`d copies, builds and dot-directories are skipped; comments never count. It exits `1` when it finds hits. Each hit names a rule ID, and the fix is in that skill's `references/<rule>.md` (or `rules/<rule>.md`).
`scan` runs its 35 checks only for packages declared in `package.json`, and only when the project is on or above the major where the old API went away (`--all` overrides every gate). A range that pins one major (`^19`, `19.x`) and the installed version must both meet that major; with no install or lockfile entry, the pinned range decides alone. Open ranges such as `>=18` defer to the installed version; without `node_modules`, the version comes from `package-lock.json`. Checks whose version stays unknown (a `latest`, `workspace:` or `catalog:` range with no install) are skipped and counted separately. Inside a git work tree it scans tracked files plus untracked files that `.gitignore` does not exclude, so ignored copies, builds and dot-directories are skipped; comments never count. It exits `1` when it finds hits. Each hit names a rule ID, and the fix is in that skill's `references/<rule>.md` (or `rules/<rule>.md`).

`detect` reports `range-mismatch` when the resolved install is a different major than `package.json` declares (for example, a hoisted copy from a parent directory).

Expand Down
2 changes: 1 addition & 1 deletion bin/checks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const CHECKS = [
files: MARKUP,
// Second branch: class helpers. Whole string literals are consumed as units, so the
// captured quote always opens a string and `!open && "x"` outside a string never matches.
pattern: /\bclass(?:Name)?\s*=\s*(?:\{[^}"'`]*)?["'`](?:[^"'`]*\s)?!-?[a-z][\w:-]*|\b(?:cn|clsx|cva|twMerge|twJoin|classNames|classnames)\((?:[^()"'`]|\([^()]*\)|"[^"\n]*"|'[^'\n]*'|`[^`]*`)*?(["'`])(?:(?:(?!\1)[^\n])*?\s)?!-?[a-z][\w:-]*/,
pattern: /\bclass(?:Name)?\s*=\s*(?:\{[^}"'`]*)?["'`](?:[^"'`]*\s)?!-?[a-z][\w:-]*|\b(?:cn|clsx|cva|twMerge|twJoin|classNames|classnames)\((?:[^()"'`]|\((?:[^()]|\([^()]*\))*\)|"[^"\n]*"|'[^'\n]*'|`[^`]*`)*?(["'`])(?:(?:(?!\1)[^\n])*?\s)?!-?[a-z][\w:-]*/,
message: "Tailwind v4 moves the important modifier to the end: !flex -> flex!, !hover:bg-x -> hover:bg-x!.",
},
{
Expand Down
107 changes: 97 additions & 10 deletions bin/react-frontend-skills.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const MAX_FILE_BYTES = 512 * 1024
const LINE_COMMENT_FILES = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|html|scss|sass|less|json)$/
const BLOCK_COMMENT_FILES = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|html|css|scss|sass|less|pcss|postcss|json)$/
const HTML_COMMENT_FILES = /\.(?:html|vue|svelte|astro|mdx)$/
const SCRIPT_FILES = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|html|mdx)$/
// Files that can hold CSS, so an unquoted url(/path) is skipped as text.
const URL_FILES = /\.(?:css|scss|sass|less|pcss|postcss|html|vue|svelte|astro)$/
// A `/` after one of these (or at the start of the text) opens a regex literal, not a division.
// `}` and `)` are left out: JSX `{b} />`, `{a}/{b}` and Vue `{{a}}/{{b}}` put a slash there.
const REGEX_PRECEDERS = new Set(['(', ',', '=', ':', '[', '!', '&', '|', '?', '{', ';', '+', '-', '*', '%', '~', '^'])
const KEYWORD_BEFORE_REGEX = /(?:^|[^\w$.])(?:return|typeof|case|void|yield|await|delete|throw|in|of|else|do)\s*$/
const MAX_REPORTED_HITS = 200
// Every installed skill's name + description rides in the agent's system prompt on every
// message, so the budgets cap the whole pack, not each skill (tokens ≈ chars / 4).
Expand Down Expand Up @@ -112,7 +119,9 @@ function lockedVersion(projectDir, name) {
const covers = nested === '' || lock?.packages?.[nested] !== undefined
const version = covers
? (lock?.packages?.[`${nested ? `${nested}/` : ''}node_modules/${name}`]?.version ??
lock?.packages?.[`node_modules/${name}`]?.version)
lock?.packages?.[`node_modules/${name}`]?.version ??
// lockfileVersion 1 (npm 6) has no `packages`, only a root `dependencies` tree.
(nested === '' ? lock?.dependencies?.[name]?.version : undefined))
: undefined
if (version) return version
if (dirname(dir) === dir) return undefined
Expand Down Expand Up @@ -219,29 +228,69 @@ function* projectFiles(dir, root) {
// Blank out comments, keeping offsets and newlines, so migration notes that name an old API
// are not reported. Quotes are tracked so "https://…" survives; '…' and "…" end at a newline,
// so a stray apostrophe in JSX text affects only its own line.
// An unclosed /* or <!-- (a JS syntax error, or a regex literal like /[/*]/) masks only the
// rest of its line, so a stray opener can never hide the remainder of the file.
// ponytail: regex literals are not parsed; a `//` or `/*` inside one hides the rest of its line.
// An unclosed /* or <!-- (a JS syntax error) masks only the rest of its line, so a stray
// opener can never hide the remainder of the file. Template `${…}` expressions are code, and
// one-line regex literals and unquoted CSS url(…) are skipped as text.
// ponytail: a regex that spans an escaped newline or follows `)` reads as division.
export function maskComments(text, file) {
const lineComments = LINE_COMMENT_FILES.test(file)
const blockComments = BLOCK_COMMENT_FILES.test(file)
const htmlComments = HTML_COMMENT_FILES.test(file)
// Searches run at rising offsets, so each needle caches its last hit: the first match after
// an earlier offset is still the first after any later offset up to it. Without this, a long
// line or many unclosed openers rescan the rest of the text per character (quadratic).
const found = new Map()
const find = (needle, from) => {
const last = found.get(needle)
if (last && from >= last.from && (last.at === -1 || from <= last.at)) return last.at
const at = text.indexOf(needle, from)
found.set(needle, { from, at })
return at
}
const lineEnd = (from) => {
const newline = text.indexOf('\n', from)
const newline = find('\n', from)
return newline === -1 ? text.length : newline
}
const closeAfter = (closer, from) => {
const close = text.indexOf(closer, from)
const close = find(closer, from)
return close === -1 ? lineEnd(from) : close + closer.length
}
const atLineStart = (at) => /^[ \t]*$/.test(text.slice(text.lastIndexOf('\n', at - 1) + 1, at))
// Offset before which a failed regex or url( lookup already showed there is none on the line.
let plainUntil = -1
const atLineStart = (at) => {
while (at > 0 && (text[at - 1] === ' ' || text[at - 1] === '\t')) at--
return at === 0 || text[at - 1] === '\n'
}
const script = SCRIPT_FILES.test(file)
const urls = URL_FILES.test(file)
// End of a one-line regex literal opened at `from`, or -1 when the line ends first or the
// closing slash would start a `//` or `/*` comment (then it was never a regex).
const regexEnd = (from) => {
let inClass = false
for (let at = from + 1; at < text.length && text[at] !== '\n'; at++) {
if (text[at] === '\\') at++
else if (text[at] === '[') inClass = true
else if (text[at] === ']') inClass = false
else if (text[at] === '/' && !inClass) return text[at + 1] === '/' || text[at + 1] === '*' ? -1 : at
}
return -1
}
const out = text.split('')
let quote
let depth = 0
// Brace depth at each open template `${`; its matching `}` resumes the template text.
const templates = []
let previous = ''
for (let index = 0; index < text.length; index++) {
const char = text[index]
if (quote) {
if (char === '\\') index++
else if (char === quote || (char === '\n' && quote !== '`')) quote = undefined
else if (quote === '`' && char === '$' && text[index + 1] === '{') {
templates.push(depth)
quote = undefined
previous = '{'
index++
} else if (char === quote || (char === '\n' && quote !== '`')) quote = undefined
continue
}
if (char === '\\') {
Expand All @@ -250,14 +299,50 @@ export function maskComments(text, file) {
}
if (char === '"' || char === "'" || char === '`') {
quote = char
previous = char
continue
}
if (char === '{') depth++
else if (char === '}') {
if (templates.length && templates.at(-1) === depth) {
templates.pop()
quote = '`'
previous = '`'
continue
}
depth--
}
if (
index >= plainUntil && script && char === '/' && text[index + 1] !== '/' && text[index + 1] !== '*' &&
(previous === '' || REGEX_PRECEDERS.has(previous) || KEYWORD_BEFORE_REGEX.test(text.slice(Math.max(0, index - 12), index)))
) {
const close = regexEnd(index)
if (close !== -1) {
index = close
previous = '/'
continue
}
plainUntil = lineEnd(index)
}
if (index >= plainUntil && urls && !/[\w-]/.test(text[index - 1] ?? '') && /^url\([ \t]*[^'"\s)]/.test(text.slice(index, index + 6))) {
const end = lineEnd(index)
const close = find(')', index)
if (close !== -1 && close < end) {
index = close
previous = ')'
continue
}
plainUntil = end
}
let end
if (char === '/' && text[index + 1] === '*' && (blockComments || atLineStart(index))) {
end = blockComments ? closeAfter('*/', index + 2) : lineEnd(index)
} else if (char === '/' && text[index + 1] === '/' && (lineComments || atLineStart(index))) end = lineEnd(index)
else if (htmlComments && text.startsWith('<!--', index)) end = closeAfter('-->', index + 4)
else continue
else {
if (!/\s/.test(char)) previous = char
continue
}
for (let at = index; at < end; at++) if (out[at] !== '\n') out[at] = ' '
index = end - 1
}
Expand Down Expand Up @@ -285,6 +370,8 @@ function selectChecks(root, { skill, all }) {
if (all) return true
const found = resolvePackage(root, manifest, check.packages)
if (!found) return false
// A check the project config rules out is neither skipped nor unknown: it never applies.
if (check.onlyIf && !projectFileMatches(check.onlyIf, root, rootFiles)) return false
if (check.since !== undefined && found.major === undefined) {
unknown++
return false
Expand All @@ -293,7 +380,7 @@ function selectChecks(root, { skill, all }) {
skipped++
return false
}
return !check.onlyIf || projectFileMatches(check.onlyIf, root, rootFiles)
return true
})
return { checks, skipped, unknown }
}
Expand Down
4 changes: 2 additions & 2 deletions mcp/package-lock.json

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

2 changes: 1 addition & 1 deletion mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pymodel/react-frontend-skills-mcp",
"version": "2.0.0",
"version": "2.0.1",
"description": "Read-only MCP server for 18 production-grade React frontend agent skills.",
"type": "module",
"license": "MIT",
Expand Down
15 changes: 4 additions & 11 deletions mcp/scripts/package-smoke.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execFile } from 'node:child_process'
import { mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'
import { mkdtemp, rm, stat, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { dirname, resolve } from 'node:path'
import { promisify } from 'node:util'
Expand Down Expand Up @@ -30,20 +30,16 @@ async function pathExists(path) {
async function main() {
const source = await loadCatalog({ skillsDir: resolve(packageRoot, '..', 'skills') })
const installationRoot = await mkdtemp(joinTempPath())
const { name, version } = JSON.parse(await readFile(resolve(packageRoot, 'package.json'), 'utf8'))
// npm pack's deterministic file name; removed on exit only if this run created it.
const expectedTarball = resolve(packageRoot, `${name.replace(/^@/, '').replace('/', '-')}-${version}.tgz`)
const preexisting = await pathExists(expectedTarball)
let tarballPath
let client

try {
const { stdout } = await npm(['pack', '--json', '--silent'], { cwd: packageRoot })
// Pack into the temp dir, so a tarball already sitting in the package root is never touched.
const { stdout } = await npm(['pack', '--json', '--silent', '--pack-destination', installationRoot], { cwd: packageRoot })
// npm 10/11 print an array of results; npm 12 prints an object keyed by package name.
const packResult = JSON.parse(stdout)
const [packed] = Array.isArray(packResult) ? packResult : Object.values(packResult)
if (!packed?.filename) throw new Error(`Unexpected npm pack --json output: ${stdout.slice(0, 200)}`)
tarballPath = resolve(packageRoot, packed.filename)
const tarballPath = resolve(installationRoot, packed.filename)
const dotfiles = packed.files.map((file) => file.path).filter((path) => /(^|\/)\./.test(path))
if (dotfiles.length) throw new Error(`Tarball ships dotfiles: ${dotfiles.join(', ')}`)

Expand Down Expand Up @@ -92,9 +88,6 @@ async function main() {
process.stdout.write('installed tarball MCP smoke: PASS\n')
} finally {
await client?.close().catch(() => undefined)
// Also covers a pack whose output could not be parsed; never deletes a tarball that was there before.
if (tarballPath) await rm(tarballPath, { force: true })
if (!preexisting) await rm(expectedTarball, { force: true })
await rm(installationRoot, { recursive: true, force: true })
await rm(generatedData, { recursive: true, force: true })
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pymodel/react-frontend-skills",
"version": "3.0.0",
"version": "3.0.1",
"description": "18 production-grade AI agent skills for React 19, Next.js 16, TypeScript 7, testing, data, UI, and frontend architecture.",
"license": "MIT",
"author": "Mohamed Elkholy (PyModel)",
Expand Down
2 changes: 1 addition & 1 deletion skills/msw/references/debug-common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const handlers = [
## Common Issues Quick Reference

**Issue: "fetch is not defined"**
- Fix: Upgrade Node.js to 22+ for MSW 3 (18+ for MSW 2)
- Fix: Upgrade Node.js to 22.12+ for MSW 3 (18+ for MSW 2)

**Issue: Body parsing hangs with fake timers**
```typescript
Expand Down
4 changes: 2 additions & 2 deletions skills/msw/references/setup-node-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ $ npm install msw@3
```

```yaml
# .nvmrc
22
# .nvmrc (Node 22 LTS, latest release)
lts/jod
```

```yaml
Expand Down
2 changes: 1 addition & 1 deletion skills/msw/references/setup-typescript-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags: setup, typescript, configuration, types, compiler

## Configure TypeScript for MSW v3

MSW v3 requires TypeScript 5.9+ (optional peer dependency `typescript: >=5.9.x`) for proper type inference. Its subpath entrypoints (`msw/http`, `msw/graphql`, …) resolve only through package `exports`, so `moduleResolution` must be `bundler`, `node16` or `nodenext`.
MSW v3 requires TypeScript 5.9+ (optional peer dependency `typescript: >=5.9.x`) for proper type inference. Its subpath entrypoints (`msw/http`, `msw/graphql`, …) resolve only through package `exports`, so `moduleResolution` must be `bundler` (with `module: "ESNext"` or `"preserve"`), or `node16`/`nodenext` with the matching `module` value (`node16` with `node16`, `nodenext` with `nodenext`).

On MSW 2.x: TypeScript 4.8+ and `import { http, HttpResponse } from 'msw'`.

Expand Down
1 change: 1 addition & 0 deletions skills/playwright/references/debug-screenshots-videos.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default defineConfig({
name: test-artifacts
path: |
test-results/**/*.png
test-results/**/*.webp
test-results/**/*.webm
retention-days: 7
```
Expand Down
6 changes: 3 additions & 3 deletions skills/playwright/references/perf-browser-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx playwright test
- run: npx playwright test --project="*"
env:
FULL_TEST: true
```
Expand Down Expand Up @@ -109,8 +109,8 @@ This replaces the `isMainBranch ? [...] : []` project array above when the only
# Quick test on Chromium only
npx playwright test --project=chromium

# Full cross-browser test
npx playwright test
# Full cross-browser test (every project, including default: false ones)
npx playwright test --project="*"

# Test specific browser
npx playwright test --project=firefox
Expand Down
2 changes: 1 addition & 1 deletion skills/tailwind/references/resp-custom-breakpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Add custom breakpoints using the `@theme` directive. This is useful for project-
}
```

**Canonicalization (Tailwind 4.3.4+):** `tailwindcss canonicalize` now converts arbitrary breakpoint and container-query variants to their named equivalents (for example `max-[64rem]:flex` becomes `max-lg:flex`), so arbitrary values that match a theme breakpoint should be written by name.
**Canonicalization (Tailwind 4.3.4+):** `tailwindcss canonicalize` now converts arbitrary breakpoint and container-query variants to their named equivalents in the active theme (with the default theme, `max-[64rem]:flex` becomes `max-lg:flex`; with `--breakpoint-lg: 992px` above, the two are not equivalent), so arbitrary values that match a theme breakpoint should be written by name.

**Benefits:**
- Consistent breakpoint values across codebase
Expand Down
Loading
Loading