-
-
Notifications
You must be signed in to change notification settings - Fork 681
Issues with loading plugin via ESLint API when running Jest #290
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
Comments
Thank you for this report. Personally, I think that it's a problem of Jest, but I agree that we should leave from using deprecated API. |
What about Something like: 'use strict'
const resolve = require('path').resolve
const requireAll = require('require-all')
const rules = requireAll({
dirname: resolve(__dirname, 'rules'),
filter
})
const config = requireAll({
dirname: resolve(__dirname, 'config'),
filter
})
function filter (filename) {
const name = filename.split('.')[0]
if (!name) return
return name
}
module.exports = {
rules,
configs
} I can submit the PR if accepted. |
Sounds good to me @scriptdaemon That would be appreciated :) |
btw. |
Swap out `requireindex` dependency with the more recently updated dependency `require-all`. The old dependency uses deprecated API that breaks when running in a Jest testing environment. Fixes vuejs#290
Swap out `requireindex` dependency with the more recently updated dependency `require-all`. The old dependency uses deprecated API that breaks when running in a Jest testing environment. Fixes #290
Tell us about your environment
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
Tried testing my ESLint config via Jest.
What did you expect to happen?
Config to load correctly, tests to pass.
What actually happened? Please include the actual, raw output from ESLint.
The reason this happens is that the
requireindex
dependency checks filenames againstrequire.extensions
(1), which is deprecated. When running Jest,require.extensions
is empty, and thus the config files never get loaded (2).requireindex
hasn't been updated since 2014. Can we look for a suitable replacement, or would it make sense to integrate it into the plugin's codebase as a utility function withoutrequire.extensions
?Edit: Looks like this issue was brought up with Jest already: jestjs/jest#2017. Given that this is still an issue, and I feel it is more proper to move away from deprecated API anyway, I still think the best solution would be to stop using
requireindex
.The text was updated successfully, but these errors were encountered: