-
Notifications
You must be signed in to change notification settings - Fork 3
Question: Usage with vue-eslint-parser
possible?
#27
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
Comments
Hi, you're welcome! I'm not familiar with the setup for vue apps (or how generally to use "multiple custom parsers" on a project with ESLint), but I'm happy to look into how that works with Looking at the docs, it seems like maybe you could just specify this in your ESLint config:
Could you try that (after installing |
Yes, that one I tried. It results in
So I was unsure if it works with multiple parsers at all. I also tried switching both parsers, resulting in a similar message |
Ok, Here is an example Vue project that I set up: https://github.com/helixbass/vue-coffee-eslint-example The issue causing the So I can open an issue with In the meantime, using Yarn selective dependency resolutions, you can swap in a forked version of In your
and then Still it won't report ESLint errors in So to work around that you can use a forked version of
At that point it is successfully reporting ESLint errors for me both in the I saw that some Vue ESLint rules may not work correctly out-of-the-box with Coffeescript (eg It should be possible to add support for overrides for these incompatible Vue rules to this plugin (opened #29) Also I'm curious should you be able to use Coffeescript syntax inside Vue template expressions? I tried eg |
I don't think so. I've been working with Vue for a few years, and it supports CoffeeScript in |
Bam, thanks so much @helixbass! I will try to set it up as you explained, switching to yarn for now. GeoffreyBooth is right—vue only supports javascript in the template section. A weird mix I personally don't enjoy at all, but the team decided 🤷♂️ |
Ok, much of the codebase seems to work, generating a lot of useful errors to fix. I do see those two patterns:
) with this line of the source: and
) with this line of the source: This is the output of |
Those seem like CoffeeScript compiler errors. |
Interesting. In that case
Looks that way. I can look more into it and keep extending the forked But per the first part of this comment, it would seem like here also
Yup if it's the same issue as the template expressions being wrapped with
So the Coffeescript compiler would be failing to parse the expressions that are wrapped in non-Coffeescript compatible wrappers But what I'm now saying here is that 3. should instead hand off to a known JS AST parser (not the parser you specified) I guess it hasn't been an issue because the only custom parsers that people have been using ( |
Ok yup looks like those issues are all resolved by making @alappe can you try updating your
and run For me this is working in the example project, it's not choking on |
@helixbass Yes, this looks great now. Some Thank you very much for your help! |
Hey folks! I'm trying to make this work, but I'm getting confused between a lot of instructions. I modified some rules to quash some non-errors:
Now I'm getting this very curious one:
Any idea what that is? |
@joallard I'm not super familiar with vue but I'm guessing it's trying to parse your In the example Vue project that I linked above it looks like I used only So it your project has a mixture of I can probably take a deeper look at this over the weekend, but in the meantime you may want to look at #33, where we were able to use |
Thanks so much! I'm taking a break from this feature at the moment, but I'll check it out when I come back! |
The code you pasted is both valid JS and valid CoffeeScript, so it's unclear which you intended it to be and which it's getting parsed as. Since it's in a file named Could you rename the file to new Vue(
render: (h) => h App
).$mount '#app' I'm leaving out some optional parentheses and braces here so that this only parses as CoffeeScript, in case that causes an error to be thrown by something parsing this as JavaScript and therefore you get another clue to what's wrong. |
Great to see there're still so many people dedicated to Coffescript! Maybe we can also transform the custom patched version of
into 2 custom packages that pull in the original dependecies as data sources and run a script after installation that patches the 0() with [], respective the custom eslint parser, for that we can always have the lastest version of those packages automatically coffescript eslint patched. |
Thanks for following up @MentalGear! I haven't been very reactive on this because that part took a lot of energy for me to set up. I managed to get something running, but it's still very messy and with a project on top. I'll try to see if I can share the base of my project that works. |
Turns out parser:babel-eslint is only needed, as per their docs, if you use non-standard features (not present in the last released ES specs yet). Coffescript already transpiles to ES6, so we should be alright without the babel eslint parser, even if you use babel. I added this as a comment to my parser option:
|
So. I was able to re-do the steps, making a commit each step of the way. Here it is: Looks like nothing will work without:
|
Yes, that's because the package author had to use a customized version of eslint-parser to make it work. I was also confused by it, and hence, after investigation, I documented the changes made to package.json for others to easily understand within the readme file, and made a pull request. Hower, @helixbass would still have to approve it. |
Tagging PR vuejs/vue-eslint-parser#62 |
Ok ya to summarize the current status:
So then as far as moving forward, I opened vuejs/vue-eslint-parser#62 to try and get # 1 merged. And just opened vuejs/vue-cli#5581 for # 2 so we can see if that can also be merged For # 3, the next step might be to further fork
And I could correspondingly try and update the example repo to demonstrate configuration for a hybrid JS/Coffeescript project (I think there are still open questions around how to specify different ESLint configurations (eg different Coffeescript-specific rules) for JS vs Coffeescript) Beyond that, for solid Vue support we'd want to identify I think it'd be good to add a "Usage with Vue" section to the README documenting this setup + status, opened #41 (@MentalGear I think this project's README is a more important place to document this than in the example repo - that being said, I'm also not opposed to the example repo also ultimately being "self-documenting" with a useful README, just not highest priority) |
@MentalGear if I'm following, I think your mental model is incorrect here -
What was your initial use case here? Trying to get a Vue project that includes both JS and Coffeescript files working with ESLint? |
Thanks for your efforts regarding style and coffeescript!
I was very happy to see that AST support landed in a coffeescript release and wanted to see if I can integrate your plugins for prettier and eslint into our projects.
But for our vue projects, I'm running into the issue that those single file components seem to need a separate parser themselves – is there a way to combine it with your parser?
Regards
Andreas
The text was updated successfully, but these errors were encountered: