Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Bump eslint-config-stylelint from 12.0.0 to 13.1.0; resolves newly-caught errors #80

Merged

Conversation

dependabot[bot]
Copy link

@dependabot dependabot bot commented on behalf of github Nov 18, 2020

Bumps eslint-config-stylelint from 12.0.0 to 13.1.0.

Release notes

Sourced from eslint-config-stylelint's releases.

13.1.0

  • Added: allow option to no-console rule.

13.0.0

  • Added: no-shadow rule.

12.1.0

  • Changed: Bump eslint-plugin-jest from v23 to v24.
Changelog

Sourced from eslint-config-stylelint's changelog.

13.1.0

  • Added: allow option to no-console rule.

13.0.0

  • Added: no-shadow rule.

12.1.0

  • Changed: Bump eslint-plugin-jest from v23 to v24.
Commits
Maintainer changes

This version was pushed to npm by ybiquitous, a new releaser for eslint-config-stylelint since your current version.


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added the pr: dependencies relates to dependencies label Nov 18, 2020
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-config-stylelint-13.1.0 branch 7 times, most recently from 9cece68 to 8402bac Compare January 7, 2021 09:29
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-config-stylelint-13.1.0 branch 2 times, most recently from d295262 to c70ffdc Compare January 19, 2021 08:58
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-config-stylelint-13.1.0 branch from c70ffdc to d7c3017 Compare February 1, 2021 09:00
@mattxwang
Copy link
Member

Just pushed some changes that resolve all the no-shadow issues surrounding non-test cases. The only errors that are now left are:

  • jest/valid-title errors, which are occurring because several tests are mapped onto an array, and there is no type-guarantee that each element is a string (though checking manually, each one is)
  • jest/no-conditional-expect errors, which are occurring because we're calling expect on different types of objects, and using a different expect value depending on the type of object

I'm not sure what the best practice is, or if there's a stylelint-preferred way of resolving these errors, but I'm more than happy to try out any suggestions the team has!

@ybiquitous
Copy link
Member

Hi @mattxwang, we can fix jest/valid-title errors by converting the argument to a string via a template literal. See below:

 	].forEach((file) => {
-		it(file, () => {
+		it(`${file}`, () => {
 			file = require.resolve('./fixtures/' + file);

it() requires a string argument, so I think it better to pass an explicit string instead of a dynamic value.

@mattxwang
Copy link
Member

Great, thanks for the suggestions! I can resolve those then!

@ybiquitous
Copy link
Member

We can also fix jest/no-conditional-expect errors by avoiding control statements or callbacks (e.g. if, for, or .forEach()).

Jest does not ensure that assertions within control blocks or callback functions are performed.
(it is the responsibility of programmers)

So, I think a straightforward and flat style can avoid unexpected bugs in test code, for example:

// good
let root = document.nodes[0]
expect(root.nodes).toHaveLength(1);
expect(root.nodes[0]).toHaveProperty('type', 'decl');
expect(root.nodes[0]).toHaveProperty('prop', 'display');
expect(root.nodes[0]).toHaveProperty('value', 'inline-block');

// not good
document.nodes.forEach((root, i) => { // This test passes even if `document.nodes` is empty!!!
	switch (i) {
		case 0: {
			expect(root.nodes).toHaveLength(1);
			root.nodes.forEach((decl) => {
				expect(decl).toHaveProperty('type', 'decl');
				expect(decl).toHaveProperty('prop', 'display');
				expect(decl).toHaveProperty('value', 'inline-block');
			});
			return;
		}
		// ...
	}
});

@mattxwang
Copy link
Member

mattxwang commented Mar 8, 2021

Hm, for the jest/no-conditional-expect issues, I see the solution you propose and it makes a lot of sense!

However, I'm a bit unsure of how to proceed: the current test fixture (tests/fixtures/interpolation-content.mjs) has quite a bit of content within it, so it seems like there may be up to 45 total expects. Should I still enumerate these out? Or is there a better approach I can take? Ex breaking up the fixture?

@mattxwang mattxwang changed the title Bump eslint-config-stylelint from 12.0.0 to 13.1.0 Bump eslint-config-stylelint from 12.0.0 to 13.1.0; resolves newly-caught errors Mar 8, 2021
@ybiquitous
Copy link
Member

Ah, in this case, I think it good to keep the test code as-is and add /*eslint-disable*/ comment with a reason. For example:

/* eslint-disable jest/no-conditional-expect -- some reason... */
...
/* eslint-enable jest/no-conditional-expect */

Rewriting the test much seems risky in this case.

@mattxwang
Copy link
Member

mattxwang commented Mar 8, 2021

Thank you for the feedback @ybiquitous! I disabled the test for that block and added a comment pointing back to this issue.

Upon merging master back into this branch (to resolve a merge conflict), I noticed another new instance of the error in test/styled-components.js. In this case, there were only eight nodes, so I was able to easily resolve the issue. I also removed a now-redundant test as we no longer run a .forEach over the code! I added a comment to describe the change, and also points back to this issue. Let me know what you think!

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

@mattxwang I think your work is great! 👏

@mattxwang mattxwang merged commit de53989 into master Mar 8, 2021
@mattxwang mattxwang deleted the dependabot/npm_and_yarn/eslint-config-stylelint-13.1.0 branch March 8, 2021 06:47
@mattxwang
Copy link
Member

Thank you for all the help, appreciate it! 😊

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: dependencies relates to dependencies
Development

Successfully merging this pull request may close these issues.

2 participants