-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
--type js: include more extensions #62
Conversation
TypeScript also uses |
@Keats thanks for the suggestion. Patch updated to include .tsx |
Hmm... I'm not an especially seasoned Javascript programmer, so I could be wrong about this, but it seems weird to lump things like CoffeeScript under the Javascript type. Was that intentional? Should CoffeeScript be given its own type? Same for TypeScript and JSX? |
To me it was intentional to include coffescript (I saw there already is a separate coffescript type too). Maybe js is a bit special, but I've many times messed with js project where more than one of these extensions are used. For example right now i have a golang app, with a js frontend. The js frontend is built with vue.js so it is a mix of .js and .vue files. So when i am searching for a "javascript related" snippet, i don't want the mental burden of figuring "may the code be in a .vue component, or in a .js file?" (it's all javascript). And while coffescript might look differently, it compiles down to js and is used in projects together with other parts of js code, which might be in a .js file. It is not uncommon to find coffescript stuff in your node_modules dependencies. Regarding typescript, it is a superscript of javascript and is getting more popular as well. So this patch address my use case (searching for "js stuff" in the "js-like files") Regarding not lumping things together, I am thinking one could make it even better if it were possible to specify a type that consisted of multiple types. So we could have a "js" type, that for now could include *.js", coffescript, typescript, react and vue types. |
Also related, similar functionality in ag:
|
I am pretty torn on this issue. It feels really wrong to lump entirely separate languages into the same file type. Your use case does sound important, and I can see why you want this. I may request that you define your own type for this (which can be done conveniently with an alias until we get a config file). |
This feature suggestion may make having a custom type a little easier: #83 |
Okay, so to progress this patch, could it be accepted if we drop the coffescript stuff entirely? Or should i rather just drop it and live happy with some rg alias? Regarding #83, interesting! |
Well, the problem is that even JSX claims to be its own language. From https://jsx.github.io/:
However, from what I know about JSX, in practice, I can see how it makes sense to lump it under the I looked for information about |
But the React docs say that it's not its own language, but a syntax extension:
|
I think that's a different |
@Keats Oh. Thanks for the clarification! I think my feeling here is that we should drop TypeScript and CoffeeScript from being designated as Javascript, but keep JSX. I don't know about Vue though. Are |
Looking at files like https://github.com/ElemeFE/vue-desktop/blob/master/src/basic/alert.vue, it seems .vue is a mix of html/css and js (similar to a react component with inline css). |
Just specify |
@BurntSushi with regards to .vue files (vue components), they contain sections: one for html template, one for css, one for script (js), looks like From experience, a vue component usually has the majority of code in javascript. |
OK, I guess I'm fine with that. So I'd say to take out TypeScript and CoffeeScript, keep jsx and vue, and let's get this merged. Thank you so much for your patience and sticking with me. :-) |
No problems! Reworked the patch according to comments. I left out the following in order to stay on track for this PR, but I think this should be added to types.rs as well: ("typescript", &["*.ts", "*.tsx"]), |
Poifect. Adding TypeScript would be great. (I do kind of think the name should be |
|
Addressed ts in #84 |
--type js: include more extensions
Includes more commonly used extensions to the js type.