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

react layer: better react file recognition #6952

Closed
panjan opened this issue Aug 29, 2016 · 6 comments
Closed

react layer: better react file recognition #6952

panjan opened this issue Aug 29, 2016 · 6 comments

Comments

@panjan
Copy link
Contributor

panjan commented Aug 29, 2016

Hi, react-layer recognizes react files only if you give them a correct suffix or prepend /** @jsx React.DOM */.

It would be great if we could detect react files automagically like WebStorm does. Does anyone think that would be useful/possible? I'd be happy to help out.

@TheBB
Copy link
Collaborator

TheBB commented Aug 29, 2016

You have to add regexps to magic-mode-alist. See here for how it's currently done.

Feel free to make a PR with additions.

@TheBB
Copy link
Collaborator

TheBB commented Aug 29, 2016

Note that the CAR instead of a regexp can be a predicate function. So all you need to do is write a function that detects a react file…

@panjan
Copy link
Contributor Author

panjan commented Aug 30, 2016

Thanks for the explanation. I'll look into it.

@CestDiego
Copy link
Contributor

@TheBB do you know if magic-mode-alist only checks the first line? because I have some files that import react but there is some eslint code on top or many other things that are comments as the first line, but the first non comment file is react. So is there a way to make this a thing that counts only the first non-comment-like line?

@TheBB
Copy link
Collaborator

TheBB commented Sep 1, 2016

It checks if it matches the beginning of the buffer. Doesn't have to be the first line, but if so you need a multiline regexp.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
@lebensterben lebensterben removed the stale marked as a stale issue/pr (usually by a bot) label Feb 4, 2022
@lebensterben lebensterben moved this from Answered, waiting to To close in Forum Feb 4, 2022
@lebensterben lebensterben moved this from Pending merge to To close in Mailing list Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Mailing list
  
To close
Forum
  
To close
Development

No branches or pull requests

5 participants