brendanmorrell / eslint-plugin-styled-components-a11y

143 stars 20 forks source link

Tests: `mouse-events-have-key-events` fails with `Error type should be JSXOpeningElement, found JSXAttribute` #63

Closed abidjappie closed 3 months ago

abidjappie commented 4 months ago

I was was trying to run the test cases and found the following error:

AssertionError [ERR_ASSERTION]: Error type should be JSXOpeningElement, found JSXAttribute

I was able to make the tests pass by changing it to:

const mouseOverError = {
  message: 'onMouseOver must be accompanied by onFocus for accessibility.',
  type: 'JSXAttribute',
};
const mouseOutError = {
  message: 'onMouseOut must be accompanied by onBlur for accessibility.',
  type: 'JSXAttribute',
};

I am running the tests on node v20.12.2. Is there some additional step required to get the development set up running on local. If so, let me know if I need to update the readme/ or if I should prepare a PR to fix this if it is in fact wrong. 🙇

brendanmorrell commented 4 months ago

awesome! i would imagine you probably correctly fixed it, but let me take a look to trouble check. has been a very busy work week, but will try and take a look this weekend and let you know. Thanks!

On Wed, May 15, 2024 at 11:09 PM Abid @.***> wrote:

I was was trying to run the test cases and found the following error:

AssertionError [ERR_ASSERTION]: Error type should be JSXOpeningElement, found JSXAttribute

I was able to make the tests pass by changing it to:

const mouseOverError = { message: 'onMouseOver must be accompanied by onFocus for accessibility.', type: 'JSXAttribute',};const mouseOutError = { message: 'onMouseOut must be accompanied by onBlur for accessibility.', type: 'JSXAttribute',};

I am running the tests on node v20.12.2. Is there some additional step required to get the development set up running on local. If so, let me know if I need to update the readme/ or if I should prepare a PR to fix this if it is in fact wrong. 🙇

— Reply to this email directly, view it on GitHub https://github.com/brendanmorrell/eslint-plugin-styled-components-a11y/issues/63, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRNADIKSHOWQJUNJKMFZ7TZCQ5RFAVCNFSM6AAAAABHZODCE2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4TSMZWGU2TMNI . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

brendanmorrell commented 3 months ago

so, took a look, and honestly, not sure why the errors in those tests are registering the type as JSXAttribute when it is actually JSXOpeningElement. I see that the parsing function that is being used in the rule is JSXOpeningElement, which is correct, and is the same as is used in jsx-a11y, so not clear on where that type is coming from in the error. Regardless, i see that the errors are correctly being reported, and match jsx-a11y, so i don't think it is too important. to fix it, i just removed the type key from the error message objects. PR is merged if you want to pull down latest. as for getting it running on local, it is a bit of a pain. i usually have a sandbox project running with this plugin/eslint and i point the package location for eslint-plugin-styled-components-a11y to the local version i am editing like this:

{
  "name": "baz",
  "dependencies": {
    "eslint-plugin-styled-components-a11y": "file:../wherever/your/repo/is/saved"
  }
}

and then i run an install so it grabs the code from my local to use for linting. then i add console logs wherever i need to in the code to see what is happening with the package. hope that helps