jsx-eslint / eslint-plugin-jsx-a11y

Static AST checker for a11y rules on JSX elements.
MIT License
3.38k stars 637 forks source link

TypeError: (0 , _minimatch.default) is not a function #929

Closed semihraifgurel closed 8 months ago

semihraifgurel commented 1 year ago
TypeError: (0 , _minimatch.default) is not a function
Occurred while linting /Users/user/project/src/components/Search.tsx:64
Rule: "jsx-a11y/label-has-associated-control"

TypeError: (0 , _minimatch.default) is not a function
Occurred while linting /Users/user/project/src/components/Search.tsx:64
Rule: "jsx-a11y/label-has-associated-control"
    at traverseChildren (/Users/user/project/node_modules/eslint-plugin-jsx-a11y/lib/util/mayContainChildComponent.js:38:102)
    at mayContainChildComponent (/Users/user/project/node_modules/eslint-plugin-jsx-a11y/lib/util/mayContainChildComponent.js:48:10)
    at /Users/user/project/node_modules/eslint-plugin-jsx-a11y/lib/rules/label-has-associated-control.js:69:57
    at Array.some (<anonymous>)
    at rule (/Users/user/project/node_modules/eslint-plugin-jsx-a11y/lib/rules/label-has-associated-control.js:68:48)
    at ruleErrorHandler (/Users/user/project/node_modules/eslint/lib/linter/linter.js:1077:28)
    at /Users/user/project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/user/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/user/project/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
Process finished with exit code -1
"rules": {
    "jsx-a11y/label-has-associated-control": [
        2,
        {
            "labelComponents": ["Label"],
            "labelAttributes": ["label"],
            "controlComponents": ["Input", "Search"],
            "depth": 3
        }
    ],
}

"eslint": "^8.38.0",

const Search = () => {
    return (
        <div className='d-flex' data-tour='search'>
            <label className='border-0 bg-transparent cursor-pointer' htmlFor='searchInput'>
                <Icon icon='Search' size='2x' color='primary' />
            </label>
            <Input
                id='searchInput'
                type='search'
                className='border-0 shadow-none bg-transparent'
                placeholder='Search...'
                onChange={formik.handleChange}
                value={formik.values.searchInput}
                autoComplete='off'
            />
        </div>
    )
};
ljharb commented 1 year ago

Seems like a bug in minimatch. What version do you have installed?

semihraifgurel commented 1 year ago
"eslint-plugin-jsx-a11y": "^6.7.1",
ljharb commented 1 year ago

I asked about minimatch.

poshiemaaat commented 8 months ago

Was this ever solved? minimatch isn't a direct dependency of ours but I can see it's using 3.1.2.

ljharb commented 8 months ago

@poshiemaaat no, but thanks that helps. what is typeof require('minimatch') in the repl?

poshiemaaat commented 8 months ago

@ljharb I'm not sure how to do that, actually. I can't seem to reproduce this at all locally; it's just failing in our pipeline. I have identical files locally to the best of my knowledge. I'm not sure how to "monkey-patch" the node_modules file in the pipeline to get the value of typeof require('minimatch') here.

poshiemaaat commented 8 months ago

Pipeline is running node 20.10.0, ubuntu:22.04 btw!

poshiemaaat commented 8 months ago

I GOT IT

Run a npm dedupe to force the minimatch package to get upgraded to v9.x. Pipeline was happy now. Oh my goodness.

poshiemaaat commented 8 months ago

Oh and you can see the list of minimatch packages installed due to all the dependency tree by running npm ls minimatch. Thank me later.

ljharb commented 8 months ago

npm explain minimatch should give you more helpful output.

we require minimatch v3 here, so using v9 i would expect to break things :-/

poshiemaaat commented 8 months ago

Oooooh good point. I must have missed something too because I now see 3.1.2 again, but the pipeline is happy. Soooooooooooooooo 🤫 don't spook the pipeline.

ljharb commented 8 months ago

Given that @semihraifgurel hasn't replied; yarn is known to be broken; and your issue was resolved, I'm going to close this, but will be happy to reopen if needed.