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

Centralize @babel/eslint-* tests #11106

Merged
merged 3 commits into from Feb 8, 2020

Conversation

kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Feb 6, 2020

Q                       A
Fixed Issues?
Patch: Bug Fix?
Patch: Chore? 👍
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I've been trying to figure out how to structure tests (and which packages should be responsible for which tests), and have decided to advocate for the following:

  • @babel/eslint-parser: Only tests the shape of the AST (and asserts that it matches Espree's)
  • @babel/eslint-plugin: Only test core rules that we have to create an @babel/* copy of
  • @babel/eslint-tests: Integration/performance tests (typescript-eslint has a similar setup). This includes testing with ESLint itself, the ESLint core rules that we don't have to override, popular plugins, etc.

I've moved all of the integration-y (by the definition above) tests into @babel/eslint-tests to centralize them there. Just to be clear, @babel/eslint-tests should never be published. I made it a package because we need to install deps for testing.

Thoughts/concerns?

I'm not sure why we weren't linting any of the @babel/eslint-* test files, but I enabled that as well.

@@ -1,6 +0,0 @@
class ClassName {
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 don't think this is actually being used anywhere?

}${message.ruleId ? ` ${message.ruleId}` : ""}`;
const expectedMessage = expectedMessages[i];

if (expectedMessage instanceof RegExp) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added the ability to pass this function a RegExp so we can enable the xited test below.

Copy link
Member

Choose a reason for hiding this comment

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

Can we use jest's methods instead of writing our own errors checking logic?

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 think that would be great. Mind if we do that in a follow up PR?

Copy link
Member

Choose a reason for hiding this comment

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

It's ok!

verifyAndAssertMessages("{ , res }", {}, [
"1:3 Parsing error: Unexpected token",
/1:2 Parsing error:.*Unexpected token \(1:2\)/,
Copy link
Member Author

Choose a reason for hiding this comment

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

This error reports an absolute file path, which is why I'm assuming it was disabled. With RegExp support we can now enable this!

@kaicataldo
Copy link
Member Author

kaicataldo commented Feb 7, 2020

Hm, looks like CI is failing in Windows when the machine is trying to install yarn. Fixed!

@kaicataldo kaicataldo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Feb 7, 2020
@kaicataldo kaicataldo merged commit 5aa368c into babel:master Feb 8, 2020
@kaicataldo kaicataldo deleted the centralize-babel-eslint-tests branch February 8, 2020 15:04
rajasekarm pushed a commit to rajasekarm/babel that referenced this pull request Feb 17, 2020
* Centralize @babel/eslint-* tests

* Enable linting of @babel/eslint-* test files

* Add missing sourceType
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 10, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint area: tests outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants