ant-design / ant-design/ant-design-cli
usage/lint skip JSX in .js files (parse-error: Unexpected JSX expression)
- Dominant language
- TypeScript
- Stars
- 257
- Forks
- 15
- Avg merge
- 1h 46m
- Merged PRs (30d)
- 5
Description
### Description
antd usage and antd lint fail to parse files that contain JSX but use the .js extension. Each such file is reported under skippedFiles with reason parse-error / 'Unexpected JSX expression', so usage counts and lint verdicts are silently wrong for projects following the JSX-in-.js convention (CRA, Next.js, SWC/rspack with jsx:true, eslint react/jsx-filename-extension set to ['.js','.jsx']). The same file renamed to .jsx is parsed correctly. Expected: parse .js with the JSX plugin enabled (as Babel/SWC do), or fall back to a JSX-enabled re-parse when the plain parse fails.
### Steps to Reproduce
1. Create foo.js containing: import { Button } from 'antd'; export const A = () => hi; 2. Run: antd usage . --format json 3. Run: antd lint . --only deprecated --format json 4. Rename foo.js to foo.jsx and repeat: both commands now work
### Expected Behavior
usage lists Button with 1 import from foo.js; lint analyses foo.js
### Actual Behavior
usage summary totalComponents=0; lint returns issues=[] and skippedFiles=[{file:'foo.js',reason:'parse-error',message:'Unexpected JSX expression'}]
### Environment
| Info | Value |
|------|-------|
| @ant-design/cli | 6.6.3 |
| Node | v22.20.0 |
| System | darwin 25.5.0 |
---
Generated by [@ant-design/cli](https://github.com/ant-design/ant-design-cli)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with foo.js using `antd usage . --format json` and `antd lint . --only deprecated --format json`, then compare with foo.jsx. Trace the shared parsing path for usage and lint; done means JSX in .js is analyzed, Button is counted, lint issues are reported, and foo.js is absent from skippedFiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100