Skip to content

refactor: Update calls to prettier functions to account for latest async API #403

Merged
lwasser merged 2 commits intoall-contributors:mainfrom
jdalrymple:ci/fixing-tests
Jan 27, 2026
Merged

refactor: Update calls to prettier functions to account for latest async API #403
lwasser merged 2 commits intoall-contributors:mainfrom
jdalrymple:ci/fixing-tests

Conversation

@jdalrymple
Copy link
Contributor

@jdalrymple jdalrymple commented Jan 25, 2026

What: Due to the prettier update, the API has changed - now exposing async functions

Why: API changes with latest dep version no longer support sync functions

How: Went through each related function and updated them accordingly

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Related to #375

# Conflicts:
#	package.json
#	src/init/__tests__/__snapshots__/add-contributors-list.js.snap
@jdalrymple jdalrymple changed the title [WIP] Testing fixes for prettier update refactor: Update calls to prettier functions to account for latest async API Jan 25, 2026
@jdalrymple jdalrymple marked this pull request as ready for review January 25, 2026 22:41

const absentFile = './abc'
const absentConfileFileExpected = `Configuration file not found: ${absentFile}`
const absentConfigFileExpected = `Configuration file not found: ${absentFile}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Praise] Nice catch 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to keep my clean up scope creeps to a minimum, but somethings i just hadddd to fix haha

@jdalrymple
Copy link
Contributor Author

Once this is in, ill look at the next blocked PR 🫡

@lwasser
Copy link
Member

lwasser commented Jan 27, 2026

@jdalrymple thank you for this refactor! I have a few questions!

With these refactors we are moving towards ES modules (yay!) ✨

But when i build the package, link/install and run this locally i get an error:

❯ all-contributors init
file:///Users/lblablabla/allcontributors/cli/dist/cli.js:4
const path = require('path');
             ^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '[/[[Users/lblablabla](file:///Users/lblablabla/)](file:///Users/lblablabla/)](file:///Users/lblablabla/allcontributors/cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///[Users/lblablabla](file:///Users/lblablabla/)/allcontributors/cli/dist/cli.js:4:14
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

  1. As we refactor, do we need to add "type": "module" to support this in our package.json ? But if we add that then how do we manage the older syntax? neither work for me locally when i run all-contributors init . (adding it or not adding it) but it seems like something is off. If this is a larger dependency issue then maybe we do have to merge as is
  2. If not, am i doing something wrong when i build and install locally:

npm run build
npm link

We could also merge this and just add that in a separate pr (if needed) bare with me!
I ask this seeing that tests pass. And i'm fine with smaller quicker iterations

and if this is what others see, we probably need to add a test or two to catch it. but please let's start with making sure you can see the same issue that I see locally! THANK YOU!!

@lwasser
Copy link
Member

lwasser commented Jan 27, 2026

Ok so when i don't add type:module (maybe the build system standardizes things? i haven't looked yet... i get a TYPEERROR related to yargs

TypeError: yargs.scriptName is not a function
    at getArgs (/Users/leahawasser/Documents/GitHub/allcontributors/cli/dist/cli.js:16:16)
    at run (/Users/leahawasser/Documents/GitHub/allcontributors/cli/dist/cli.js:99:18)
    at Object.<anonymous> (/Users/leahawasser/Documents/GitHub/allcontributors/cli/dist/cli.js:119:1)
    at Module._compile (node:internal/modules/cjs/loader:1706:14)
    at Object..js (node:internal/modules/cjs/loader:1839:10)
    at Module.load (node:internal/modules/cjs/loader:1441:32)
    at Function._load (node:internal/modules/cjs/loader:1263:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Function.e

I think this might be a yargs version error . I looked at the tests when i merged pr's but i didn't test the CLI each time assuming test coverage.

@lwasser
Copy link
Member

lwasser commented Jan 27, 2026

Ok it was bugging me - the fix is actually pinning yargs back to "yargs": "17.7.2". This is indeed a dependency issue. And the api was already broken and i missed it. thank goodness it's not deploying. I propose that we merge this. And we will have a larger set of fixes as we upgrade dependencies.

@lwasser lwasser self-requested a review January 27, 2026 04:03
Copy link
Member

@lwasser lwasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opening a quick pr to modify yargs

@lwasser lwasser merged commit 7d8c2bf into all-contributors:main Jan 27, 2026
1 check passed
@jdalrymple jdalrymple deleted the ci/fixing-tests branch January 28, 2026 04:07
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

Successfully merging this pull request may close these issues.

3 participants