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
Bug: All ESLint 8 commands fail if the project path contains URL-encoded characters #15766
Comments
This error is coming from eslint/lib/cli-engine/cli-engine.js Line 33 in bb4c0d5
Do you see this behavior in ESLint v8.0.0? |
Looking at the line const require$1 = Module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('eslintrc.cjs', document.baseURI).href))); You can see the whole file here: https://unpkg.com/@eslint/eslintrc@1.2.1/dist/eslintrc.cjs The corresponding source code is this harmless-looking line in eslintrc: const require = createRequire(import.meta.url); which can be found here: https://github.com/eslint/eslintrc/blob/9b719813fc6f023b722168a4f67d895106e875ce/lib/config-array-factory.js#L58 From what I can tell, the generated code is trying to create a file URL from This is not a bug in ESLint, but rather an issue with the build tools used in eslintrc, most probably Rollup. |
@fasttime wow, thanks for the detailed analysis. We will look deeper into this. |
@fasttime thanks for all the details! I prepared a possible fix based on your suggestion. |
* fix: use custom Rollup plugin for `import.meta.url` Refs eslint/eslint#15766 * Use URL#toString() Co-authored-by: 唯然 <weiran.zsd@outlook.com> Co-authored-by: 唯然 <weiran.zsd@outlook.com>
* fix: allow project paths to have URL-encoded characters Fixes #15766 * test with eslintrc main branch * use v1.2.2
Thanks all for the quick response! ❤️ |
* fix: allow project paths to have URL-encoded characters Fixes eslint#15766 * test with eslintrc main branch * use v1.2.2
Environment
Node version: 14.18.2
npm version: 6.14.15
Local ESLint version: 8.12.0
Global ESLint version: none
Operating System: Darwin 20.6.0 (macOS Big Sur)
What parser are you using?
@typescript-eslint/parser
What did you do?
Try to run any ESLint command in a project path with a URL encoded character, such as
/my%2Fproject/yarn eslint --env-info
.What did you expect to happen?
Command would succeed with the expected output, such as:
What actually happened?
Example
A project with
eslint@8.12.0
installed is in the following path that includes a URL-encoded slash:/Users/myuser/my%2Fproject
Run any ESLint command, such as
--env-info
and it fails with the following:Participation
Additional comments
Prior versions of ESLint, such as
7.32.0
, work fine with these paths. For example, this works fine:The text was updated successfully, but these errors were encountered: