Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ClassParser incorrectly end group with jsx functional component content #660

Merged
merged 2 commits into from Jan 17, 2022

Conversation

lianghx-319
Copy link
Contributor

@lianghx-319 lianghx-319 commented Jan 14, 2022

Before

image

it('parse function with parameter deconstruction', () => {
    const badClasses = 'function ComponentA({ name }: Props) { return div className= grid }';
    const goodClasses = '{ return div className= grid }';
    const badResult = new ClassParser(badClasses, ':', []).parse();
    const goodResult = new ClassParser(goodClasses, ':', []).parse();

    const findGrid = (els: any[]) => els.find(item => item.raw === 'grid');
    expect(findGrid(badResult)).toBeTruthy();
    expect(findGrid(goodResult)).toBeTruthy();
  });

Expected

Both of badClasses and goodClasses should return a element.raw === 'grid'.

After

image

it('parse function with parameter deconstruction', () => {
    const classes = 'function ComponentA({ name } Props) { return div className= grid }';
    const result = new ClassParser(classes, ':', []).parse();

    const findGrid = (els: any[]) => els.find(item => item.raw === 'grid');
    expect(findGrid(result)).toBeTruthy();
    expect(result).toMatchSnapshot('jsx function component');
  });

@lianghx-319
Copy link
Contributor Author

I found that while prcocessing .tsx file, contains function with parameter deconstructor, will mistake ) after function declare as end group, then miss detect the reset chars which contains the meaningful className

@lianghx-319 lianghx-319 changed the title Want help: bad case while use windicss cli with fuzzy fix: bad case while use windicss cli with fuzzy Jan 14, 2022
@lianghx-319 lianghx-319 changed the title fix: bad case while use windicss cli with fuzzy fix: ClassParser incorrectly end group with jsx functional component content Jan 14, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #660 (a3ef3e0) into main (0a0f456) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #660   +/-   ##
=======================================
  Coverage   88.16%   88.17%           
=======================================
  Files          57       57           
  Lines        4860     4863    +3     
  Branches     1034     1034           
=======================================
+ Hits         4285     4288    +3     
  Misses        311      311           
  Partials      264      264           
Impacted Files Coverage Δ
src/utils/parser/class.ts 97.11% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a0f456...a3ef3e0. Read the comment docs.

@antfu antfu merged commit 0be1b2c into windicss:main Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants