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
Pass filename as an argument to parse
#5344
Comments
I seem to remember that we already have something like that. We had a request a while back to pass filenames to rules, so we added a function to the rule |
I don't think the |
Oh, sorry, for some reason I though you were talking about |
@nmote can you explain how you see this working? Keep in mind, we'd need something that won't interfere with how other parsers work. |
I think the clearest thing would be for me to just put up a PR and we can discuss there. What I have is just a third argument passed to |
So either |
Both of those would be fine with me, although perhaps |
I thinking something in the options object makes the most sense. My fear of adding another parameter is that we could run into collisions should a parser randomly decide they want to add a third parameter. My only fear about |
Sounds good to me. Suggestions for a specific option name? I'll put together a PR. |
|
@nmote Do you just need filename, or do you need a full path to a file? |
Well, we at least need a relative path. Sorry for not being clearer throughout. With that in mind I think |
That's why I asked. Yes, or |
|
@nmote do you still plan to put together a PR for this? |
I do, sorry for the delay: I've been busy with other things. It's near the top of my list and I'll do it this week. |
@nmote I think you have done the work but didn't open a pull request. Do you want to open a pull request? |
I can finish this up using that commit if @nmote doesn't (actually seems to be helpful for babel-eslint errors in general when figuring out how to run eslint tests) |
There was a pull request that we closed because it was abandoned. @hzoo I'd say go for it. |
@hzoo (just checking) r u working on this? |
i can take this on if @hzoo isn't working on it! how do i go about writing tests? i haven't made a core contribution yet so i'm not sure how to get started |
@azhang496 Unit tests are located here: https://github.com/eslint/eslint/blob/master/tests/lib/eslint.js You will probably need to create fake parser through Sinon and verify that filename is passed into parse method. |
@azhang496 If you'd like to, go ahead! |
I have been experimenting with type-aware lint rules. The prototype I have combines Flow with
babel-eslint
to annotate the AST with type information.However, for Flow to be able to provide complete type information it needs the path to the current file so that it can properly resolve imports/requires. To that end I would like to pass the file name as an argument to
parse
.I understand that this is a radical departure from the current idea of what a frontend for ESLint is, but the change required to support this idea is very small and will not interfere with existing code. I'm happy to put up a pull request if it is likely to be accepted.
The text was updated successfully, but these errors were encountered: