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

new rule exports-valid #296

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

mightyiam
Copy link

@mightyiam mightyiam commented Jun 16, 2020

Draft for preliminary review

For reference:
https://nodejs.org/api/esm.html#esm_main_entry_point_export

Description of change

Checklist

  • Unit tests have been added
  • Specific notes for documentation, if applicable

Copy link
Author

@mightyiam mightyiam left a comment

Choose a reason for hiding this comment

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

Could I please get a preliminary review?

Comment on lines 26 to 132
failedCases.forEach(({title, input, fails}) => {
// eslint-disable-next-line jest/valid-title
test(title, () => {
Copy link
Author

Choose a reason for hiding this comment

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

Is this good Jest practice?

Copy link
Owner

Choose a reason for hiding this comment

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

I've typically seen each test explicitly called out and helpers are used to generate the data.

describe('exports-valid Unit Tests', () => {
describe('a rule type value should be exported', () => {
test('it should equal "standard"', () => {
expect(ruleType).toStrictEqual('standard');
Copy link
Author

Choose a reason for hiding this comment

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

I don't know what this is, really.

Copy link
Owner

Choose a reason for hiding this comment

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

We've been doing this as a sanity check that the rule type is configure correctly. The rule type allows each rule to accept a standard error/warning/off config, a config object, a list of values, or an optional config object.

const ruleType = 'standard';

const getKeyType = (key) => {
if (key.startsWith('/')) return 'invalid';
Copy link
Owner

Choose a reason for hiding this comment

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

Would you mind running the linter? It has prettier included for formatting.

@tclindner
Copy link
Owner

Nice work, @mightyiam. This is looking really good. Let me know if you have questions about my comments. I'm happy to discuss more!

@mightyiam mightyiam force-pushed the exports-valid branch 2 times, most recently from 6c399a0 to 653e05c Compare September 17, 2020 05:47
@mightyiam
Copy link
Author

Some of the checks I came up with are beyond validity. They are additional checks. For example, an array of fallbacks that has multiple valid values does not makes sense, because only the first will be used. I will split this work into multiple rules. By the way, I am streaming this work live. The schedule is here.

Copy link
Author

@mightyiam mightyiam left a comment

Choose a reason for hiding this comment

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

In the tests are all of the checks I came up with. Implementation seems to cover these tests and I'm OK with how it's written.

Now this rule should be split into multiple different rules. One rule for mere validity of the exports field and then for each additional check, a rule.

Is it OK that a single rule have numerous possible messages?

Would it be OK to namespace these rules like

  • exports-valid
  • exports-not-empty (or something else consistent with other rules)
  • exports-no-unreachable-fallback

and so on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants