Skip to content

test(eslint-plugin): migrate validation tools to jest test cases #1403

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

Merged
merged 6 commits into from
Jan 7, 2020
Merged

test(eslint-plugin): migrate validation tools to jest test cases #1403

merged 6 commits into from
Jan 7, 2020

Conversation

armano2
Copy link
Collaborator

@armano2 armano2 commented Jan 5, 2020

This is follow up PR that changes way how we do test configs and documentations.

There is few positives and negatives with changing it to tests:

  • Custom tools are more descriptive and can/show custom messages like "run x command"
  • Tests uses common framework to validate if configurations/documents are valid, it means that they can be simpler, because we can utilize jest functions (like comparing objects), that allows us to reduce complexity.

For example new configs validation is going to look like this

all.json config › contains all @typescript-eslint/eslint-plugin rule modules, except the deprecated ones

expect(received).toEqual(expected) // deep equality
- Expected
+ Received

@@ -2,10 +2,11 @@
   "@typescript-eslint/adjacent-overload-signatures": "error",
   "@typescript-eslint/array-type": "error",
   "@typescript-eslint/await-thenable": "error",
   "@typescript-eslint/ban-ts-ignore": "error",
   "@typescript-eslint/ban-types": "error",
+  "@typescript-eslint/brace-style": "error",
   "@typescript-eslint/camelcase": "error",
   "@typescript-eslint/class-name-casing": "error",
   "@typescript-eslint/consistent-type-assertions": "error",
   "@typescript-eslint/consistent-type-definitions": "error",
   "@typescript-eslint/explicit-function-return-type": "error",

TODO:

  • update test tiles

#1396 (comment)

@typescript-eslint

This comment has been minimized.

bradzacher
bradzacher previously approved these changes Jan 5, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

few nits on the test wording.
might as well be more explicit whilst we're at it.

otherwise, LGTM - thanks for doing this

// find the table
const rulesTable = readme.find(
token => token.type === 'table',
) as marked.Tokens.Table;
Copy link
Member

Choose a reason for hiding this comment

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

Nit - I probably should have correctly typed this

Suggested change
) as marked.Tokens.Table;
) as marked.Tokens.Table | undefined;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's correct, i just copy/paste it from tools :>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this actually should be:

Suggested change
) as marked.Tokens.Table;
const rulesTable = readme.find(
(token): token is marked.Tokens.Table => token.type === 'table',
);

@bradzacher bradzacher added the tests anything to do with testing label Jan 5, 2020
@armano2 armano2 marked this pull request as ready for review January 7, 2020 19:20
Copy link
Member

@bradzacher bradzacher 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!

@bradzacher bradzacher merged commit 40d9127 into typescript-eslint:master Jan 7, 2020
@armano2 armano2 deleted the tools-to-tests branch January 7, 2020 19:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tests anything to do with testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants