Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

kylekthompson
Copy link
Contributor

@kylekthompson kylekthompson commented Jan 31, 2018

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

Fixes the highlighting when re-exporting a default export:

export {
  default as alias,
} from 'module';

screen shot 2018-01-31 at 12 57 07 pm

Alternate Designs

Find an alternate regex.

Benefits

The export will be properly tokenized.

Possible Drawbacks

There could be a performance hit with the new regex.

Applicable Issues

I actually did find one! #271

@kylekthompson kylekthompson force-pushed the fix-multiline-default-reexport branch 2 times, most recently from 7490dad to ac4000c Compare January 31, 2018 18:38
@kylekthompson kylekthompson force-pushed the fix-multiline-default-reexport branch from ac4000c to 9002aad Compare March 3, 2018 01:58
@kylekthompson kylekthompson changed the title **WIP** Fix multiline re-export of the default export Fix multiline re-export of the default export Mar 3, 2018
@kylekthompson kylekthompson force-pushed the fix-multiline-default-reexport branch from 8c19229 to 9002aad Compare March 3, 2018 02:25
@kylekthompson
Copy link
Contributor Author

kylekthompson commented Mar 3, 2018

@50Wliu sorry it's taken me so long to get back to this!

So, I've tracked down the issue with this; the problem is that the multiline re-export is falling into the from-less matches here.

My proposed change is to search for from across multiple lines, though I'm running into some issues with xregexp. Are we not able to use the s flag?

@MaximSokolov
Copy link
Contributor

My proposed change is to search for from across multiple lines

This is not possible due to limitation of the regex engine. It can be fixed by removing this pattern and changing invalid.illegal -> variable.language.default here, so default always would be legal inside export statement

@kylekthompson
Copy link
Contributor Author

@MaximSokolov I had considered doing that, but it breaks this case:

export { default as alias };

Maybe it's okay that we don't highlight this as invalid?

@MaximSokolov
Copy link
Contributor

Yeah, it's fine. Linting is not a priority for this package

@kylekthompson kylekthompson force-pushed the fix-multiline-default-reexport branch from 46f6afc to 334a3a8 Compare March 3, 2018 16:14
@kylekthompson
Copy link
Contributor Author

✨ updated the fix. Thanks for the quick feedback on this!

@winstliu winstliu merged commit e4bc190 into atom:master Mar 5, 2018
@kylekthompson kylekthompson deleted the fix-multiline-default-reexport branch March 5, 2018 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants