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

Chore: Extract config comment parsing #11091

Merged
merged 6 commits into from Nov 19, 2018
Merged

Chore: Extract config comment parsing #11091

merged 6 commits into from Nov 19, 2018

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Nov 16, 2018

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:

Extracted config comment parsing into a separate utility.

What changes did you make? (Give an overview)

While digging around in Linter, I realized that the config comment parsing could be completely separated out, allowing us to better test config comment parsing. I just extracted the existing helper functions from linter.js and put them into a class. I also wrote up some basic tests based on the comments inside the code to verify everything works. At some point I'd like to go back and clean up the methods a bit to make them less tied to what's going on inside of linter.js, but for now this helps make linter.js smaller and gives us a place to test for further changes in comment parsing.

I'd really like to make linter.js smaller as it's over 1,000 lines right now and a bit hard to follow.

Is there anything you'd like reviewers to focus on?

Does this approach make sense?

@nzakas nzakas added core Relates to ESLint's core APIs and features chore This change is not user-facing labels Nov 16, 2018
@nzakas
Copy link
Member Author

nzakas commented Nov 16, 2018

Hmm, looks like the build is breaking only in Node 11 due to a completely unrelated problem. MockFS existsSync seems to be throwing an error in Node 11 when the file isn't found instead of returning false: tschaub/mock-fs#256

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for doing this! (It's been on my list for quite some time...)

There are a lot of commented tests. What's the plan for those?

constructor() {
debug("Created ConfigCommentParser");

// empty for now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to put more in here? Seems like it's pretty clear to me this is only used for debugging purposes at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking at some point I'd add a strict option to remove some of the fallback behavior we have. Right now it's just a placeholder though. I can remove it if it's vexing.

tests/lib/util/config-comment-parser.js Outdated Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Nov 19, 2018

@platinumazure what commented tests are you referring to?

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nzakas nzakas merged commit f394a1d into master Nov 19, 2018
@nzakas nzakas deleted the config-comments branch November 19, 2018 18:06
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 19, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants