-
Notifications
You must be signed in to change notification settings - Fork 36
Lint grammar files "JavaScript for Automation (JXA)" #310
Comments
Are all "JavaScript for Automation (JXA)" files perfectly valid JS? |
Yes. They're referred to as "JavaScript for Automation" (aka JXA) because Apple makes certain OSA (Open Script Architecture) libraries available to them, and executes them in an environment that allows for access of OS functions, etc. They can be identified by the fact that they have the language "language-javascript-jxa" (https://atom.io/packages/language-javascript-jxa https://atom.io/packages/language-javascript-jxa) specified.
|
Cool, then it should be as simple as adding You'll want to add a spec testing that it works for those files, see the CI files in linter-stylelint for how to pre-install the language file, and remember to activate the language in the relevant section of the spec file. |
OK, that's cool, except I've never done any of that before. Not sure what a "PR" is, although I might assume the "R" stands for request. Not sure how to do the rest of the stuff, either. With that said, I'm a developer, so I can learn just about anything. Unfortunately, I've spent my (long) professional career on the Windows side, so even though I'm all about the Mac now, I'm fighting an uphill battle with all the things I don't know. So if you want to point me to some docs to learn how to do all this, I'd be happy to learn. Just be aware that I may be a pest with stupid questions until I get it figured out. It's OK with me if it's OK with you, but you've been warned. :)
|
"PR" = "Pull Request", or how you say "I have these changes that I would like to make, will you accept them?" to a project. I can take care of this at some point if you don't want to go through the trouble, but on the other hand if you want a learning experience I'd be happy to help you through the process, it's up to you 😉. |
I'd love to learn the process. I've just started working with GitHub, and I'm getting a crash course in Atom (I love it), so this is the next logical step. What steps do I follow for a PR? I clicked on the button for creating a new pull request, but I wasn't sure what it was asking, so I stopped.
|
First you will want to fork this repository to your account (button at the top right of the page). Then create a new branch for the work you will be doing. You can do this in the web UI, but as you will need something to manage the code on your computer anyway, you should probably just do it there. If you are just starting I would recommend installing GitHub Desktop as it works well enough for beginner users. When creating your branch give it a descriptive, but short, name. Something like "add-jxa-support" in this case. Your client should automatically switch you to that branch when you create it. Next you will need to make the required changes. Like I said before you need to add the "scope" (how Atom determines what a file actually is) for JXA files to the list of scopes this linter plugin claims it supports. You would want to add that right here. Next create a "jxa" folder in the Now that you have the support added there, and the files you will be testing added, you need to tell it how to test that everything is working. Start this by storing the path to those files at the top of the waitsForPromise(() => atom.packages.activatePackage('language-javascript-jxa')); To tell Atom it should load that language file for this section of the specs. Then modify the "verifies the first message" block to match the message from your "bad" file, changing the expected message, and the range. You can then run the spec by running View -> Developer -> Run Package Spec from within Atom while editing the code, or by running Once you have it passing locally you will need to ensure the CI environment is setup to properly test it is working in all environments. Start by ensuring the extra language file is installed:
env:
global:
- APM_TEST_PACKAGES="language-javascript-jxa"
matrix:
- ATOM_CHANNEL=stable
- ATOM_CHANNEL=beta
environment:
APM_TEST_PACKAGES: language-javascript-jxa
matrix:
- ATOM_CHANNEL: stable
- ATOM_CHANNEL: beta
apm install language-javascript-jxa At this point you should be done with the required changes, so commit everything with a descriptive commit message, and push your changes up to your branch. I think the GitHub Desktop client actually lets you start a PR directly from there, otherwise go back to the web interface and start a PR with your branch you created as the "source" and the |
Thanks. I'll get to this this afternoon (i.e. in a few hours). I'm reasonably familiar with Git and GutHub for basic version control stuff, so that part should be easy. I'll let you know how the rest goes. Thanks! |
Well, you've just made a huge mistake. :) I've been looking for a testing suite, and now you've inadvertently led me to Jasmine. I can't resist the rabbit trail, as I desperately needed something like this. So it might be a day or two before I'm back from this trail. I will get back, rest assured, but not today. :) |
I tried to run the test, but I think I don't have everything installed I need. I got this error:
|
You should be in the directory containing the code for this project before running Btw, as far as test suits are concerned Jasmine (v1.3) is just what is bundled into Atom, I've heard a lot of people prefer Mocha so you might want to look into that as well for your own projects 😉. |
Sorry - I posted the wrong error message. This is the one I meant to post:
Thanks for the comment about Mocha. I'll take a look. |
Looks like you need to run |
OK, that worked, but now I don't really know how to code the tests. Specifically, when using the waitsForPromise looking for an error message, I don't know how to figure out what exactly it should be looking for. Really, the existing tests should work just the same for a jxa file as for a js file. I could just duplicate the entire set of tests, just changing the language, but there's probably a better way than that. I'm beginning to think this is over my head, for the time being. I mean seriously, like you said, all that's needed is a minor addition to one line. |
#374 solves it. The |
Marking this as a duplicate of #372, since that moves the responsibility of making sure it works out to the user, bypassing all the extra steps required to ensure it is working that was being outlined above. |
Is there any way to have linter-jshint process files that have the Grammar specified as "JavaScript for Automation (JXA)"?
The only way I can use it right now is to change the Grammar to "JavaScript", then change it back, and that's no fun. :)
The text was updated successfully, but these errors were encountered: