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

Fix some tests that use callbacks #4970

Merged
merged 9 commits into from
Oct 13, 2020
Merged

Fix some tests that use callbacks #4970

merged 9 commits into from
Oct 13, 2020

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Oct 7, 2020

This PR fixes the following tests that use callbacks:

  • lib/utils/__tests__/findAtRuleContext.test.js
  • lib/utils/__tests__/isContextFunctionalPseudoClass.test.js
  • lib/utils/__tests__/isMap.test.js
  • lib/utils/__tests__/isStandardSyntaxFunction.test.js

Which issue, if any, is this issue related to?

This is a part of #4881.

Is there anything in the PR that needs further explanation?

This PR includes some indentation changes, so I recommend viewing with hidden whitespace changes.

@hudochenkov hudochenkov mentioned this pull request Oct 10, 2020
}
d {}
`;
a {}
Copy link
Member

Choose a reason for hiding this comment

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

Could increase all template literal content indentation by one level? So it look nicer :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I'll fix the template literals in other files in another PR. 💪

lib/utils/__tests__/findAtRuleContext.test.js Outdated Show resolved Hide resolved
postcss.parse(css).walkRules((rule) => {
parseSelector((selectorAST) => {
selectorAST.walkPseudos(cb);
selectorAST.walkPseudos((pseudo) => pseudos.push(pseudo));
Copy link
Member

Choose a reason for hiding this comment

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

Parameter pseudo is the same as function name pseudo. Maybe rename function to pseudoClass to avoid potential hard to find bugs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! ESLint's no-shadow rule may reduce our review cost:

$ npx eslint --rule "no-shadow: 2" lib/utils/__tests__/isContextFunctionalPseudoClass.test.js

/tmp/stylelint/lib/utils/__tests__/isContextFunctionalPseudoClass.test.js
  12:29  error  'pseudo' is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)

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've opened #4985 about the `no-shadow- rule.

lib/utils/__tests__/isStandardSyntaxFunction.test.js Outdated Show resolved Hide resolved
Copy link
Member

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

@ybiquitous ybiquitous merged commit 847fddc into master Oct 13, 2020
@ybiquitous ybiquitous deleted the fix-callbacks-in-test branch October 13, 2020 14:08
m-allanson added a commit that referenced this pull request Nov 5, 2020
* master: (46 commits)
  Update CHANGELOG.md
  Add ignoreAtRules to property-no-unknown (#4965)
  Bump eslint from 7.11.0 to 7.12.1 (#5017)
  Bump typescript from 4.0.3 to 4.0.5 (#5016)
  Bump lint-staged from 10.4.0 to 10.5.1 (#5014)
  Bump remark-cli from 8.0.1 to 9.0.0 (#4996)
  Bump jest-circus from 26.5.3 to 26.6.1 (#5009)
  Bump got from 11.7.0 to 11.8.0 (#5007)
  Bump jest from 26.5.3 to 26.6.1 (#5008)
  Refactor formatter tests (#4988)
  Fix `isStandardSyntaxDeclaration.test.js` that use callbacks (#4972)
  Update CHANGELOG.md
  Add "comment-pattern" rule (#4962)
  Update CHANGELOG.md
  Show the pattern in "*-pattern" rule messages (#4975)
  Enable ESLint `no-shadow` and add disable comments (#4986)
  Report disables in the same manner as lints (#4973)
  Update dependencies (#4982)
  Fix some tests that use callbacks (#4970)
  Use own vendor utility instead of PostCSS (#4942) (#4963)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants