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

fix(format-files): ensure paths passed to prettier-eslint are absolute paths #259

Merged
merged 1 commit into from
Mar 6, 2021

Conversation

dpwilhelmsen
Copy link
Contributor

What:

This addresses the error reported in #205 & #208. Error: 'basePath' should be an absolute path

Why:

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 PR ensures they are always absolute paths.

As an example, this command would fail:
prettier-eslint --list-different --write "./src/**/*.{js,jsx}"

To get it working with eslint@^6.7.0, you'd have to find a way to ensure the paths are absolute in the glob, like this:

prettier-eslint --list-different --write "$(pwd)/src/**/*.{js,jsx}"

This change would make either glob pattern valid.

How:

In format-files.js the filePathToFormatted has been updated to run the filePath variable through path.resolve() to ensure it is an absolute path before being passed into the formatFile method.

…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
@codecov-io
Copy link

codecov-io commented Apr 19, 2020

Codecov Report

Merging #259 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #259   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          123       124    +1     
  Branches        16        16           
=========================================
+ Hits           123       124    +1     
Impacted Files Coverage Δ
src/format-files.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29db6b5...4b9682b. Read the comment docs.

@jingsam
Copy link

jingsam commented Jul 9, 2020

This PR solved my issue. I am hoping for this PR to be merged

@NicolasRannou
Copy link

Bump :)

@jjorissen52
Copy link

@kentcdodds What needs to happen for this to be merged?

@kentcdodds
Copy link
Member

Sorry, I haven't maintained this project for years now. You'll need to find an active maintainer.

@kemicofa
Copy link

+1 would be nice to get this fixed

@marcofugaro
Copy link

Looks like this repo is dead

@kylemh kylemh merged commit dd70720 into prettier:master Mar 6, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2021

🎉 This PR is included in version 5.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants