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

Error: 'basePath' should be an absolute path. #208

Closed
JohnApache opened this issue Nov 27, 2019 · 12 comments
Closed

Error: 'basePath' should be an absolute path. #208

JohnApache opened this issue Nov 27, 2019 · 12 comments

Comments

@JohnApache
Copy link

Command:

$ prettier-eslint 'src/**/*.{ts,tsx}' --write 

Executing this command throws an exception!

but when I use the full path, Like this:

$ prettier-eslint '/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/src/**/*.{ts,tsx}' --write 
 

no error is reported, but I want to support relative paths

When I use version 6.6.0 of eslint,also no error is reported;

Now I have to reduce the eslint version to solve this problem

Version:

  • prettier-eslint-cli version:4.7.1
  • prettier version: 1.19.1
  • eslint version:6.7.1

Target:

// src/index.ts
const a = () => {
console.log(1);
};

What you did:

$ prettier-eslint 'src/**/*.{ts,tsx}' --write

What happened:
Error Log:

prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.
prettier-eslint-cli [ERROR]: There was an error formatting "src/index.ts": 
    AssertionError [ERR_ASSERTION]: 'basePath' should be an absolute path.
        at new IgnorePattern (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js:178:9)
        at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/config-array-factory.js:651:49)
        at _normalizeObjectConfigDataBody.next (<anonymous>)
        at ConfigArrayFactory._normalizeObjectConfigData (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/config-array-factory.js:594:20)
        at _normalizeObjectConfigData.next (<anonymous>)
        at createConfigArray (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/config-array-factory.js:338:25)
        at ConfigArrayFactory.create (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/config-array-factory.js:393:16)
        at createBaseConfigArray (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:96:48)
        at new CascadingConfigArrayFactory (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:211:30)
        at new CLIEngine (/Users/cuijianwei/WebstormProjects/testproject/hasaki-cli-demo/gen-demo/node_modules/eslint/lib/cli-engine/cli-engine.js:563:36)
failure formatting 1 file with prettier-eslint
error Command failed with exit code 1.
@JonDum
Copy link

JonDum commented Dec 3, 2019

I'm getting the same issue.

It's a stopgap solution, but adding $PWD in front of your glob seems to fix it. might need to use cross-env if you support non-nix systems.

Example:

    "format": "prettier-eslint --write $PWD/'src/**/*.[jt]s?(x)' && eslint --fix ."

@JohnApache
Copy link
Author

@JonDum
Thank u!
But $PWD does not work correctly on windows, my current solution is to reduce the eslint version to @6.6.0, this works.
I don't know why the absolute path is limited in eslint@6.7.1?

@MrCheater
Copy link

+1

@NoPhaseNoKill
Copy link

Any updates to this? Facing same issue currently

@tr1ms
Copy link

tr1ms commented Mar 29, 2020

Any updates to this? Facing same issue currently

@JonDum solution works for me, I've eslint 6.8.0

dpwilhelmsen added a commit to dpwilhelmsen/prettier-eslint-cli that referenced this issue Apr 19, 2020
…ute paths

As of the 6.7.0 release of eslint, absolute paths are required when eslint is
searching for ignore patterns (eslint/eslint@ca3b2a6).
This causes prettier-eslint-cli to fail if called with a glob pattern using
relative paths. This commit passes the file path through the `path.resolve` method
to ensure they are always absolute paths.

Addresses issues prettier#205 & prettier#208
dpwilhelmsen added a commit to dpwilhelmsen/prettier-eslint-cli that referenced this issue Apr 19, 2020
…ute paths

As of the 6.7.0 release of eslint, absolute paths are required when eslint is
searching for ignore patterns (eslint/eslint@ca3b2a6).
This causes prettier-eslint-cli to fail if called with a glob pattern using
relative paths. This commit passes the file path through the `path.resolve` method
to ensure they are always absolute paths.

Addresses issues prettier#205 & prettier#208
@pittersnider
Copy link

Still having the issue.

@dpwilhelmsen
Copy link
Contributor

I opened a pull request that should resolve this, #259. Haven't seen any response on it yet, but feel free to try the branch.

@mathiaswillburger
Copy link

mathiaswillburger commented Aug 13, 2020

The following solution works for me on Windows with eslint@7.6.0, no downgrade required:

Either use npx to execute the command directly in your project path and it will recognize $PWD, e.g. : npx prettier-eslint --write $PWD/src/**/*.{js,jsx} or if you want to have it as script in the package.json file (which actually will not recognize $PWD) you'll have to use %INIT_CWD% instead like this:

"scripts": {
    "format": "prettier-eslint --write %INIT_CWD%/src/**/*.{js,jsx}",
  },

and you can execute it as usual using npm run format

kylemh pushed a commit that referenced this issue Mar 6, 2021
…ute paths (#259)

As of the 6.7.0 release of eslint, absolute paths are required when eslint is
searching for ignore patterns (eslint/eslint@ca3b2a6).
This causes prettier-eslint-cli to fail if called with a glob pattern using
relative paths. This commit passes the file path through the `path.resolve` method
to ensure they are always absolute paths.

Addresses issues #205 & #208
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2021

Stale issue

@kylemh
Copy link
Collaborator

kylemh commented Mar 7, 2021

Hey, shut up you. I haven't gotten to it yet.

@JounQin
Copy link
Member

JounQin commented Aug 7, 2022

https://antfu.me/posts/why-reproductions-are-required

Feel free to create a new issue with minimal but runnable reproduction.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2022
@kylemh
Copy link
Collaborator

kylemh commented Aug 7, 2022

FWIW: #259 was merged so this issue should be resolved.

@kylemh kylemh closed this as completed Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants